Skip to content

Commit 943d275

Browse files
authored
Merge pull request #5 from YanLien/main
ci: reorganize workflows into modular reusable components
2 parents 43a16a8 + e9e861a commit 943d275

File tree

5 files changed

+171
-60
lines changed

5 files changed

+171
-60
lines changed

.github/workflows/check.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build & Check CI
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
ci:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
rust-toolchain: [nightly]
13+
targets: [x86_64-unknown-linux-gnu, x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: dtolnay/rust-toolchain@nightly
17+
with:
18+
toolchain: ${{ matrix.rust-toolchain }}
19+
components: rust-src, clippy, rustfmt
20+
targets: ${{ matrix.targets }}
21+
- name: Check rust version
22+
run: rustc --version --verbose
23+
- name: Check code format
24+
run: cargo fmt --all -- --check
25+
- name: Clippy
26+
run: cargo clippy --manifest-path ./fdt-parser/Cargo.toml --target ${{ matrix.targets }} --all-features -- -A clippy::new_without_default
27+
- name: Build
28+
run: cargo build -p fdt-parser --target ${{ matrix.targets }} --all-features

.github/workflows/ci.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: 'pages'
16+
cancel-in-progress: false
17+
18+
jobs:
19+
quality-check:
20+
uses: ./.github/workflows/check.yml
21+
22+
test:
23+
uses: ./.github/workflows/test.yml
24+
25+
build-doc:
26+
name: Build documentation
27+
runs-on: ubuntu-latest
28+
needs: [quality-check, test]
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v5
32+
33+
- name: Install Rust toolchain
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
toolchain: nightly
37+
components: rust-src
38+
39+
- name: Build docs
40+
run: cargo doc --no-deps
41+
42+
- name: Create index redirect
43+
run: |
44+
printf '<meta http-equiv="refresh" content="0;url=fdt-parser/index.html">' > target/doc/index.html
45+
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v4
48+
with:
49+
path: target/doc
50+
51+
deploy-doc:
52+
name: Deploy to GitHub Pages
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
runs-on: ubuntu-latest
57+
needs: build-doc
58+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release-plz
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Test"]
6+
types:
7+
- completed
8+
branches:
9+
- main
10+
11+
jobs:
12+
release-plz-release:
13+
name: Release-plz release
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.repository_owner == 'drivercraft' &&
17+
(github.event_name == 'push' ||
18+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'))
19+
permissions:
20+
contents: write
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
27+
persist-credentials: false
28+
- name: Install Rust toolchain
29+
uses: dtolnay/rust-toolchain@stable
30+
- name: Run release-plz
31+
uses: release-plz/action@v0.5
32+
with:
33+
command: release
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
36+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
37+
38+
release-plz-pr:
39+
name: Release-plz PR
40+
runs-on: ubuntu-latest
41+
if: |
42+
github.repository_owner == 'drivercraft' &&
43+
(github.event_name == 'push' ||
44+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'))
45+
permissions:
46+
pull-requests: write
47+
contents: write
48+
concurrency:
49+
group: release-plz-${{ github.ref }}
50+
cancel-in-progress: false
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v5
54+
with:
55+
fetch-depth: 0
56+
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
57+
persist-credentials: false
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
- name: Run release-plz
61+
uses: release-plz/action@v0.5
62+
with:
63+
command: release-pr
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
66+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
ci:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: dtolnay/rust-toolchain@nightly
12+
- name: Install dtc
13+
run: sudo apt-get install device-tree-compiler
14+
- name: Unit test
15+
run: cargo test -- --nocapture

0 commit comments

Comments
 (0)