Rust 1.81.0 #303
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
test-rust: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: [stable, nightly] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.rust }} | |
- uses: Homebrew/actions/setup-homebrew@master | |
- name: Install protobuf | |
run: brew install protobuf | |
- name: Test and check (stable) | |
run: | | |
make COUNT_ALLOCATIONS=1 check | |
if: matrix.rust == 'stable' | |
- name: Test and check (nightly) | |
run: | | |
rustup component add clippy rustfmt --toolchain nightly | |
make NIGHTLY=1 check | |
make check-simd | |
if: matrix.rust == 'nightly' | |
continue-on-error: true | |
test-webgpu: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: install swiftshader | |
shell: bash | |
run: | | |
set -e | |
mkdir -p swiftshader | |
curl -LsSf https://github.com/gfx-rs/ci-build/releases/latest/download/swiftshader-linux-x86_64.tar.xz | tar -xf - -C swiftshader | |
echo "VK_ICD_FILENAMES=$PWD/swiftshader/vk_swiftshader_icd.json" >> "$GITHUB_ENV" | |
- name: install llvmpipe, vulkan sdk | |
shell: bash | |
run: | | |
set -e | |
sudo apt-get update -y -qq | |
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - | |
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list | |
sudo apt-get update | |
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev vulkan-sdk | |
- run: cargo test --features webgpu-compute | |
working-directory: crates/core | |
test-rust-wasi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-wasi | |
- run: rustc --version | |
- uses: Homebrew/actions/setup-homebrew@master | |
- run: brew install wasmtime | |
- run: cargo install cargo-wasi | |
- run: cargo wasi test -- --nocapture | |
working-directory: crates/core | |
test-c-and-cxx-bindings: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- if: ${{ matrix.os == 'ubuntu-latest' }} | |
uses: Homebrew/actions/setup-homebrew@master | |
- if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: sudo apt-get update && sudo apt-get -y install libc6-dbg && brew install valgrind | |
- run: make test-c-and-cxx-bindings | |
test-python: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.x'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Test with Python ${{ matrix.python-version }} | |
run: make test-python | |
test-wasm: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [ '18.x', 'latest' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- uses: Homebrew/actions/setup-homebrew@master | |
- name: Install wasm-opt | |
run: brew update && brew install binaryen | |
- run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | |
- run: cargo binstall --no-confirm wasm-bindgen-cli | |
- name: Test with Node ${{ matrix.node-version }} | |
run: make node-package | |
benchmark: | |
strategy: | |
matrix: | |
tested-commit: [new, old] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
if: matrix.tested-commit == 'new' || github.event_name != 'pull_request' | |
- name: Checkout base branch (${{ github.base_ref }} of pull request | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.base_ref }} | |
if: matrix.tested-commit == 'old' && github.event_name == 'pull_request' | |
- name: Checkout previous commit | |
run: git checkout HEAD~1 | |
if: matrix.tested-commit == 'old' && github.ref == 'refs/heads/main' | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Homebrew/actions/setup-homebrew@master | |
- run: brew install valgrind | |
- name: Run benchmark on ${{ matrix.tested-commit }} commit | |
run: ./run-iai-benchmark.py > ${{ matrix.tested-commit }}-baseline.json | |
working-directory: crates/core | |
- name: Upload benchmark | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.tested-commit }}-benchmark | |
path: crates/core/${{ matrix.tested-commit }}-baseline.json | |
compare-benchmarks: | |
needs: [benchmark] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download new benchmark | |
uses: actions/download-artifact@v4 | |
with: | |
name: new-benchmark | |
- name: Download old benchmark | |
uses: actions/download-artifact@v4 | |
with: | |
name: old-benchmark | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Format commit comment | |
id: get-comment-body | |
run: | | |
body=$(./.github/workflows/compare-iai.py old-baseline.json new-baseline.json) | |
delimiter="$(openssl rand -hex 8)" | |
{ echo "body<<$delimiter"; echo "$body"; echo "$delimiter"; } >> "$GITHUB_OUTPUT" | |
- name: Post commit comment | |
uses: peter-evans/commit-comment@v3 | |
with: | |
body: ${{ steps.get-comment-body.outputs.body }} | |
fuzz-afl: | |
runs-on: ubuntu-latest | |
# Allow failures as LLVM is not always available for installation: | |
continue-on-error: true | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- run: sudo apt-get install llvm | |
- name: Fuzz with AFL | |
run: AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 AFL_BENCH_UNTIL_CRASH=1 make fuzz-afl | |
- name: Upload crashes found by fuzzing | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./crates/fuzzing-afl/target/fuzz-findings/default/crashes | |
name: fuzzing-crashes-afl | |
fuzz-libfuzzer: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: nightly | |
- name: Fuzz with libfuzzer | |
run: timeout 1800s make fuzz-libfuzzer | |
continue-on-error: true | |
- name: Upload crashes found by fuzzing | |
uses: actions/upload-artifact@v4 | |
with: | |
path: crates/fuzzing-libfuzzer/fuzz/artifacts/fuzz_target/ | |
name: fuzzing-crashes-libfuzzer | |
fuzz-honggfuzz: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Install honggfuzz dependencies | |
run: sudo apt-get update && sudo apt-get -y install build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev | |
- name: Fuzz with honggfuzz | |
run: make fuzz-hfuzz | |
env: | |
# See https://github.com/google/honggfuzz/blob/master/docs/USAGE.md | |
HFUZZ_RUN_ARGS: "--timeout 10 --run_time 1800 --exit_upon_crash" | |
- name: Upload crashes found by fuzzing | |
uses: actions/upload-artifact@v4 | |
with: | |
path: crates/fuzzing-hfuzz/hfuzz_workspace/advent-of-code-fuzzing-hfuzz/*.fuzz | |
name: fuzzing-crashes-honggfuzz | |
coverage: | |
runs-on: ubuntu-latest | |
container: | |
image: xd009642/tarpaulin | |
options: --security-opt seccomp=unconfined | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Generate code coverage | |
run: cargo tarpaulin --verbose --timeout 720 --out xml | |
working-directory: crates/core | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v4 | |
with: | |
directory: crates/core | |
actionlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download actionlint | |
id: get_actionlint | |
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | |
- name: Check workflow files | |
run: ${{ steps.get_actionlint.outputs.executable }} -color | |
check-js: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
- name: Check js | |
run: npm install && npm run check | |
working-directory: crates/wasm | |
gist-mapping: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install requests | |
run: pip install requests | |
- name: Update gist mapping | |
run: ./update-gists.py && git add gist-mapping.json | |
working-directory: crates/wasm/site | |
env: | |
GIST_API_TOKEN: ${{ secrets.GIST_API_TOKEN }} | |
- name: Tests gists | |
run: ./validate-gists.py | |
working-directory: crates/wasm/site | |
- name: Commit and push gist mapping if updated | |
run: | | |
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then | |
git config --global user.name 'Gist Mapping Updater' | |
git config --global user.email '[email protected]' | |
git commit -m 'Update gist-mapping' | |
git push | |
fi | |
- name: Upload new gist-mapping.json | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gist-mapping | |
path: crates/wasm/site/gist-mapping.json | |
deploy-site: | |
if: github.ref == 'refs/heads/main' | |
needs: [benchmark, gist-mapping] | |
runs-on: ubuntu-latest | |
# Permissions necessary for ${{ secrets.GITHUB_TOKEN }} | |
# to allow cloudflare/pages-action to create deployment: | |
# https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/ | |
permissions: | |
contents: read | |
deployments: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: nightly | |
targets: wasm32-unknown-unknown | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- uses: Homebrew/actions/setup-homebrew@master | |
- name: Install wasm-opt | |
run: brew update && brew install binaryen | |
- run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | |
- run: cargo binstall --no-confirm wasm-bindgen-cli | |
- name: Download new gist-mapping.json | |
uses: actions/download-artifact@v4 | |
with: | |
name: gist-mapping | |
path: crates/wasm/site | |
- name: Download new benchmark | |
uses: actions/download-artifact@v4 | |
with: | |
name: new-benchmark | |
path: crates/wasm/site/benchmark | |
- name: Setup site to deploy | |
run: make deploy-site | |
- name: Deploy site to cloudflare | |
uses: cloudflare/pages-action@1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_PAGES_EDIT_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: aoc-fornwall-net | |
directory: crates/wasm/aoc.fornwall.net | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install the Netlify CLI | |
run: npm install netlify-cli -g | |
- name: Deploy to Netlify | |
run: make netlify | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_API_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
deploy-cloudflare-worker: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- uses: Homebrew/actions/setup-homebrew@master | |
- name: Install wasm-opt | |
run: brew update && brew install binaryen | |
- name: Deploy to Cloudflare | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: c494646a87f38a82ce35ea24edaada52 | |
working-directory: crates/worker | |
run: npx wrangler publish | |
build-and-deploy-http-server: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- run: cargo install cross | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Build and deploy docker image | |
working-directory: crates/http-server | |
env: | |
DOCKER_IMAGE_NAME: fredrikfornwall/advent-of-code-http-server | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
FLY_PROJECT_PATH: crates/grpc-server | |
run: | | |
cross build --release --target x86_64-unknown-linux-musl | |
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code-server | |
IMAGE_WITH_VERSION=${DOCKER_IMAGE_NAME}:${GITHUB_SHA} | |
mkdir -p target/linux/amd64 | |
cp ../../target/x86_64-unknown-linux-musl/release/advent-of-code-server target/linux/amd64/ | |
docker buildx build --tag "${IMAGE_WITH_VERSION}" . | |
flyctl deploy --image "${IMAGE_WITH_VERSION}" | |
if: github.ref == 'refs/heads/main' | |
build-and-deploy-grpc-server: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- run: cargo install cross | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Build and deploy docker image | |
working-directory: crates/grpc-server | |
env: | |
DOCKER_IMAGE_NAME: fredrikfornwall/advent-of-code-grpc-server | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
FLY_PROJECT_PATH: crates/grpc-server | |
run: | | |
cross build --release --target x86_64-unknown-linux-musl | |
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code-grpc-server | |
IMAGE_WITH_VERSION=${DOCKER_IMAGE_NAME}:${GITHUB_SHA} | |
mkdir -p target/linux/amd64 | |
cp ../../target/x86_64-unknown-linux-musl/release/advent-of-code-grpc-server target/linux/amd64/ | |
docker buildx build --tag "${IMAGE_WITH_VERSION}" . | |
flyctl deploy --image "${IMAGE_WITH_VERSION}" | |
if: github.ref == 'refs/heads/main' |