Skip to content

Commit aeb3c07

Browse files
committed
fix(ci): dont generate a job for each crate-system on each system
Also simplifies the test run check
1 parent 86c5a29 commit aeb3c07

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,16 @@ jobs:
139139
build_success_files=$(find . -maxdepth 2 -type f -name "build-success-*" -exec basename {} \;)
140140
echo "Build Success Files: $build_success_files"
141141
142-
declare -a found_artifacts=()
142+
declare -A found_artifacts=()
143143
for crate_system in $crate_systems; do
144144
echo "Checking for build-success-$crate_system"
145145
if [[ ${build_success_files[*]} =~ build-success-$crate_system ]]; then
146146
echo "Found build-success-$crate_system"
147-
found_artifacts+=("$crate_system")
147+
split=("${crate_system//-/ }")
148+
split_len=${#split[@]}
149+
crate=$(IFS=$'-' ; echo "${split[*]:0:$split_len-2}")
150+
system=$(IFS=$'-' ; echo "${split[*]:$split_len-2:2}")
151+
found_artifacts["$crate"]+="$system,"
148152
fi
149153
done
150154
@@ -155,9 +159,10 @@ jobs:
155159
fi
156160
157161
matrix='{"system": ["x86_64-linux","aarch64-linux","x86_64-windows","aarch64-windows","x86_64-darwin","aarch64-darwin"], "crate": ['
158-
for crate_system in "${found_artifacts[@]}"; do
159-
crate="${crate_system%-*}"
160-
matrix+="\"$crate\","
162+
for crate in "${!found_artifacts[@]}"; do
163+
systems=${found_artifacts["$crate"]}
164+
systems=${systems::-1}
165+
matrix+="{\"name\": \"$crate\", \"systems\": [\"${systems//,/\",\"}\"]},"
161166
done
162167
matrix="${matrix::-1}]}"
163168
@@ -177,7 +182,7 @@ jobs:
177182
fail-fast: false
178183
matrix: ${{ fromJson(needs.determine-tests.outputs.test-matrix) }}
179184
runs-on: ${{ endsWith(matrix.system, 'darwin') && 'macos-latest' || 'ubuntu-latest' }}
180-
name: Run Tests for ${{ matrix.crate }} on ${{ matrix.system }}
185+
name: Run Tests for ${{ matrix.crate.name }} on ${{ matrix.system }}
181186
steps:
182187
- uses: actions/checkout@v4
183188
- uses: cachix/install-nix-action@v30
@@ -186,21 +191,18 @@ jobs:
186191
- name: Should we run tests?
187192
id: should-run-tests
188193
run: |
189-
matrix_system="${{ matrix.system }}"
190-
191-
# If the system ends with windows we should skip the tests.
192-
if [[ "$matrix_system" == *windows ]]; then
193-
echo "run_tests=false" >> "$GITHUB_OUTPUT"
194-
fi
195-
196-
# We only want to run native tests on the runner that matches the host system, no cross-architecture testing.
194+
echo "run_tests=false" >> "$GITHUB_OUTPUT"
197195
host_system=$(nix eval --raw nixpkgs#system)
198-
if [[ "$matrix_system" == "$host_system" ]]; then
199-
echo "run_tests=true" >> "$GITHUB_OUTPUT"
200-
fi
196+
successful_builds=(${{ matrix.crate.systems }})
201197
202-
echo "run_tests=false" >> "$GITHUB_OUTPUT"
198+
# If crate.systems does not contain the host system, the build was not successful and we should exit.
199+
if [[ ${successful_builds[*]} =~ $host_system ]]; then
200+
echo "Build was not successful for $host_system."
201+
exit 0
202+
fi
203203
204+
echo "run_tests=true" >> "$GITHUB_OUTPUT"
205+
204206
- name: Run Tests
205207
if: ${{ steps.should-run-tests.outputs.run_tests == 'true' }}
206208
run: nix develop --impure -c cargo nextest run --package ${{ matrix.crate }} --all-features

0 commit comments

Comments
 (0)