2021-05-30 20:03:53 +00:00
|
|
|
name: Rust
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ main ]
|
|
|
|
pull_request:
|
2021-08-31 18:00:12 +00:00
|
|
|
types: [opened, reopened, synchronize]
|
2021-05-30 20:03:53 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
|
|
|
jobs:
|
2021-11-29 08:37:47 +00:00
|
|
|
pre_job:
|
2022-03-31 13:51:12 +00:00
|
|
|
continue-on-error: true
|
2021-11-29 08:37:47 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# Map a step output to a job output
|
|
|
|
outputs:
|
|
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
|
|
steps:
|
|
|
|
- id: skip_check
|
|
|
|
uses: fkirc/skip-duplicate-actions@master
|
|
|
|
with:
|
2022-04-25 15:38:13 +00:00
|
|
|
concurrent_skipping: 'outdated_runs'
|
2021-11-29 08:37:47 +00:00
|
|
|
skip_after_successful_duplicate: 'true'
|
2021-12-08 09:58:17 +00:00
|
|
|
paths_ignore: '["**/*.md", "**/docs/**", "example_configs/**", "*.sh"]'
|
|
|
|
do_not_skip: '["workflow_dispatch", "schedule"]'
|
2022-04-25 15:38:13 +00:00
|
|
|
cancel_others: true
|
|
|
|
|
2021-06-23 09:13:18 +00:00
|
|
|
test:
|
|
|
|
name: cargo test
|
2021-11-29 08:37:47 +00:00
|
|
|
needs: pre_job
|
|
|
|
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
2021-06-23 08:57:43 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-05-30 20:03:53 +00:00
|
|
|
|
2021-06-23 08:57:43 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
2023-03-27 07:14:26 +00:00
|
|
|
uses: actions/checkout@v3.5.0
|
2022-11-17 20:13:16 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
2021-06-23 08:57:43 +00:00
|
|
|
- name: Build
|
2021-06-23 09:13:18 +00:00
|
|
|
run: cargo build --verbose --workspace
|
2021-06-23 08:57:43 +00:00
|
|
|
- name: Run tests
|
2021-06-23 09:13:18 +00:00
|
|
|
run: cargo test --verbose --workspace
|
2021-08-26 19:46:00 +00:00
|
|
|
- name: Generate GraphQL schema
|
|
|
|
run: cargo run -- export_graphql_schema -o generated_schema.graphql
|
|
|
|
- name: Check schema
|
2021-09-01 08:01:08 +00:00
|
|
|
run: diff schema.graphql generated_schema.graphql || (echo "The schema file is out of date. Please run `./export_schema.sh`" && false)
|
2021-08-26 19:46:00 +00:00
|
|
|
|
2021-06-23 08:57:43 +00:00
|
|
|
|
|
|
|
clippy:
|
|
|
|
name: cargo clippy
|
2021-11-29 08:37:47 +00:00
|
|
|
needs: pre_job
|
|
|
|
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
2021-06-23 08:57:43 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
2023-03-27 07:14:26 +00:00
|
|
|
uses: actions/checkout@v3.5.0
|
2021-06-23 08:57:43 +00:00
|
|
|
|
2022-11-17 20:13:16 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
2021-10-22 12:15:49 +00:00
|
|
|
|
2021-06-23 09:13:18 +00:00
|
|
|
- name: Run cargo clippy
|
2021-06-23 08:57:43 +00:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: clippy
|
2021-06-23 09:13:18 +00:00
|
|
|
args: --tests --all -- -D warnings
|
2021-06-23 08:57:43 +00:00
|
|
|
|
|
|
|
format:
|
|
|
|
name: cargo fmt
|
2021-11-29 08:37:47 +00:00
|
|
|
needs: pre_job
|
|
|
|
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
2021-06-23 08:57:43 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
2023-03-27 07:14:26 +00:00
|
|
|
uses: actions/checkout@v3.5.0
|
2021-06-23 08:57:43 +00:00
|
|
|
|
2022-11-17 20:13:16 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
2021-10-22 12:15:49 +00:00
|
|
|
|
2021-06-23 09:13:18 +00:00
|
|
|
- name: Run cargo fmt
|
2021-06-23 08:57:43 +00:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
2021-10-22 12:15:49 +00:00
|
|
|
|
|
|
|
coverage:
|
|
|
|
name: Code coverage
|
2021-11-29 08:37:47 +00:00
|
|
|
needs: pre_job
|
2022-04-25 15:38:13 +00:00
|
|
|
if: ${{ needs.pre_job.outputs.should_skip != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
|
2021-10-22 12:15:49 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout sources
|
2023-03-27 07:14:26 +00:00
|
|
|
uses: actions/checkout@v3.5.0
|
2021-10-22 12:15:49 +00:00
|
|
|
|
|
|
|
- name: Install Rust
|
2022-04-15 18:00:33 +00:00
|
|
|
run: rustup toolchain install nightly --component llvm-tools-preview && rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu
|
2021-10-22 12:15:49 +00:00
|
|
|
|
2022-03-31 14:29:03 +00:00
|
|
|
- uses: taiki-e/install-action@cargo-llvm-cov
|
2021-10-22 12:15:49 +00:00
|
|
|
|
2022-11-17 20:13:16 +00:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
2021-10-22 12:15:49 +00:00
|
|
|
|
|
|
|
- name: Generate code coverage for unit test
|
|
|
|
run: cargo llvm-cov --workspace --no-report
|
|
|
|
- name: Aggregate reports
|
|
|
|
run: cargo llvm-cov --no-run --lcov --output-path lcov.info
|
|
|
|
- name: Upload coverage to Codecov
|
2022-04-05 20:31:21 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2021-10-22 12:15:49 +00:00
|
|
|
with:
|
|
|
|
files: lcov.info
|
|
|
|
fail_ci_if_error: true
|
2023-03-27 07:28:27 +00:00
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|