Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit fe0add7

Browse files
committed
ci: introduce linting and reusuable workflows
1 parent ef8ca1e commit fe0add7

File tree

7 files changed

+156
-143
lines changed

7 files changed

+156
-143
lines changed

.github/workflows/_lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Rust
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get install -y build-essential
18+
sudo snap install --classic rustup
19+
rustup default stable
20+
21+
- name: Check formattting
22+
run: cargo fmt --check
23+
24+
- name: Lint
25+
run: cargo clippy
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Spread Matrix
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
tests:
7+
description: Spread job matrix
8+
value: ${{ jobs.spread-matrix.outputs.tests }}
9+
10+
jobs:
11+
spread-matrix:
12+
name: Compute
13+
runs-on: ubuntu-24.04
14+
outputs:
15+
tests: ${{ steps.tests.outputs.tests }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Go
21+
uses: actions/setup-go@v5
22+
23+
- name: Install
24+
run: |
25+
go install github.com/snapcore/spread/cmd/spread@latest
26+
27+
- name: Generate matrix list
28+
id: tests
29+
run: |
30+
list="$(spread -list lxd | jq -r -ncR '[inputs | select(length>0)]')"
31+
echo "tests=$list"
32+
echo "tests=$list" >> "$GITHUB_OUTPUT"

.github/workflows/_spread.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Spread Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tests:
7+
description: Spread tests to run
8+
type: string
9+
required: true
10+
11+
jobs:
12+
spread-tests:
13+
name: ${{ matrix.test }}
14+
runs-on: ubuntu-24.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
test: ${{ fromJSON(inputs.tests) }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: "1.23.0"
27+
28+
- name: Install
29+
run: go install github.com/snapcore/spread/cmd/spread@latest
30+
31+
- name: Setup LXD
32+
uses: canonical/[email protected]
33+
34+
- name: Run integration tests
35+
run: spread -v "${{ matrix.test }}"

.github/workflows/_test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
name: Unit Tests
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Rust
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get install -y build-essential
18+
sudo snap install --classic rustup
19+
rustup default stable
20+
21+
- name: Build
22+
run: cargo build
23+
24+
- name: Unit tests
25+
run: cargo test -- --show-output

.github/workflows/push.yml

Lines changed: 20 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build/Test oxidizr
1+
name: CI (Push)
22

33
on:
44
push:
@@ -11,85 +11,34 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
test:
15-
name: Build/Test oxidizr
16-
runs-on: ubuntu-latest
17-
steps:
18-
- name: Check out code
19-
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
22-
23-
- name: Setup Rust
24-
run: |
25-
sudo apt-get update
26-
sudo apt-get install -y build-essential
27-
sudo snap install --classic rustup
28-
rustup default stable
29-
30-
- name: Build oxidizr
31-
run: |
32-
cargo build
14+
lint:
15+
name: Lint
16+
uses: ./.github/workflows/_lint.yml
3317

34-
- name: Run tests
35-
run: |
36-
cargo test -- --show-output
37-
38-
define-matrix:
39-
name: Define spread matrix
40-
runs-on: ubuntu-24.04
41-
outputs:
42-
suites: ${{ steps.suites.outputs.suites }}
43-
steps:
44-
- name: Checkout
45-
uses: actions/checkout@v4
46-
47-
- name: Setup Go
48-
uses: actions/setup-go@v5
49-
50-
- name: Install
51-
run: |
52-
go install github.com/snapcore/spread/cmd/spread@latest
18+
test:
19+
name: Test
20+
uses: ./.github/workflows/_test.yml
5321

54-
- name: Generate matrix list
55-
id: suites
56-
run: |
57-
list="$(spread -list lxd | jq -r -ncR '[inputs | select(length>0)]')"
58-
echo "suites=$list"
59-
echo "suites=$list" >> $GITHUB_OUTPUT
22+
spread-matrix:
23+
name: Spread Matrix
24+
uses: ./.github/workflows/_spread-matrix.yml
6025

6126
spread-tests:
62-
name: Spread (${{ matrix.test }})
63-
runs-on: ubuntu-24.04
27+
name: Spread tests
28+
uses: ./.github/workflows/_spread.yml
6429
needs:
6530
- test
66-
- define-matrix
67-
strategy:
68-
fail-fast: false
69-
matrix:
70-
test: ${{ fromJSON(needs.define-matrix.outputs.suites) }}
71-
steps:
72-
- name: Checkout
73-
uses: actions/checkout@v4
74-
75-
- name: Setup Go
76-
uses: actions/setup-go@v5
77-
with:
78-
go-version: "1.23.0"
79-
80-
- name: Install
81-
run: |
82-
go install github.com/snapcore/spread/cmd/spread@latest
83-
84-
- name: Setup LXD
85-
uses: canonical/[email protected]
86-
87-
- name: Run integration tests
88-
run: |
89-
spread -v "${{ matrix.test }}"
31+
- lint
32+
- spread-matrix
33+
with:
34+
tests: spread-matrix.outputs.tests
9035

9136
snap:
9237
name: Build snap
38+
needs:
39+
- test
40+
- lint
41+
- spread-tests
9342
strategy:
9443
matrix:
9544
include:

.github/workflows/release.yml

Lines changed: 15 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,82 +9,27 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
test:
13-
name: Build/Test oxidizr
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Check out code
17-
uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
20-
21-
- name: Setup Rust
22-
run: |
23-
sudo apt-get update
24-
sudo apt-get install -y build-essential
25-
sudo snap install --classic rustup
26-
rustup default stable
27-
28-
- name: Build oxidizr
29-
run: |
30-
cargo build
31-
32-
- name: Run tests
33-
run: |
34-
cargo test -- --show-output
35-
36-
define-matrix:
37-
name: Define spread matrix
38-
runs-on: ubuntu-24.04
39-
outputs:
40-
suites: ${{ steps.suites.outputs.suites }}
41-
steps:
42-
- name: Checkout
43-
uses: actions/checkout@v4
12+
lint:
13+
name: Lint
14+
uses: ./.github/workflows/_lint.yml
4415

45-
- name: Setup Go
46-
uses: actions/setup-go@v5
47-
48-
- name: Install
49-
run: |
50-
go install github.com/snapcore/spread/cmd/spread@latest
16+
test:
17+
name: Test
18+
uses: ./.github/workflows/_test.yml
5119

52-
- name: Generate matrix list
53-
id: suites
54-
run: |
55-
list="$(spread -list lxd | jq -r -ncR '[inputs | select(length>0)]')"
56-
echo "suites=$list"
57-
echo "suites=$list" >> $GITHUB_OUTPUT
20+
spread-matrix:
21+
name: Spread Matrix
22+
uses: ./.github/workflows/_spread-matrix.yml
5823

5924
spread-tests:
60-
name: Spread (${{ matrix.test }})
61-
runs-on: ubuntu-24.04
25+
name: Spread tests
26+
uses: ./.github/workflows/_spread.yml
6227
needs:
6328
- test
64-
- define-matrix
65-
strategy:
66-
fail-fast: false
67-
matrix:
68-
test: ${{ fromJSON(needs.define-matrix.outputs.suites) }}
69-
steps:
70-
- name: Checkout
71-
uses: actions/checkout@v4
72-
73-
- name: Setup Go
74-
uses: actions/setup-go@v5
75-
with:
76-
go-version: "1.23.0"
77-
78-
- name: Install
79-
run: |
80-
go install github.com/snapcore/spread/cmd/spread@latest
81-
82-
- name: Setup LXD
83-
uses: canonical/[email protected]
84-
85-
- name: Run integration tests
86-
run: |
87-
spread -v "${{ matrix.test }}"
29+
- lint
30+
- spread-matrix
31+
with:
32+
tests: spread-matrix.outputs.tests
8833

8934
snap:
9035
name: Release snap

src/packages/coreutils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ mod tests {
122122
.for_each(|f| assert!(expected.contains(&f.as_str())));
123123

124124
let created_symlinks = runner.created_symlinks.clone().into_inner();
125-
let expected = [("/usr/bin/coreutils", "/usr/bin/sort"),
126-
("/usr/bin/coreutils", "/usr/bin/date")];
125+
let expected = [
126+
("/usr/bin/coreutils", "/usr/bin/sort"),
127+
("/usr/bin/coreutils", "/usr/bin/date"),
128+
];
127129
assert!(created_symlinks.len() == 2);
128130
created_symlinks
129131
.iter()

0 commit comments

Comments
 (0)