This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
generated from yamgent/advent-of-code-xxxx-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e1b981a
Showing
10 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Tests and Lints | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.INPUT_REPO_TOKEN }} | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
- name: Build & run tests | ||
run: cargo test | ||
all-doc-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.INPUT_REPO_TOKEN }} | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ubuntu-latest-cargo-all-doc-tests-${{ hashFiles('**/Cargo.toml') }} | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
- name: Run doc tests with all features (this also compiles README examples) | ||
run: cargo test --doc --all-features | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
token: ${{ secrets.INPUT_REPO_TOKEN }} | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ubuntu-latest-cargo-lint-${{ hashFiles('**/Cargo.toml') }} | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
components: rustfmt, clippy | ||
- name: Run clippy | ||
run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings | ||
- name: Check format | ||
run: cargo fmt --all -- --check |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
/.idea |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "actual_inputs"] | ||
path = actual_inputs | ||
url = [email protected]:yamgent/advent-of-code-inputs.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "aoc_xxxx" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# advent-of-code-xxxx-rust | ||
|
||
1. Clone template | ||
2. Replace all `xxxx` with current year (do not accidentally replace content inside `actual_inputs` folder!) | ||
3. Update the `src/bin/empty/main.rs` `include_str!()` macro to use the correct year. | ||
4. Add `INPUT_REPO_TOKEN` secret with access to `actual_inputs` folder so that CI can access the inputs | ||
* Just "Contents - Read-only" access for the input repo is sufficient |
Submodule actual_inputs
added at
70438f
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const ACTUAL_INPUT: &str = include_str!("../../../actual_inputs/2015/01/input.txt"); | ||
|
||
fn p1(input: &str) -> String { | ||
let _input = input.trim(); | ||
"".to_string() | ||
} | ||
|
||
fn p2(input: &str) -> String { | ||
let _input = input.trim(); | ||
"".to_string() | ||
} | ||
|
||
fn main() { | ||
println!("{}", p1(ACTUAL_INPUT)); | ||
println!("{}", p2(ACTUAL_INPUT)); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
const SAMPLE_INPUT: &str = r""; | ||
|
||
#[test] | ||
fn test_p1_sample() { | ||
assert_eq!(p1(SAMPLE_INPUT), ""); | ||
} | ||
|
||
#[test] | ||
#[ignore = "not yet implemented"] | ||
fn test_p1_actual() { | ||
assert_eq!(p1(ACTUAL_INPUT), ""); | ||
} | ||
|
||
#[test] | ||
fn test_p2_sample() { | ||
assert_eq!(p2(SAMPLE_INPUT), ""); | ||
} | ||
|
||
#[test] | ||
#[ignore = "not yet implemented"] | ||
fn test_p2_actual() { | ||
assert_eq!(p2(ACTUAL_INPUT), ""); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn add(left: u64, right: u64) -> u64 { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |