Skip to content

Commit

Permalink
Merge pull request #7 from ephemient/rs/day1
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient authored Dec 1, 2024
2 parents 0114701 + 2eb17fc commit 39a6283
Show file tree
Hide file tree
Showing 12 changed files with 956 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ kt/kotlin-js-store/yarn.lock

# generated by Poetry
py/poetry.lock linguist-generated

# generated by Cargo
rs/Cargo.lock linguist-generated
71 changes: 71 additions & 0 deletions .github/workflows/rs-bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Rust benchmarks

on:
workflow_dispatch:

permissions:
contents: write

jobs:
get-inputs:
uses: ephemient/aoc2024/.github/workflows/get-inputs.yml@main
secrets:
SESSION: ${{ secrets.SESSION }}

build:
needs: [ get-inputs ]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
ref: gh-docs
path: gh-docs
- uses: actions/download-artifact@v4
with:
name: inputs
path: inputs
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy,rustfmt
cache-workspaces: rs -> target
- run: cargo install cargo-criterion
working-directory: rs
- run: cargo criterion
env:
AOC2024_DATADIR: ${{ github.workspace }}/inputs
working-directory: rs
- run: rsync --archive --delete --verbose --whole-file target/criterion/reports/ ../gh-docs/criterion/
working-directory: rs
- name: Inline Criterion benchmark results
run: |
cat >>gh-docs/criterion/index.html <<'EOF'
<script>
document.querySelectorAll('ul ul li a[href]')
.forEach(a => {
let b = a.getAttribute('href');
b = b.substr(0, b.lastIndexOf('/') + 1);
fetch(a.href, {
mode: 'same-origin',
headers: {
'Accept': 'text/html'
}
})
.then(r => r.text())
.then(t => new DOMParser().parseFromString(t, 'text/html'))
.then(d => {
d.querySelectorAll('.explanation').forEach(e => e.remove());
d.querySelectorAll('[src]').forEach(e => e.setAttribute('src', `${b}${e.getAttribute('src')}`));
d.querySelectorAll('[href]').forEach(e => e.setAttribute('href', `${b}${e.getAttribute('href')}`));
a.insertAdjacentElement('afterend', d.querySelector('.body'));
d.querySelectorAll('style').forEach(e => document.head.append(e));
});
});
</script>
EOF
- uses: EndBug/add-and-commit@v9
with:
cwd: gh-docs
add: criterion
message: 'Rust Criterion ${{ github.sha }}'
50 changes: 50 additions & 0 deletions .github/workflows/rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Rust CI

on:
push:
branches: [ main ]
paths: [ rs/** ]
pull_request:
branches: [ main ]
paths: [ rs/** ]

workflow_dispatch:

jobs:
get-inputs:
uses: ephemient/aoc2024/.github/workflows/get-inputs.yml@main
secrets:
SESSION: ${{ secrets.SESSION }}

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy,rustfmt
cache-workspaces: rs -> target
- run: cargo fmt -- --check
working-directory: rs
- run: cargo clippy -- --deny warnings
working-directory: rs
- run: cargo test
working-directory: rs
- run: cargo build --all-features --all-targets --release
working-directory: rs
- uses: actions/upload-artifact@v4
with:
name: aoc2024-rs
path: rs/target/release/aoc2024

run:
needs: [ get-inputs, build ]
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v4
- run: chmod +x aoc2024-rs/aoc2024
- run: aoc2024-rs/aoc2024
env:
AOC2024_DATADIR: inputs
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

Development occurs in language-specific directories:

|[Haskell](hs) ![Haskell CI](https://github.com/ephemient/aoc2024/workflows/Haskell%20CI/badge.svg)|[Kotlin](kt) ![Kotlin CI](https://github.com/ephemient/aoc2024/workflows/Kotlin%20CI/badge.svg)|[Python](py) ![Python CI](https://github.com/ephemient/aoc2024/workflows/Python%20CI/badge.svg)|
|--:|--:|--:|
|[Day1.hs](hs/src/Day1.hs)|[Day1.kt](kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/Day1.kt)|[day1.py](py/aoc2024/day1.py)|
|[Haskell](hs) ![Haskell CI](https://github.com/ephemient/aoc2024/workflows/Haskell%20CI/badge.svg)|[Kotlin](kt) ![Kotlin CI](https://github.com/ephemient/aoc2024/workflows/Kotlin%20CI/badge.svg)|[Python](py) ![Python CI](https://github.com/ephemient/aoc2024/workflows/Python%20CI/badge.svg)|[Rust](rs) ![Rust CI](https://github.com/ephemient/aoc2024/workflows/Rust%20CI/badge.svg)|
|--:|--:|--:|--:|
|[Day1.hs](hs/src/Day1.hs)|[Day1.kt](kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/Day1.kt)|[day1.py](py/aoc2024/day1.py)|[day1.rs](rs/src/day1.rs)|
2 changes: 2 additions & 0 deletions rs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
**/*.rs.bk
Loading

0 comments on commit 39a6283

Please sign in to comment.