From ae450e2c9fcbbf919132a5080a267acd3cbb8885 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Tue, 2 Jul 2024 14:08:43 +0200 Subject: [PATCH] Add initial structure --- .github/ISSUE_TEMPLATE/bug_report.md | 39 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 25 +++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 0 .github/labeler.yml | 22 +++++++++++++ .github/workflows/audit.yml | 26 +++++++++++++++ .github/workflows/label.yml | 16 ++++++++++ .github/workflows/style.yml | 23 +++++++++++++ .github/workflows/test.yml | 20 ++++++++++++ .gitignore | 5 +++ .pre-commit-config.yaml | 14 ++++++++ .pre-commit-hooks/clippy.sh | 9 ++++++ .pre-commit-hooks/rustfmt.sh | 10 ++++++ CODEOWNERS | 4 +++ isotomachine/Cargo.toml | 6 ++++ isotomachine/src/lib.rs | 14 ++++++++ isototest/Cargo.toml | 6 ++++ isototest/src/lib.rs | 14 ++++++++ 17 files changed, 253 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/label.yml create mode 100644 .github/workflows/style.yml create mode 100644 .github/workflows/test.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .pre-commit-hooks/clippy.sh create mode 100644 .pre-commit-hooks/rustfmt.sh create mode 100644 CODEOWNERS create mode 100644 isotomachine/Cargo.toml create mode 100644 isotomachine/src/lib.rs create mode 100644 isototest/Cargo.toml create mode 100644 isototest/src/lib.rs diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..81be861 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Found an issue? Please let us know! +title: "[BUG:]" +labels: '' +assignees: '' + +--- + +# Found an issue? Please let us know! + + + +### Please tick the applicable box(es) regarding the kind of bug you found: + + + +- [ ] Broken feature +- [ ] Wrong documentation +- [ ] Broken dependency + +### Steps to reproduce + + + +### Additional context + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..59cb765 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: Feature Request +about: You would like us to add something? Add it here! +title: "[FR:]" +labels: '' +assignees: '' + +--- +# You would like to suggest a new feature? + + + +*** +## Is your feature request related to a problem you had? Please describe: + + + +## Additional context + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..d306538 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,22 @@ +rust: +- **/**/*.rs + +dependencies: +- Cargo.toml +- **/Cargo.toml +- **/Cargo.lock +- Cargo.lock + +documentation: +- docs/** +- README.md +- LICENSE +- CODE_OF_CONDUCT.md +- CONTRIBUTING + +code-quality: +- .pre-commit-hooks/* +- .pre-commit-config.yaml + +maintenance: +- .github/* diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..535afd1 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,26 @@ +name: Dependency Vulnerability Audit + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 0 * * 0' + +jobs: + vulnerability_audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + use-cross: true + command: audit + args: --color always diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 0000000..0728f27 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,16 @@ +name: Labeler +on: [pull_request_target] + +jobs: + label: + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000..bfc9e49 --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,23 @@ +name: Style checking + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + rustfmt: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run cargo fmt + run: cargo fmt -- --check + + - name: Run cargo clippy + run: cargo clippy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3e71135 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Execute Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + cargo-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run Cargo test + run: cargo test --verbose diff --git a/.gitignore b/.gitignore index 6985cf1..196e176 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,8 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + + +# Added by cargo + +/target diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a19d041 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: local + hooks: + - id: rustfmt + name: autofmt + entry: .pre-commit-hooks/rustfmt.sh + language: script + files: \.rs$ + + - id: clippy + name: clippy_linter + entry: .pre-commit-hooks/clippy.sh + language: script + files: \.rs$ diff --git a/.pre-commit-hooks/clippy.sh b/.pre-commit-hooks/clippy.sh new file mode 100644 index 0000000..ff485d4 --- /dev/null +++ b/.pre-commit-hooks/clippy.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Run cargo clippy mainly for dead code analysis. + +cargo clippy -- --Dwarnings 2> /dev/null +clippy_exit_code=$? +if [ $clippy_exit_code != 0 ]; then + echo -e "\e[31mYour code seems to contain style violations! Run cargo clippy before committing!\e[0m" ; exit 1 +fi diff --git a/.pre-commit-hooks/rustfmt.sh b/.pre-commit-hooks/rustfmt.sh new file mode 100644 index 0000000..9ef64b8 --- /dev/null +++ b/.pre-commit-hooks/rustfmt.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Run rustfmt on all staged files to check for formatting errors. + +STAGED=$(git diff --name-only --cached | grep '.*\.rs') +if ! [ "$STAGED" = '' ]; then + rustfmt --check "$STAGED" || { + echo -e "\e[31mYour code is not formatted correctly! Please run rustfmt on all staged files before committing!\e[0m" ; exit 1 + } +fi diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..414f6c3 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,4 @@ +# This file will automatically ping all mentioned persons or teams +# when a PR changes files at the specified locations. + +* @ByteOtter diff --git a/isotomachine/Cargo.toml b/isotomachine/Cargo.toml new file mode 100644 index 0000000..563ec67 --- /dev/null +++ b/isotomachine/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "isotomachine" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/isotomachine/src/lib.rs b/isotomachine/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/isotomachine/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/isototest/Cargo.toml b/isototest/Cargo.toml new file mode 100644 index 0000000..219b0ba --- /dev/null +++ b/isototest/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "isototest" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/isototest/src/lib.rs b/isototest/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/isototest/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}