diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7dac880..6bdd8d6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,34 +2,64 @@ name: test on: push: - branches: [ main ] + branches: [main] env: CARGO_TERM_COLOR: always jobs: - tests: - name: AoC 2024 + setup: + name: Setup runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: setup toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - cache: true - components: clippy, rustfmt - toolchain: stable + - uses: actions/checkout@v3 + - name: setup toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: true + components: clippy, rustfmt + toolchain: stable - - name: fake inputs - run: | - mkdir -p input/2024/ - for i in $(seq 1 25); do touch input/2024/day${i}.txt; done + - name: install cargo-aoc + run: cargo install --locked cargo-aoc - - name: cargo test - run: cargo test --lib --all-features + - name: get date + id: date + run: | + echo date=$(date +%Y%m%d) > $GITHUB_OUTPUT - - name: rustfmt - run: cargo fmt --all -- --check + - name: Get cached inputs + id: inputs + uses: actions/cache@v4 + with: + path: input + key: ${{ steps.date.outputs.date }} - # - name: clippy - # run: cargo clippy --lib --all-features --tests -- -D warnings + - 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 + test: + runs-on: ubuntu-latest + name: Test and Lint + steps: + - name: cargo test + run: cargo test --lib --all-features + + - name: rustfmt + run: cargo fmt --all -- --check + + - name: clippy + run: cargo clippy --lib --all-features --tests -- -D warnings + run: + runs-on: ubuntu-latest + name: Full run + steps: + - name: full run + run: cargo run --release