Skip to content

Commit b6d07f1

Browse files
committed
github: split matrix into individual build steps per OS
So we don't have to wait for the whole matrix to start building individual packages per OS Signed-off-by: William Casarin <[email protected]>
1 parent 79e0228 commit b6d07f1

File tree

2 files changed

+88
-77
lines changed

2 files changed

+88
-77
lines changed

.github/workflows/build-and-test.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build, Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
upload-artifact-name:
10+
required: true
11+
type: string
12+
upload-artifact-name:
13+
required: true
14+
type: string
15+
additional-setup:
16+
required: false
17+
type: string
18+
19+
jobs:
20+
run:
21+
runs-on: ${{ inputs.os }}
22+
steps:
23+
- name: Checkout Code
24+
uses: actions/checkout@v2
25+
26+
- name: Setup Rust
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
profile: minimal
30+
toolchain: stable
31+
override: true
32+
33+
- name: Rust cache
34+
uses: Swatinem/rust-cache@v2
35+
36+
- name: Additional Setup (if specified)
37+
if: ${{ inputs.additional-setup != '' }}
38+
run: ${{ inputs.additional-setup }}
39+
40+
- name: Run Tests
41+
uses: actions-rs/cargo@v1
42+
with:
43+
command: test
44+
args: --release
45+
46+
- name: Build
47+
uses: actions-rs/cargo@v1
48+
with:
49+
command: build
50+
args: --release
51+
52+
- name: Upload Build Artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ inputs.upload-artifact-name }}
56+
path: ${{ inputs.upload-artifact-path }}

.github/workflows/rust.yml

+32-77
Original file line numberDiff line numberDiff line change
@@ -37,85 +37,36 @@ jobs:
3737
command: clippy
3838
args: -- -D warnings
3939

40-
build-and-test:
41-
name: Build and Test (${{ matrix.os }})
42-
runs-on: ${{ matrix.os }}
43-
strategy:
44-
matrix:
45-
os: [ubuntu-latest, windows-latest, macos-latest]
46-
toolchain: [stable]
47-
steps:
48-
# Checkout the repository
49-
- name: Checkout Code
50-
uses: actions/checkout@v2
51-
52-
# Set up the Rust toolchain
53-
- name: Setup Rust
54-
uses: actions-rs/toolchain@v1
55-
with:
56-
profile: minimal
57-
toolchain: ${{ matrix.toolchain }}
58-
override: true
59-
60-
# Cache
61-
- name: Rust cache
62-
uses: Swatinem/rust-cache@v2
63-
64-
# Install dependencies (only for Ubuntu)
65-
- name: Install Dependencies (Ubuntu)
66-
if: runner.os == 'Linux'
67-
run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
68-
69-
# Run tests
70-
- name: Run Tests
71-
uses: actions-rs/cargo@v1
72-
with:
73-
command: test
74-
args: --release
75-
76-
# Build
77-
- name: Build
78-
uses: actions-rs/cargo@v1
79-
with:
80-
command: build
81-
args: --release
82-
83-
# Strip Debug Symbols
84-
#
85-
## > Don't strip for now <
86-
#
87-
#- name: Strip Debug Symbols
88-
# if: runner.os == 'Linux'
89-
# run: strip target/release/notedeck || echo "Skipping strip if not applicable"
90-
91-
# Upload bin for further packaging steps
92-
- name: Upload Build Artifacts (Linux)
93-
if: runner.os == 'Linux'
94-
uses: actions/upload-artifact@v4
95-
with:
96-
name: notedeck-linux-bin
97-
path: target/release/notedeck
98-
99-
# Upload artifacts (for macOS, adjust paths as needed)
100-
- name: Upload Build Artifacts (macOS)
101-
if: runner.os == 'macOS'
102-
uses: actions/upload-artifact@v4
103-
with:
104-
name: notedeck-macos-bin
105-
path: target/release/notedeck
106-
107-
# Upload exe for further packaging steps
108-
- name: Upload Build Artifacts (Windows)
109-
if: runner.os == 'Windows'
110-
uses: actions/upload-artifact@v4
111-
with:
112-
name: notedeck.exe
113-
path: target/release/notedeck.exe
40+
linux-build-test:
41+
name: Build and Test (Linux)
42+
uses: ./.github/workflows/build-and-test.yml
43+
with:
44+
os: ubuntu-latest
45+
upload-artifact-name: notedeck-linux-bin
46+
upload-artifact-path: target/release/notedeck
47+
additional-setup: |
48+
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
49+
50+
macos-build-test:
51+
name: Build and Test (macOS)
52+
uses: ./.github/workflows/build-and-test.yml
53+
with:
54+
os: macos-latest
55+
upload-artifact-name: notedeck-macos-bin
56+
upload-artifact-path: target/release/notedeck
57+
58+
windows-build-test:
59+
name: Build and Test (Windows)
60+
uses: ./.github/workflows/build-and-test.yml
61+
with:
62+
os: windows-latest
63+
upload-artifact-name: notedeck.exe
64+
upload-artifact-path: target/release/notedeck.exe
11465

11566
packaging:
11667
name: Build Linux Packages
11768
runs-on: ubuntu-latest
118-
needs: build-and-test
69+
needs: linux-build-test
11970
steps:
12071
# Checkout the repository
12172
- name: Checkout Code
@@ -161,7 +112,7 @@ jobs:
161112
macos-dmg:
162113
name: Build macOS DMG
163114
runs-on: macos-latest
164-
needs: build-and-test
115+
needs: macos-build-test
165116
env:
166117
NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }}
167118
NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }}
@@ -180,6 +131,10 @@ jobs:
180131
toolchain: stable
181132
override: true
182133

134+
# create-dmg and cargo-bundle caching
135+
- name: Rust cache
136+
uses: Swatinem/rust-cache@v2
137+
183138
- name: Download Build Artifacts (MacOS)
184139
uses: actions/download-artifact@v4
185140
with:
@@ -209,7 +164,7 @@ jobs:
209164
windows-installer:
210165
name: Build Windows Installer
211166
runs-on: windows-latest
212-
needs: build-and-test
167+
needs: windows-build-test
213168
steps:
214169
# Checkout the repository
215170
- name: Checkout Code

0 commit comments

Comments
 (0)