-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests and Github work flows to run tests and lints
- Loading branch information
1 parent
aafe068
commit 5412669
Showing
21 changed files
with
618 additions
and
4 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,81 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
name: Check and Lint | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
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 | ||
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/cargo@v1 | ||
with: | ||
command: 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 | ||
|
||
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 |
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,76 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
#name: Test with Code Coverage | ||
name: Unit Tests | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-20.04, windows-latest, macos-11] | ||
arch: [x86_64] | ||
include: | ||
# for windows also test 32-bit binaries, | ||
# to be sure that win-api integration is correct. | ||
- os: windows-latest | ||
arch: i686 | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable-${{ matrix.arch }} | ||
override: true | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-dependencies-test | ||
with: | ||
path: | | ||
~/.cargo/.crates.toml | ||
~/.cargo/.crates2.json | ||
~/.cargo/bin | ||
~/.cargo/registry/index | ||
~/.cargo/registry/cache | ||
# target | ||
key: ${{ runner.os }}-${{ matrix.arch }}-build-v2-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} | ||
- name: Install cargo-suity | ||
run: cargo install cargo-suity | ||
- name: Run tests | ||
run: cargo suity | ||
- name: Upload raw Unit Test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Unit Test Results (${{ matrix.os }}) | ||
path: ./test-results/* | ||
publish-test-results: | ||
name: "Publish Unit Tests Results" | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: always() | ||
|
||
steps: | ||
- name: Download Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v1 | ||
with: | ||
files: "artifacts/**/*.xml" | ||
|
||
# orginal example used code coverage and tests reports, but disable it for now | ||
# https://github.com/BamPeers/rust-ci-github-actions-workflow/blob/main/.github/workflows/test.yaml | ||
# https://dev.to/bampeers/rust-ci-with-github-actions-1ne9 | ||
# if we would use code coverage, not sure how it should work on cross platform tests, | ||
# perhaps need to gather coverage files across whole matrix into single post-processing step. | ||
# and test results as XML requires nightly. |
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
Oops, something went wrong.