feat: Add setup for Rust environment and implement test workflows
This commit is contained in:
140
.github/workflows/test.yaml
vendored
Normal file
140
.github/workflows/test.yaml
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
# this workflow runs tests on pull request and push events targeting master branch
|
||||
# it also verify the generated code is up to date and valid
|
||||
|
||||
name: Test
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test-crates:
|
||||
needs: frontend-build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Rust, checkout and restore caches
|
||||
uses: ./.github/actions/setup-rust
|
||||
|
||||
- name: Restore frontend build cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: apps/nxmesh-frontend/build
|
||||
key: frontend-build-${{ runner.os }}-run-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
frontend-build-${{ runner.os }}-
|
||||
|
||||
- name: install protobuf compiler
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y protobuf-compiler
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
|
||||
lint-crates:
|
||||
needs: frontend-build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Rust, checkout and restore caches
|
||||
uses: ./.github/actions/setup-rust
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: Restore frontend build cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: apps/nxmesh-frontend/build
|
||||
key: frontend-build-${{ runner.os }}-run-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
frontend-build-${{ runner.os }}-
|
||||
|
||||
- name: install protobuf compiler
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y protobuf-compiler
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-features
|
||||
|
||||
- name: Check code formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
lint-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
name: Install Bun
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun install
|
||||
|
||||
- name: Run frontend linter
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun run lint
|
||||
|
||||
test-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
name: Install Bun
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun install
|
||||
|
||||
- name: Run frontend tests
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun run test
|
||||
|
||||
frontend-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
name: Install Bun
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun install
|
||||
|
||||
- name: Build frontend
|
||||
run: |
|
||||
cd apps/nxmesh-frontend
|
||||
bun run build
|
||||
|
||||
- name: Cache frontend build
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: apps/nxmesh-frontend/build
|
||||
key: frontend-build-${{ runner.os }}-run-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
frontend-build-${{ runner.os }}-
|
||||
Reference in New Issue
Block a user