Skip to content

Commit 3b3242f

Browse files
ci: optimize workflows with caching, composite action, and release split
- Add Swatinem/rust-cache to all Rust jobs (target-specific keys for cross-compilation) - Remove apt full-upgrade, use apt-get install -y - Add concurrency cancellation to push/PR workflows - Extract reusable setup-rust composite action to deduplicate boilerplate - Split release.yml into build.yml (CI build) and release.yml (tag release) - Add fast check-release job on PRs, gate expensive LTO build to push only - Merge release-docker.yml into release.yml, add Docker images to release notes - Pin Python 3.12 in doc.yml, upgrade setup-python to v5 - Replace cargo install cargo-hack with cargo-binstall - Add missing rustup update to binary upload job - Add check_release and docker-build recipes to justfile - Update Dockerfile to use just release and pinned rust version - Update .dockerignore for new project structure
1 parent c12bea5 commit 3b3242f

11 files changed

Lines changed: 242 additions & 191 deletions

File tree

.dockerignore

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
*
2-
!src
3-
!Cargo.toml
4-
!Cargo.lock
5-
!diode-file-bindings/src
6-
!diode-file-bindings/Cargo.toml
7-
!diode-file-bindings/Cargo.lock
1+
.github/
2+
config_examples/
3+
doc/
4+
target/
5+
CONTRIBUTING.md
6+
docker-compose.yml
7+
Dockerfile
8+
LICENSE
9+
README.md
10+
SECURITY.md
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Setup Rust
2+
description: Checkout, install system deps, update Rust toolchain, and cache Cargo.
3+
4+
inputs:
5+
target:
6+
description: Optional Rust cross-compilation target to add.
7+
default: ''
8+
extra-packages:
9+
description: Extra apt packages to install alongside just.
10+
default: ''
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Install system dependencies
18+
shell: bash
19+
run: |
20+
packages="just"
21+
if [ -n "${{ inputs.extra-packages }}" ]; then
22+
packages="$packages ${{ inputs.extra-packages }}"
23+
fi
24+
sudo apt-get update && sudo apt-get install -y $packages
25+
26+
- name: Update rust
27+
shell: bash
28+
run: rustup update
29+
30+
- name: Add Rust target
31+
if: inputs.target != ''
32+
shell: bash
33+
run: rustup target add ${{ inputs.target }}
34+
35+
- uses: Swatinem/rust-cache@v2
36+
with:
37+
key: ${{ inputs.target }}

.github/workflows/build.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master, dev]
6+
pull_request:
7+
branches: [master]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
SUFFIX: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
17+
18+
jobs:
19+
check-release:
20+
name: Check release build
21+
runs-on: ubuntu-26.04
22+
steps:
23+
- uses: ./.github/actions/setup-rust
24+
25+
- name: Check release build
26+
run: just check_release
27+
28+
build-linux:
29+
name: Build for Linux
30+
runs-on: ubuntu-26.04
31+
if: github.event_name != 'pull_request'
32+
needs: check-release
33+
steps:
34+
- uses: ./.github/actions/setup-rust
35+
36+
- name: Build release
37+
run: |
38+
just release
39+
just grant_chroot_receive_file
40+
41+
- name: Gather artifacts
42+
run: |
43+
mkdir -p artifacts/release/
44+
cp target/release/liblidi_bindings.so artifacts/release/
45+
cp target/release/lidi-dir-send artifacts/release/
46+
cp target/release/lidi-file-receive artifacts/release/
47+
cp target/release/lidi-file-send artifacts/release/
48+
cp target/release/lidi-flood-receive artifacts/release/
49+
cp target/release/lidi-flood-send artifacts/release/
50+
cp target/release/lidi-network-simulator artifacts/release/
51+
cp target/release/lidi-receive artifacts/release/
52+
cp target/release/lidi-receive-oneshot artifacts/release/
53+
cp target/release/lidi-send artifacts/release/
54+
cp target/release/lidi-send-oneshot artifacts/release/
55+
cp target/release/lidi-udp-receive artifacts/release/
56+
cp target/release/lidi-udp-send artifacts/release/
57+
58+
- name: Upload release artifacts
59+
uses: actions/upload-artifact@v7
60+
with:
61+
name: linux
62+
path: artifacts
63+
retention-days: 0
64+
65+
package:
66+
name: Package artifacts
67+
runs-on: ubuntu-26.04
68+
if: github.event_name != 'pull_request'
69+
needs: [build-linux]
70+
steps:
71+
- uses: actions/checkout@v6
72+
73+
- uses: actions/download-artifact@v8
74+
with:
75+
merge-multiple: true
76+
path: artifacts
77+
78+
- name: Gathering artifacts
79+
run: |
80+
mkdir -p release/lidi-${{ env.SUFFIX }}
81+
mv artifacts/release/* release/lidi-${{ env.SUFFIX }}/
82+
cp -r CONTRIBUTING.md LICENSE README.md SECURITY.md release/lidi-${{ env.SUFFIX }}/
83+
84+
- name: Upload release artifacts
85+
uses: actions/upload-artifact@v7
86+
with:
87+
name: lidi-${{ env.SUFFIX }}
88+
path: release

.github/workflows/check-build.yml

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,32 @@ on:
77
branches: [ master ]
88
workflow_dispatch:
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
env:
1115
CARGO_TERM_COLOR: always
1216

1317
jobs:
1418
check-build-windows:
1519
name: Check build for Windows
1620
runs-on: ubuntu-26.04
17-
1821
steps:
19-
- uses: actions/checkout@v6
20-
21-
- name: Install system dependencies
22-
run: |
23-
sudo apt update
24-
sudo apt full-upgrade
25-
sudo apt install just
26-
27-
- name: Update rust
28-
run: rustup update
29-
30-
- name: Add Windows target to Rust
31-
run: rustup target add x86_64-pc-windows-gnu
22+
- uses: ./.github/actions/setup-rust
23+
with:
24+
target: x86_64-pc-windows-gnu
3225

3326
- name: Check build for Windows
3427
run: just check_windows
3528

3629
check-build-freebsd:
3730
name: Check build for FreeBSD
3831
runs-on: ubuntu-26.04
39-
4032
steps:
41-
- uses: actions/checkout@v6
42-
43-
- name: Install system dependencies
44-
run: |
45-
sudo apt update
46-
sudo apt full-upgrade
47-
sudo apt install just
48-
49-
- name: Update rust
50-
run: rustup update
51-
52-
- name: Add FreeBSD target to Rust
53-
run: rustup target add x86_64-unknown-freebsd
33+
- uses: ./.github/actions/setup-rust
34+
with:
35+
target: x86_64-unknown-freebsd
5436

5537
- name: Check build for FreeBSD
5638
run: just check_freebsd
57-

.github/workflows/clippy.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@ on:
77
branches: [master]
88
workflow_dispatch:
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
env:
1115
CARGO_TERM_COLOR: always
1216

1317
jobs:
1418
clippy-check:
1519
name: Run clippy
1620
runs-on: ubuntu-26.04
17-
1821
steps:
19-
- uses: actions/checkout@v6
20-
21-
- name: Install system dependencies
22-
run: |
23-
sudo apt update
24-
sudo apt full-upgrade
25-
sudo apt install just
26-
27-
- name: Update rust
28-
run: rustup update
22+
- uses: ./.github/actions/setup-rust
2923

3024
- name: Run clippy
3125
run: just clippy

.github/workflows/doc.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010

1111
steps:
1212
- uses: actions/checkout@v6
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.12'
1416

1517
- name: Install system dependencies
16-
run: |
17-
sudo apt update
18-
sudo apt full-upgrade
19-
sudo apt install just
18+
run: sudo apt-get update && sudo apt-get install -y just
2019

2120
- name: Prepare
2221
run: pip install sphinx sphinx_rtd_theme

.github/workflows/release-docker.yml

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

0 commit comments

Comments
 (0)