Skip to content

Commit

Permalink
.github workflows with linting and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laruh committed Oct 6, 2024
1 parent 9b79ae3 commit f0efc7c
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/actions/cargo-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Set up cargo cache'
description: 'Sets up the cargo cache for the workflow'
runs:
using: 'composite'
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
60 changes: 60 additions & 0 deletions .github/workflows/fmt-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Format and Lint
on: [push]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
fmt-and-lint:
name: x86 Format and Lint Checks
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2023-06-01

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: fmt check
# Format checks aren't OS dependent.
if: matrix.os == 'ubuntu-latest'
run: cargo fmt --all -- --check --color always

- name: Clippy lint
run: cargo clippy --all-targets --all-features -- --D warnings

wasm-lint:
name: Wasm Lint Checks
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy
override: true
profile: minimal
toolchain: nightly-2023-06-01
target: wasm32-unknown-unknown

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Clippy lint
run: cargo clippy --target wasm32-unknown-unknown -- --D warnings
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test
on:
push:
branches-ignore:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
x86-64-unit-tests:
name: x86 Cargo unit tests
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2023-06-01

- name: Cargo cache
uses: ./.github/actions/cargo-cache

- name: Cargo test
run: cargo test --no-fail-fast
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target/

.vscode/
.vscode/

.idea

0 comments on commit f0efc7c

Please sign in to comment.