Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit tests and Github work flows to run tests and lints #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 35 additions & 48 deletions .github/workflows/check-and-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache dependencies
uses: actions/cache@v3
env:
cache-name: cache-dependencies
cache-name: cache-check
with:
path: |
~/.cargo/.crates.toml
Expand All @@ -30,52 +25,44 @@ jobs:
~/.cargo/registry/cache
# target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: check
- name: cargo check
run: cargo check

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Install rustfmt
run: rustup component add rustfmt
- name: Run Rustfmt
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- name: Cache dependencies
uses: actions/cache@v3
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
# target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- uses: actions-rs/clippy-check@v1
continue-on-error: true # currently Clippy would fail. TODO fix warnings.
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
name: Clippy Output
# TODO clippy action is deprecated. Perhaps use https://github.com/actions-rs/clippy-check but it require more work
Mart-Bogdan marked this conversation as resolved.
Show resolved Hide resolved
# clippy:
# name: Clippy
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@stable
# with:
# components: clippy
# - name: Cache dependencies
# uses: actions/cache@v3
# env:
# cache-name: cache-dependencies
# with:
# path: |
# ~/.cargo/.crates.toml
# ~/.cargo/.crates2.json
# ~/.cargo/bin
# ~/.cargo/registry/index
# ~/.cargo/registry/cache
## target
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
# - uses: actions-rs/clippy-check@v1
# continue-on-error: true # currently Clippy would fail. TODO fix warnings.
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# args: --all-features
# name: Clippy Output
15 changes: 9 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-${{ matrix.arch }}
override: true
- name: Install toolchain
run: rustup install stable-${{ matrix.arch }} --profile minimal --no-self-update
# needed for windows test, as we are using multiple architectures here
- name: Switch toolchain
run: rustup default stable-${{ matrix.arch }}
- name: Cache dependencies
uses: actions/cache@v3
env:
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Install cargo-suity
run: cargo install cargo-suity
- name: Run tests
run: cargo suity
run: cargo suity
- name: Upload raw Unit Test results
if: always()
uses: actions/upload-artifact@v3
Expand All @@ -64,6 +64,9 @@ jobs:
path: artifacts

- name: Publish Unit Test Results
# TODO this won't work for PRs from contributors,
Mart-Bogdan marked this conversation as resolved.
Show resolved Hide resolved
# see: https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#support-fork-repositories-and-dependabot-branches
# and https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: "artifacts/**/*.xml"
Expand Down