-
-
Notifications
You must be signed in to change notification settings - Fork 243
188 lines (188 loc) · 5.78 KB
/
unit-tests.yml
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# SPDX-FileCopyrightText: 2024 Christina Sørensen
# SPDX-License-Identifier: EUPL-1.2
name: Unit tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-deny
- name: Scan for vulnerabilities
run: cargo deny check
check_if_pr:
runs-on: ubuntu-latest
outputs:
is_pr: ${{ steps.check.outputs.is_pr }}
steps:
- name: Check if it's a PR
id: check
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "is_pr=true" >> $GITHUB_OUTPUT
else
echo "is_pr=false" >> $GITHUB_OUTPUT
fi
no-merge-commits:
needs: check_if_pr
if: needs.check_if_pr.outputs.is_pr == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run test
uses: NexusPHP/no-merge-commits@v2.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
conventional:
needs: [check_if_pr, no-merge-commits]
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: webiny/action-conventional-commits@v1.3.0
unit-tests:
needs: conventional
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.rust == 'nightly' }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [1.70.0, stable, beta, nightly]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: rustup toolchain install ${{ matrix.rust }} --profile minimal
- uses: Swatinem/rust-cache@v2
- name: Install cargo-hack
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: cargo install cargo-hack
- name: Run rustfmt checks
run: cargo fmt --check
- name: Run clippy lints
if: ${{ matrix.os != 'windows-latest' }}
run: cargo clippy -- -D warnings
- name: Run unit tests
run: cargo hack test
unit-tests-freebsd:
needs: conventional
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Compile
uses: vmactions/freebsd-vm@v1
with:
release: '14.2'
usesh: true
prepare: |
pkg install -y rust git
cargo install cargo-hack
git config --global --add safe.directory /home/runner/work/eza/eza
run: |
set -e
export CARGO_TERM_COLOR="always"
export RUSTFLAGS="--deny warnings"
cargo fmt --check
cargo clippy -- -D warnings
cargo hack test
unit-tests-netbsd:
needs: conventional
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Compile
uses: vmactions/netbsd-vm@v1
with:
release: '10.1'
usesh: true
prepare: |
PATH="/root/.cargo/bin:/usr/pkg/sbin:/usr/pkg/bin:$PATH"
PKG_PATH="https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/10.1/All/"
export PATH PKG_PATH
/usr/sbin/pkg_add pkgin
pkgin -y install rust git
cargo install cargo-hack
git config --global --add safe.directory /home/runner/work/eza/eza
run: |
set -e
export CARGO_TERM_COLOR="always"
export RUSTFLAGS="--deny warnings"
cargo fmt --check
cargo clippy -- -D warnings
cargo hack test
unit-tests-openbsd:
needs: conventional
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Compile
uses: vmactions/openbsd-vm@v1
with:
release: '7.6'
usesh: true
prepare: |
pkg_add rust rust-rustfmt rust-clippy git
cargo install cargo-hack
git config --global --add safe.directory /home/runner/work/eza/eza
run: |
set -e
export CARGO_TERM_COLOR="always"
export RUSTFLAGS="--deny warnings"
cargo fmt --check
cargo clippy -- -D warnings
cargo hack test
flake-check:
needs: conventional
name: Check Nix Flake
runs-on: ubuntu-latest
strategy:
matrix:
checks: [build, formatting, lint, pre-commit-check, test, trycmd]
target: [x86_64-linux]
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Nix Flake Check
run: nix build .#checks.${{ matrix.target }}.${{ matrix.checks }} -L
flake-build:
needs: conventional
name: Build Nix package
# if cross compilation is desired add 'aarch64-linux', 'x86_64-darwin' and 'aarch64-darwin' and fix the flake to support cross compilation.
strategy:
matrix:
target: [x86_64-linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Nix Build
run: nix build .#packages.${{ matrix.target }}.default -L