-
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (109 loc) · 3.37 KB
/
rust.yml
File metadata and controls
115 lines (109 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Rust
on:
push:
branches: [main]
paths:
- crates/**/*.rs
- crates/**/Cargo.toml
- .github/workflows/rust.yml
tags:
- 'rf24-rs/*'
- 'rf24ble-rs/*'
# - 'rf24network-rs/*'
# - 'rf24mesh-rs/*'
pull_request:
branches: [main]
paths:
- crates/**/*.rs
- crates/**/Cargo.toml
- .github/workflows/rust.yml
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
permissions: {}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Rust
run: rustup update --no-self-update
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@0b24824336e2b3800b0f89d9e08b2c08bfa3dcdd # v1.17.9
- name: Install cargo-llvm-cov, cargo-nextest, and nur
env:
GITHUB_TOKEN: ${{ github.token }}
run: cargo binstall -y cargo-nextest cargo-llvm-cov nur
- name: Cache deps
uses: actions/cache@v5 # zizmor: ignore[cache-poisoning]
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-crates-${{ hashFiles('crates/*/src/**', 'crates/**/Cargo.toml') }}
- run: rustup component add llvm-tools-preview
# this enables a tool (for default toolchain) needed to measure code coverage.
- name: Run tests
run: nur test --profile ci
- name: Generate coverage reports
run: nur test lcov
- name: Upload coverage as artifact
uses: actions/upload-artifact@v7
with:
path: lcov.info
name: lcov.info
coverage:
needs: test
runs-on: ubuntu-latest
environment:
name: test-coverage
url: https://app.codecov.io/gh/nRF24/rf24-rs
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Download coverage artifact
uses: actions/download-artifact@v8
with:
name: lcov.info
- uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
if: github.repository == 'nRF24/rf24-rs'
id: codecov
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
publish:
name: Publish
runs-on: ubuntu-latest
if: startswith(github.ref, 'refs/tags/')
permissions:
# needed for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup nushell
uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23
with:
version: ${{ vars.NU_SHELL_VERSION || '*' }}
- name: Get pkg from tag
id: pkg
shell: nu {0}
run: |-
let tag = $env.GITHUB_REF_NAME
let pkg = $tag | parse "{name}/{version}" | first
$"name=($pkg | get name)\n" | save --append $env.GITHUB_OUTPUT
- name: Install Rust
run: rustup update stable --no-self-update
- name: Establish provenance
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
id: auth
- run: cargo publish -p ${PKG_NAME}
env:
PKG_NAME: ${{ steps.pkg.outputs.name }}
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}