From b9478fbb6bcf3681c47db7564fee8221f1b8d2c3 Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Wed, 2 Dec 2026 13:30:00 -0700 Subject: [PATCH] add workflow for all years --- .github/workflows/test-2024.yaml | 70 -------------------- .github/workflows/test.yaml | 106 +++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/test-2024.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test-2024.yaml b/.github/workflows/test-2024.yaml deleted file mode 100644 index 6a046ed..0000000 --- a/.github/workflows/test-2024.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: test-2024 - -on: - push: - branches: [ main ] - paths: - - '2024/**' - - '.github/workflows/test-2024.yaml' - -env: - CARGO_TERM_COLOR: always - -defaults: - run: - working-directory: 2024 - -jobs: - tests: - name: AoC 2024 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: setup toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - cache: true - cache-workspaces: 2024 - components: clippy, rustfmt - toolchain: stable - rustflags: "" - - - name: install cargo-aoc - run: cargo install --locked cargo-aoc - - - name: get date - id: date - run: | - echo date=$(date +%Y%m%d) > $GITHUB_OUTPUT - - - name: Get cached inputs - id: inputs - uses: actions/cache@v4 - with: - path: 2024/input - key: ${{ steps.date.outputs.date }} - - - name: Get inputs from source - if: steps.inputs.outputs.cache-hit != 'true' - run: | - cargo aoc credentials ${{ secrets.AOC_SESSION }} - for i in $(seq 1 25); do - dayfmt=$(printf %02d $i) - if [ ${{ steps.date.outputs.date }} -ge 202412${dayfmt} ]; then - cargo aoc input --year 2024 --day $i - fi - done - - - name: cargo test - run: cargo test --lib - - - name: rustfmt - run: cargo fmt --all -- --check - - - name: clippy - run: cargo clippy --lib --tests -- -D warnings - if: always() - - - name: full run - run: cargo run --release - if: always() diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..10aec92 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,106 @@ +name: test + +on: + push: + branches: [ main ] + paths: + - '2022/**' + - '2024/**' + - '2025/**' + - '2026/**' + - '.github/workflows/test.yaml' + - 'rustfmt.toml' + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + CARGO_AOC_VERSION: 0.3.8 + +jobs: + tests: + name: AoC ${{ matrix.year }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + year: [2022, 2024, 2025, 2026] + include: + - year: 2024 + clippy_args: -D warnings + defaults: + run: + working-directory: ${{ matrix.year }} + steps: + - uses: actions/checkout@v4 + + - name: get date + id: date + # AoC unlocks puzzles at 00:00 EST (05:00 UTC), so shift the date back 5 hours + run: | + echo "date=$(date -u -d '-5 hours' +%Y%m%d)" >> "$GITHUB_OUTPUT" + echo "week=$(date -u +%G-W%V)" >> "$GITHUB_OUTPUT" + + - name: cache rustup toolchains + uses: actions/cache@v4 + with: + path: ~/.rustup + key: rustup-${{ runner.os }}-${{ runner.arch }}-${{ steps.date.outputs.week }} + + - name: setup toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + # caches the cargo registry and the year's target dir + cache: true + cache-workspaces: ${{ matrix.year }} + components: clippy, rustfmt + toolchain: stable + rustflags: "" + + - name: cache cargo-aoc + id: cargo-aoc + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-aoc + key: cargo-aoc-${{ runner.os }}-${{ runner.arch }}-${{ env.CARGO_AOC_VERSION }} + + - name: install cargo-aoc + if: steps.cargo-aoc.outputs.cache-hit != 'true' + run: cargo install --locked cargo-aoc --version "$CARGO_AOC_VERSION" + + - name: Get cached inputs + id: inputs + uses: actions/cache@v4 + with: + path: ${{ matrix.year }}/input + key: inputs-${{ matrix.year }}-${{ steps.date.outputs.date }} + restore-keys: inputs-${{ matrix.year }}- + + - name: Get inputs from source + if: steps.inputs.outputs.cache-hit != 'true' + env: + AOC_SESSION: ${{ secrets.AOC_SESSION }} + AOC_DATE: ${{ steps.date.outputs.date }} + run: | + year=${{ matrix.year }} + max_day=25 + if [ "$year" -ge 2025 ]; then max_day=12; fi + cargo aoc credentials "$AOC_SESSION" + for i in $(seq 1 "$max_day"); do + if [ "$AOC_DATE" -ge "$(printf '%s12%02d' "$year" "$i")" ]; then + cargo aoc input --year "$year" --day "$i" + fi + done + + - name: cargo test + run: cargo test --lib + + - name: rustfmt + run: cargo fmt --all -- --check + + - name: clippy + run: cargo clippy --lib --tests -- ${{ matrix.clippy_args }} + if: always() + + - name: full run + run: cargo run --release + if: always()