Repository navigation
167 lines (161 loc) · 5.35 KB
/
Copy pathrust.yml
File metadata and controls
167 lines (161 loc) · 5.35 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Shared CI for Veraison Rust projects: rustfmt, clippy, build & test and
# cargo-deny.
#
# Typical caller:
#
# name: ci
# on:
# push:
# branches: ["**"]
# pull_request:
# workflow_dispatch:
# permissions:
# contents: read
# concurrency:
# group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
# jobs:
# rust:
# uses: veraison/ci/.github/workflows/rust.yml@main
#
# Lints are configured in Cargo.toml ([lints] / [workspace.lints]), so that
# "cargo clippy" behaves the same locally and in CI.
name: rust
on:
workflow_call:
inputs:
jobs:
description: "Comma separated list of the jobs to run: lint, test, deny"
type: string
default: "lint,test,deny"
working-directory:
description: "Directory containing the Cargo workspace"
type: string
default: "."
toolchain:
description: "Rust toolchain used for all jobs"
type: string
default: "stable"
os:
description: "JSON list of runners to test on"
type: string
default: '["ubuntu-latest"]'
features:
description: "JSON list of cargo feature flags to build and test with"
type: string
default: '[""]'
setup:
description: "Shell commands run before the lint and test jobs (e.g. installing system packages)"
type: string
default: ""
timeout-minutes:
type: number
default: 30
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: lint
if: >-
contains(inputs.jobs, 'lint') &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
with:
toolchain: ${{ inputs.toolchain }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: ${{ inputs.working-directory }}
- name: Setup
if: inputs.setup != ''
env:
SETUP: ${{ inputs.setup }}
run: eval "${SETUP}"
- name: Formatting checks
run: cargo fmt --all -- --check
- name: Clippy checks
run: cargo clippy --all-targets
test:
name: test (${{ matrix.os }}${{ matrix.features != '' && format(', {0}', matrix.features) || '' }})
if: >-
contains(inputs.jobs, 'test') &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ inputs.timeout-minutes }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.os) }}
features: ${{ fromJSON(inputs.features) }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # master
with:
toolchain: ${{ inputs.toolchain }}
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: ${{ inputs.working-directory }}
key: ${{ matrix.features }}
- name: Setup
if: inputs.setup != ''
env:
SETUP: ${{ inputs.setup }}
run: eval "${SETUP}"
- name: Build
env:
FEATURES: ${{ matrix.features }}
run: |
read -ra features <<< "${FEATURES}"
cargo build --verbose "${features[@]}"
- name: Test
env:
FEATURES: ${{ matrix.features }}
run: |
read -ra features <<< "${FEATURES}"
cargo test --verbose "${features[@]}"
deny:
name: cargo-deny (${{ matrix.checks }})
if: >-
contains(inputs.jobs, 'deny') &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
strategy:
fail-fast: false
matrix:
checks:
- advisories
- bans licenses sources
# Relax on security advisories for now
continue-on-error: ${{ matrix.checks == 'advisories' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check deny.toml is up to date
if: matrix.checks == 'advisories'
uses: $/.github/actions/check-config
with:
working-directory: ${{ inputs.working-directory }}
- uses: EmbarkStudios/cargo-deny-action@17aeb3c839e42274e2b8adf721c8c65edfdc74dd # v2.1.3
with:
command: check ${{ matrix.checks }}
manifest-path: ${{ inputs.working-directory }}/Cargo.toml