Hyperfine #17
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: Hyperfine | |
on: | |
workflow_dispatch: | |
jobs: | |
get-inputs: | |
uses: ephemient/aoc2024/.github/workflows/get-inputs.yml@main | |
secrets: | |
SESSION: ${{ secrets.SESSION }} | |
haskell: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
ghc: [ '9.10', '9.12' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
- run: | | |
cabal configure --enable-tests --enable-benchmarks --with-compiler=ghc-${{ matrix.ghc }} --allow-newer=aeson-2.2.3.0:ghc-prim,aeson-2.2.3.0:template-haskell,binary-orphans-1.0.5:base,indexed-traversable-0.1.4:base,indexed-traversable-instances-0.1.2:base,integer-conversion-0.1.1:base,microstache-1.0.3:base,process-1.6.25.0:base,process-1.6.25.0:filepath,scientific-0.3.8.0:base,scientific-0.3.8.0:filepath,scientific-0.3.8.0:template-haskell,semialign-1.3.1:base,these-1.2.1:base,time-compat-1.9.7:base,uuid-types-1.0.6:template-haskell | |
cabal build all --dry-run | |
working-directory: hs | |
- uses: actions/cache/restore@v4 | |
id: cache | |
env: | |
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ env.key }}-plan-${{ hashFiles('hs/dist-newstyle/cache/plan.json') }} | |
restore-keys: ${{ env.key }}- | |
- run: cabal build all --only-dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
working-directory: hs | |
- uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.setup.outputs.cabal-store }} | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
- id: build | |
run: | | |
cabal build exe:aoc2024 | |
echo "exe=$(cabal list-bin aoc2024)" >> $GITHUB_OUTPUT | |
working-directory: hs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-hs-${{ matrix.ghc }} | |
path: ${{ steps.build.outputs.exe }} | |
kotlin: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- uses: gradle/actions/setup-gradle@v4 | |
- run: ./gradlew assemble distZip | |
working-directory: kt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-kt | |
path: kt/aoc2024-exe/build/distributions/*.zip | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-kexe | |
path: | | |
kt/aoc2024-exe/build/bin/*/debugExecutable/*.kexe | |
kt/aoc2024-exe/build/bin/*/releaseExecutable/*.kexe | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-wasmJs | |
path: kt/build/js/packages/aoc2024-aoc2024-exe-wasm-js/kotlin/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-wasmWasi | |
path: kt/aoc2024-exe/build/compileSync/wasmWasi/main/productionExecutable/optimized/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-js | |
path: kt/build/js/packages/aoc2024-aoc2024-exe/kotlin/* | |
graalvm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: 21 | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: gradle/actions/setup-gradle@v4 | |
- run: ./gradlew --no-configuration-cache nativeCompile | |
working-directory: kt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-graalvm | |
path: kt/graalvm/build/native/nativeCompile/* | |
python: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: snok/install-poetry@v1 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
cache: poetry | |
- run: poetry install --no-interaction | |
working-directory: py | |
- run: poetry build | |
working-directory: py | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-py | |
path: py/dist/* | |
rust: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache-workspaces: rs -> target | |
- run: cargo build --bins --all-features --release | |
working-directory: rs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: aoc2024-rs | |
path: rs/target/release/aoc2024 | |
hyperfine: | |
needs: [ get-inputs, haskell, kotlin, graalvm, python, rust ] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
day: | |
- 1 | |
- 2 | |
- 3 | |
- 4 | |
- 5 | |
- 6 | |
- 7 | |
- 8 | |
- 9 | |
- 10 | |
- 11 | |
- 12 | |
- 13 | |
- 14 | |
- 15 | |
- 16 | |
- 17 | |
- 18 | |
- 19 | |
- 20 | |
- 21 | |
- 22 | |
- 23 | |
- 24 | |
- 25 | |
- all | |
steps: | |
- name: sudo apt install hyperfine | |
run: | | |
wget https://github.com/sharkdp/hyperfine/releases/download/v1.19.0/hyperfine_1.19.0_amd64.deb | |
sudo apt install ./hyperfine_1.19.0_amd64.deb | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.0.0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
- uses: actions/download-artifact@v4 | |
- name: Set up binaries | |
run: | | |
unzip -d aoc2024-kt aoc2024-kt/aoc2024-exe.zip | |
chmod -v +x aoc2024-hs-9.10/aoc2024 aoc2024-hs-9.12/aoc2024 aoc2024-kt/aoc2024-exe/bin/aoc2024-exe aoc2024-kexe/*/*/*.kexe aoc2024-graalvm/aoc2024-native aoc2024-rs/aoc2024 | |
cd aoc2024-py | |
python -m venv . | |
. bin/activate | |
pip install *.whl | |
- name: Set input | |
run: echo "DAY=${{ matrix.day }}" >> $GITHUB_ENV | |
if: matrix.day != 'all' | |
- name: Run hyperfine | |
run: | | |
hyperfine --warmup 1 --shell none --sort command --export-markdown ${{ matrix.day }}.md \ | |
--command-name 'Haskell (GHC 9.10)' 'aoc2024-hs-9.10/aoc2024 ${{ env.DAY }}' \ | |
--command-name 'Haskell (GHC 9.12)' 'aoc2024-hs-9.12/aoc2024 ${{ env.DAY }}' \ | |
--command-name Kotlin/JVM 'aoc2024-kt/aoc2024-exe/bin/aoc2024-exe ${{ env.DAY }}' \ | |
--command-name Kotlin/JS 'node aoc2024-js/aoc2024-aoc2024-exe.js ${{ env.DAY }}' \ | |
--command-name Kotlin/Native 'aoc2024-kexe/linuxX64/releaseExecutable/aoc2024-exe.kexe ${{ env.DAY }}' \ | |
--command-name Kotlin/wasmJs 'node aoc2024-wasmJs/aoc2024-aoc2024-exe-wasm-js.mjs ${{ env.DAY }}' \ | |
--command-name Kotlin/wasmWasi 'node aoc2024-wasmWasi/aoc2024-aoc2024-exe-wasm-wasi.mjs ${{ env.DAY }}' \ | |
--command-name Kotlin/GraalVM 'aoc2024-graalvm/aoc2024-native ${{ env.DAY }}' \ | |
--command-name Python 'aoc2024-py/bin/aoc2024 ${{ env.DAY }}' \ | |
--command-name Rust 'aoc2024-rs/aoc2024 ${{ env.DAY }}' | |
env: | |
AOC2024_DATADIR: inputs | |
TRACE: 0 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: hyperfine-${{ matrix.day }} | |
path: ${{ matrix.day }}.md | |
docs: | |
needs: [ hyperfine ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: gh-docs | |
- run: rm -rf hyperfine | |
- uses: actions/download-artifact@v4 | |
with: | |
path: hyperfine | |
pattern: hyperfine-* | |
merge-multiple: true | |
- run: | | |
git add hyperfine | |
git commit -m 'Hyperfine ${{ github.sha }}' | |
git push | |
env: | |
GIT_AUTHOR_NAME: github-actions[bot] | |
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | |
GIT_COMMITTER_NAME: github-actions[bot] | |
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com |