-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (153 loc) · 5.6 KB
/
Copy pathci.yml
File metadata and controls
180 lines (153 loc) · 5.6 KB
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
name: CI
# This workflow runs tests, formatting checks, and the fspec tool.
#
# To set up branch protection for master/main (require reviews and passing CI):
# 1. Go to your repository on GitHub
# 2. Navigate to Settings > Branches
# 3. Click "Add branch protection rule" or edit existing rule for master/main
# 4. Enable the following options:
# - "Require a pull request before merging"
# - Enable "Require approvals" (set to 1 or more)
# - Optionally enable "Dismiss stale pull request approvals when new commits are pushed"
# - "Require status checks to pass before merging"
# - Select "Test Suite" as the required status check
# - Optionally: "Require conversation resolution before merging"
# - Optionally: "Do not allow bypassing the above settings" (prevents admins from bypassing)
# 5. Click "Create" or "Save changes"
#
# Note: Branch protection cannot be configured via files alone - it requires
# repository settings access. However, this workflow will fail if tests don't pass,
# which effectively enforces the requirement.
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch: # Allows manual triggering from GitHub Actions UI
env:
CARGO_TERM_COLOR: always
jobs:
# Format check only runs on Linux (no need to run on all platforms)
fmt:
name: Format Check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
${{ runner.home }}/.cargo/bin/
${{ runner.home }}/.cargo/registry/index/
${{ runner.home }}/.cargo/registry/cache/
${{ runner.home }}/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
run: cargo fmt --all -- --check
# Test suite runs on all platforms
test:
name: Test Suite (${{ matrix.os }})
strategy:
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- os: windows-2022
target: x86_64-pc-windows-msvc
- os: macos-14
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
${{ runner.home }}/.cargo/bin/
${{ runner.home }}/.cargo/registry/index/
${{ runner.home }}/.cargo/registry/cache/
${{ runner.home }}/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run tests
run: cargo test --workspace --all-features --target ${{ matrix.target }}
- name: Run fspec tool
run: cargo run --target ${{ matrix.target }}
working-directory: ${{ github.workspace }}
# Aggregation job that reports overall test suite status
test-complete:
name: Test Suite
needs: [test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" != "success" ]; then
echo "One or more test jobs failed"
exit 1
fi
echo "All test jobs passed successfully"
# Build release binaries for all platforms
build:
name: Build Release (${{ matrix.os }})
strategy:
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
artifact_name: fspec-x86_64-unknown-linux-gnu
binary_name: fspec
- os: windows-2022
target: x86_64-pc-windows-msvc
artifact_name: fspec-x86_64-pc-windows-msvc
binary_name: fspec.exe
- os: macos-14
target: x86_64-apple-darwin
artifact_name: fspec-x86_64-apple-darwin
binary_name: fspec
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
${{ runner.home }}/.cargo/bin/
${{ runner.home }}/.cargo/registry/index/
${{ runner.home }}/.cargo/registry/cache/
${{ runner.home }}/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --bin fspec
- name: Create artifact directory
shell: bash
run: |
mkdir -p ${{ matrix.artifact_name }}
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.artifact_name }}/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}/*
retention-days: 90