Skip to content

Commit c0a175e

Browse files
committed
Update CI config
1 parent 552f748 commit c0a175e

File tree

2 files changed

+58
-25
lines changed

2 files changed

+58
-25
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,9 @@ jobs:
105105
with:
106106
target: ${{ matrix.target }}
107107
if: matrix.target != ''
108-
- run: |
109-
echo "RUSTFLAGS=${RUSTFLAGS} --cfg qemu" >>"${GITHUB_ENV}"
108+
- run: echo "RUSTFLAGS=${RUSTFLAGS} --cfg qemu" >>"${GITHUB_ENV}"
110109
if: matrix.target != '' && !startsWith(matrix.target, 'i686') && !startsWith(matrix.target, 'x86_64')
111-
- run: |
112-
echo "TARGET=--target=${{ matrix.target }}" >>"${GITHUB_ENV}"
110+
- run: echo "TARGET=--target=${{ matrix.target }}" >>"${GITHUB_ENV}"
113111
if: matrix.target != ''
114112

115113
- run: cargo test -vv --workspace --exclude bench --all-features $TARGET $BUILD_STD $DOCTEST_XCOMPILE
@@ -387,6 +385,17 @@ jobs:
387385
branch: update-no-atomic-rs
388386
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
389387

388+
docs:
389+
runs-on: ubuntu-latest
390+
steps:
391+
- uses: actions/checkout@v3
392+
with:
393+
persist-credentials: false
394+
- uses: dtolnay/rust-toolchain@nightly
395+
- run: cargo doc --workspace --all-features --document-private-items
396+
env:
397+
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg docsrs
398+
390399
tidy:
391400
runs-on: ubuntu-latest
392401
steps:
@@ -397,39 +406,22 @@ jobs:
397406
with:
398407
components: clippy,rustfmt
399408
- uses: taiki-e/install-action@shellcheck
409+
- run: pip3 install yq
400410
- run: cargo fmt --all --check
401411
if: always()
402412
- run: cargo clippy --workspace --all-features --all-targets
403413
if: always()
404414
- run: shellcheck $(git ls-files '*.sh')
405415
if: always()
406-
407-
docs:
408-
runs-on: ubuntu-latest
409-
steps:
410-
- uses: actions/checkout@v3
411-
with:
412-
persist-credentials: false
413-
- uses: dtolnay/rust-toolchain@nightly
414-
- run: cargo doc --workspace --all-features
415-
env:
416-
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg docsrs
416+
- run: tools/check-workflow.sh
417+
if: always()
417418

418419
# ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
419420

420421
ci-success:
421422
name: ci
422423
if: github.event_name == 'push' && success()
423-
needs:
424-
- test
425-
- build
426-
- msrv
427-
- miri
428-
- san
429-
- valgrind
430-
- codegen
431-
- tidy
432-
- docs
424+
needs: [test, build, no-std, msrv, miri, san, valgrind, codegen, docs, tidy] # tidy:needs
433425
runs-on: ubuntu-latest
434426
steps:
435427
- name: Mark the job as a success

tools/check-workflow.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2046
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
cd "$(dirname "$0")"/..
6+
7+
# USAGE:
8+
# ./tools/check-workflow.sh
9+
#
10+
# Note: This script requires the following tools:
11+
# - jq
12+
# - yq
13+
14+
bail() {
15+
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
16+
echo "::error::$*"
17+
else
18+
echo "error: $*" >&2
19+
fi
20+
exit 1
21+
}
22+
23+
if [[ $# -gt 0 ]]; then
24+
cat <<EOF
25+
USAGE:
26+
$0
27+
EOF
28+
exit 1
29+
fi
30+
31+
# shellcheck disable=SC2207
32+
jobs_actual=($(yq '.jobs' .github/workflows/ci.yml | jq -r 'keys_unsorted[]'))
33+
unset 'jobs_actual[${#jobs_actual[@]}-1]'
34+
# shellcheck disable=SC2207
35+
jobs_expected=($(yq -r '.jobs."ci-success".needs[]' .github/workflows/ci.yml))
36+
if [[ "${jobs_actual[*]}" != "${jobs_expected[*]+"${jobs_expected[*]}"}" ]]; then
37+
printf -v jobs '%s, ' "${jobs_actual[@]}"
38+
sed -i "s/needs: \[.*\] # tidy:needs/needs: [${jobs%, }] # tidy:needs/" .github/workflows/ci.yml
39+
git --no-pager diff .github/workflows/ci.yml
40+
bail "please update 'needs' section in 'ci-success' job to '[${jobs%, }]'"
41+
fi

0 commit comments

Comments
 (0)