Merge pull request #17 from van-sprundel/add-arrayvec-usage #18
This file contains hidden or 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: | |
| pull_request: | |
| push: | |
| branches: [master] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| clippy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - run: cargo clippy --all-targets --locked | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - run: cargo test --all-features | |
| benchmark: | |
| name: Run benchmarks (instruction counts) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| # Install valgrind and iai-callgrind-runner | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y valgrind | |
| cargo install iai-callgrind-runner | |
| - name: Run benchmarks on PR branch | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| cargo bench --bench generate_moves_iai 2>&1 | tee benchmark-pr.txt | |
| - name: Run benchmarks on master | |
| if: github.event_name == 'push' | |
| run: cargo bench --bench generate_moves_iai | |
| - name: Checkout base branch | |
| if: github.event_name == 'pull_request' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.base_ref }} | |
| clean: false | |
| - name: Run benchmarks on base branch | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| cargo bench --bench generate_moves_iai 2>&1 | tee benchmark-base.txt | |
| - name: Compare benchmarks | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "## 📊 Benchmark Results (Instruction Counts)" > benchmark_results.md | |
| echo "" >> benchmark_results.md | |
| echo "Comparing \`${{ github.head_ref }}\` (PR) vs \`${{ github.base_ref }}\` (base)" >> benchmark_results.md | |
| echo "" >> benchmark_results.md | |
| echo "**Using iai-callgrind:** Counts instructions via Cachegrind - deterministic and not affected by CI noise." >> benchmark_results.md | |
| echo "" >> benchmark_results.md | |
| echo '```' >> benchmark_results.md | |
| # Extract and format benchmark results | |
| if [ -f benchmark-base.txt ]; then | |
| # Remove ANSI color codes and extract relevant lines | |
| sed 's/\x1b\[[0-9;]*m//g' benchmark-base.txt | \ | |
| grep -E "(generate_moves_iai::|Instructions:)" | \ | |
| awk '/generate_moves_iai::/ {name=$1; gsub(/generate_moves_iai::/, "", name); gsub(/generate_/, "", name); gsub(/_/, " ", name)} | |
| /Instructions:/ {print name": "$2" ("$3")"}' >> benchmark_results.md | |
| else | |
| echo "See job logs for detailed results" >> benchmark_results.md | |
| fi | |
| echo '```' >> benchmark_results.md | |
| echo "" >> benchmark_results.md | |
| echo "<sub>📏 Instruction counts via Cachegrind. Lower is better. Results are deterministic.</sub>" >> benchmark_results.md | |
| - name: Comment PR with results | |
| if: github.event_name == 'pull_request' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| filePath: benchmark_results.md | |
| comment_tag: benchmark_results |