Skip to content

Commit 0fdffaa

Browse files
committed
feat: handle day25 special case
1 parent 603fe40 commit 0fdffaa

6 files changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/trigger-day-scheduling.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ jobs:
7373
DAY_NUMBER: ${{ inputs.day }}
7474
RUSTFLAGS: "-C target-cpu=native"
7575
run: |
76-
if ! cargo build --test test_build ; then
76+
if [ "${{ inputs.day }}" -eq 25 ]; then
77+
BUILD_ARGS="--features day_25"
78+
else
79+
BUILD_ARGS=""
80+
fi
81+
if ! cargo build --test test_build $BUILD_ARGS; then
7782
echo "::warning::The day ${{ inputs.day }} module is missing or malformed. Skipping the run."
7883
echo "valid=false" >> $GITHUB_OUTPUT
7984
else

rust-runner/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
name = "rust-runner"
33
version = "0.1.0"
44
edition = "2021"
5+
build = "build.rs"
6+
7+
[features]
8+
day_25 = []
59

610
[dependencies]
711
paste = "1.0.0"

rust-runner/bench_part2.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ use rust_runner::{check_result, Output};
33
use std::hint::black_box;
44

55
paste::paste! {
6+
#[cfg(not(day_25))]
67
use solution::[<day env!("DAY_NUMBER")>]::{part2};
78
}
89

10+
#[cfg(not(day_25))]
911
fn bench_part2(c: &mut Criterion) {
1012
let mut g = c.benchmark_group(concat!("day", env!("DAY_NUMBER")));
1113
let input = include_str!("./input.txt");
@@ -19,5 +21,12 @@ fn bench_part2(c: &mut Criterion) {
1921
check_result(output, expected, 2);
2022
}
2123

24+
#[cfg(day_25)]
25+
fn bench_part2(c: &mut Criterion) {
26+
let mut g = c.benchmark_group(concat!("day", env!("DAY_NUMBER")));
27+
g.bench_function("part2", |b| b.iter(|| {}));
28+
}
29+
30+
2231
criterion_group!(benches, bench_part2);
2332
criterion_main!(benches);

rust-runner/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::env;
2+
3+
fn main() {
4+
if let Ok(day_number) = env::var("DAY_NUMBER") {
5+
if day_number == "25" {
6+
println!("cargo:rustc-cfg=day_25");
7+
}
8+
}
9+
}

rust-runner/rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"

rust-runner/test_build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
use rust_runner::check_result;
33

44
paste::paste! {
5+
#[cfg(not(day_25))]
56
use solution::[<day env!("DAY_NUMBER")>]::{part1, part2};
7+
8+
#[cfg(day_25)]
9+
use solution::[<day env!("DAY_NUMBER")>]::part1;
610
}
711

812
#[test]
@@ -13,6 +17,7 @@ fn test_build_part_1() {
1317
check_result(output, expected, 1);
1418
}
1519

20+
#[cfg(not(day_25))]
1621
#[test]
1722
fn test_build_part_2() {
1823
let input = "PLACEHOLDER";

0 commit comments

Comments
 (0)