Rust implementation of the CVM algorithm for counting distinct elements in a stream
0

Configure Feed

Select the types of activity you want to include in your feed.

Initial cargo dist run

+292 -1
+271
.github/workflows/release.yml
··· 1 + # Copyright 2022-2024, axodotdev 2 + # SPDX-License-Identifier: MIT or Apache-2.0 3 + # 4 + # CI that: 5 + # 6 + # * checks for a Git Tag that looks like a release 7 + # * builds artifacts with cargo-dist (archives, installers, hashes) 8 + # * uploads those artifacts to temporary workflow zip 9 + # * on success, uploads the artifacts to a GitHub Release 10 + # 11 + # Note that the GitHub Release will be created with a generated 12 + # title/body based on your changelogs. 13 + 14 + name: Release 15 + 16 + permissions: 17 + contents: write 18 + 19 + # This task will run whenever you push a git tag that looks like a version 20 + # like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. 21 + # Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where 22 + # PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION 23 + # must be a Cargo-style SemVer Version (must have at least major.minor.patch). 24 + # 25 + # If PACKAGE_NAME is specified, then the announcement will be for that 26 + # package (erroring out if it doesn't have the given version or isn't cargo-dist-able). 27 + # 28 + # If PACKAGE_NAME isn't specified, then the announcement will be for all 29 + # (cargo-dist-able) packages in the workspace with that version (this mode is 30 + # intended for workspaces with only one dist-able package, or with all dist-able 31 + # packages versioned/released in lockstep). 32 + # 33 + # If you push multiple tags at once, separate instances of this workflow will 34 + # spin up, creating an independent announcement for each one. However, GitHub 35 + # will hard limit this to 3 tags per commit, as it will assume more tags is a 36 + # mistake. 37 + # 38 + # If there's a prerelease-style suffix to the version, then the release(s) 39 + # will be marked as a prerelease. 40 + on: 41 + push: 42 + tags: 43 + - '**[0-9]+.[0-9]+.[0-9]+*' 44 + pull_request: 45 + 46 + jobs: 47 + # Run 'cargo dist plan' (or host) to determine what tasks we need to do 48 + plan: 49 + runs-on: ubuntu-latest 50 + outputs: 51 + val: ${{ steps.plan.outputs.manifest }} 52 + tag: ${{ !github.event.pull_request && github.ref_name || '' }} 53 + tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} 54 + publishing: ${{ !github.event.pull_request }} 55 + env: 56 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 57 + steps: 58 + - uses: actions/checkout@v4 59 + with: 60 + submodules: recursive 61 + - name: Install cargo-dist 62 + # we specify bash to get pipefail; it guards against the `curl` command 63 + # failing. otherwise `sh` won't catch that `curl` returned non-0 64 + shell: bash 65 + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" 66 + # sure would be cool if github gave us proper conditionals... 67 + # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible 68 + # functionality based on whether this is a pull_request, and whether it's from a fork. 69 + # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* 70 + # but also really annoying to build CI around when it needs secrets to work right.) 71 + - id: plan 72 + run: | 73 + cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json 74 + echo "cargo dist ran successfully" 75 + cat plan-dist-manifest.json 76 + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" 77 + - name: "Upload dist-manifest.json" 78 + uses: actions/upload-artifact@v4 79 + with: 80 + name: artifacts-plan-dist-manifest 81 + path: plan-dist-manifest.json 82 + 83 + # Build and packages all the platform-specific things 84 + build-local-artifacts: 85 + name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) 86 + # Let the initial task tell us to not run (currently very blunt) 87 + needs: 88 + - plan 89 + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} 90 + strategy: 91 + fail-fast: false 92 + # Target platforms/runners are computed by cargo-dist in create-release. 93 + # Each member of the matrix has the following arguments: 94 + # 95 + # - runner: the github runner 96 + # - dist-args: cli flags to pass to cargo dist 97 + # - install-dist: expression to run to install cargo-dist on the runner 98 + # 99 + # Typically there will be: 100 + # - 1 "global" task that builds universal installers 101 + # - N "local" tasks that build each platform's binaries and platform-specific installers 102 + matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} 103 + runs-on: ${{ matrix.runner }} 104 + env: 105 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 106 + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json 107 + steps: 108 + - name: enable windows longpaths 109 + run: | 110 + git config --global core.longpaths true 111 + - uses: actions/checkout@v4 112 + with: 113 + submodules: recursive 114 + - uses: swatinem/rust-cache@v2 115 + with: 116 + key: ${{ join(matrix.targets, '-') }} 117 + - name: Install cargo-dist 118 + run: ${{ matrix.install_dist }} 119 + # Get the dist-manifest 120 + - name: Fetch local artifacts 121 + uses: actions/download-artifact@v4 122 + with: 123 + pattern: artifacts-* 124 + path: target/distrib/ 125 + merge-multiple: true 126 + - name: Install dependencies 127 + run: | 128 + ${{ matrix.packages_install }} 129 + - name: Build artifacts 130 + run: | 131 + # Actually do builds and make zips and whatnot 132 + cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json 133 + echo "cargo dist ran successfully" 134 + - id: cargo-dist 135 + name: Post-build 136 + # We force bash here just because github makes it really hard to get values up 137 + # to "real" actions without writing to env-vars, and writing to env-vars has 138 + # inconsistent syntax between shell and powershell. 139 + shell: bash 140 + run: | 141 + # Parse out what we just built and upload it to scratch storage 142 + echo "paths<<EOF" >> "$GITHUB_OUTPUT" 143 + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" 144 + echo "EOF" >> "$GITHUB_OUTPUT" 145 + 146 + cp dist-manifest.json "$BUILD_MANIFEST_NAME" 147 + - name: "Upload artifacts" 148 + uses: actions/upload-artifact@v4 149 + with: 150 + name: artifacts-build-local-${{ join(matrix.targets, '_') }} 151 + path: | 152 + ${{ steps.cargo-dist.outputs.paths }} 153 + ${{ env.BUILD_MANIFEST_NAME }} 154 + 155 + # Build and package all the platform-agnostic(ish) things 156 + build-global-artifacts: 157 + needs: 158 + - plan 159 + - build-local-artifacts 160 + runs-on: "ubuntu-20.04" 161 + env: 162 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 163 + BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json 164 + steps: 165 + - uses: actions/checkout@v4 166 + with: 167 + submodules: recursive 168 + - name: Install cargo-dist 169 + shell: bash 170 + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" 171 + # Get all the local artifacts for the global tasks to use (for e.g. checksums) 172 + - name: Fetch local artifacts 173 + uses: actions/download-artifact@v4 174 + with: 175 + pattern: artifacts-* 176 + path: target/distrib/ 177 + merge-multiple: true 178 + - id: cargo-dist 179 + shell: bash 180 + run: | 181 + cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json 182 + echo "cargo dist ran successfully" 183 + 184 + # Parse out what we just built and upload it to scratch storage 185 + echo "paths<<EOF" >> "$GITHUB_OUTPUT" 186 + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" 187 + echo "EOF" >> "$GITHUB_OUTPUT" 188 + 189 + cp dist-manifest.json "$BUILD_MANIFEST_NAME" 190 + - name: "Upload artifacts" 191 + uses: actions/upload-artifact@v4 192 + with: 193 + name: artifacts-build-global 194 + path: | 195 + ${{ steps.cargo-dist.outputs.paths }} 196 + ${{ env.BUILD_MANIFEST_NAME }} 197 + # Determines if we should publish/announce 198 + host: 199 + needs: 200 + - plan 201 + - build-local-artifacts 202 + - build-global-artifacts 203 + # Only run if we're "publishing", and only if local and global didn't fail (skipped is fine) 204 + if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} 205 + env: 206 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 207 + runs-on: "ubuntu-20.04" 208 + outputs: 209 + val: ${{ steps.host.outputs.manifest }} 210 + steps: 211 + - uses: actions/checkout@v4 212 + with: 213 + submodules: recursive 214 + - name: Install cargo-dist 215 + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" 216 + # Fetch artifacts from scratch-storage 217 + - name: Fetch artifacts 218 + uses: actions/download-artifact@v4 219 + with: 220 + pattern: artifacts-* 221 + path: target/distrib/ 222 + merge-multiple: true 223 + # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce" 224 + - id: host 225 + shell: bash 226 + run: | 227 + cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json 228 + echo "artifacts uploaded and released successfully" 229 + cat dist-manifest.json 230 + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" 231 + - name: "Upload dist-manifest.json" 232 + uses: actions/upload-artifact@v4 233 + with: 234 + # Overwrite the previous copy 235 + name: artifacts-dist-manifest 236 + path: dist-manifest.json 237 + 238 + # Create a GitHub Release while uploading all files to it 239 + announce: 240 + needs: 241 + - plan 242 + - host 243 + # use "always() && ..." to allow us to wait for all publish jobs while 244 + # still allowing individual publish jobs to skip themselves (for prereleases). 245 + # "host" however must run to completion, no skipping allowed! 246 + if: ${{ always() && needs.host.result == 'success' }} 247 + runs-on: "ubuntu-20.04" 248 + env: 249 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 250 + steps: 251 + - uses: actions/checkout@v4 252 + with: 253 + submodules: recursive 254 + - name: "Download GitHub Artifacts" 255 + uses: actions/download-artifact@v4 256 + with: 257 + pattern: artifacts-* 258 + path: artifacts 259 + merge-multiple: true 260 + - name: Cleanup 261 + run: | 262 + # Remove the granular manifests 263 + rm -f artifacts/*-dist-manifest.json 264 + - name: Create GitHub Release 265 + uses: ncipollo/release-action@v1 266 + with: 267 + tag: ${{ needs.plan.outputs.tag }} 268 + name: ${{ fromJson(needs.host.outputs.val).announcement_title }} 269 + body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }} 270 + prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }} 271 + artifacts: "artifacts/*"
+21 -1
Cargo.toml
··· 5 5 license = "MIT OR Apache-2.0" 6 6 repository = "https://github.com/urschrei/cvmcount" 7 7 8 - version = "0.1.1" 8 + version = "0.1.2" 9 9 edition = "2021" 10 10 11 11 [dependencies] ··· 30 30 [profile.bench] 31 31 lto = true 32 32 codegen-units = 1 33 + 34 + # The profile that 'cargo dist' will build with 35 + [profile.dist] 36 + inherits = "release" 37 + lto = "thin" 38 + 39 + # Config for 'cargo dist' 40 + [workspace.metadata.dist] 41 + # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) 42 + cargo-dist-version = "0.13.3" 43 + # CI backends to support 44 + ci = ["github"] 45 + # The installers to generate for each app 46 + installers = ["shell"] 47 + # Target platforms to build apps for (Rust target-triple syntax) 48 + targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] 49 + # Publish jobs to run in CI 50 + pr-run-mode = "plan" 51 + # Whether to install an updater program 52 + install-updater = false