Skip to content

Commit

Permalink
Update CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 13, 2022
1 parent 552f748 commit c0a175e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
42 changes: 17 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ jobs:
with:
target: ${{ matrix.target }}
if: matrix.target != ''
- run: |
echo "RUSTFLAGS=${RUSTFLAGS} --cfg qemu" >>"${GITHUB_ENV}"
- run: echo "RUSTFLAGS=${RUSTFLAGS} --cfg qemu" >>"${GITHUB_ENV}"
if: matrix.target != '' && !startsWith(matrix.target, 'i686') && !startsWith(matrix.target, 'x86_64')
- run: |
echo "TARGET=--target=${{ matrix.target }}" >>"${GITHUB_ENV}"
- run: echo "TARGET=--target=${{ matrix.target }}" >>"${GITHUB_ENV}"
if: matrix.target != ''

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

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --workspace --all-features --document-private-items
env:
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg docsrs

tidy:
runs-on: ubuntu-latest
steps:
Expand All @@ -397,39 +406,22 @@ jobs:
with:
components: clippy,rustfmt
- uses: taiki-e/install-action@shellcheck
- run: pip3 install yq
- run: cargo fmt --all --check
if: always()
- run: cargo clippy --workspace --all-features --all-targets
if: always()
- run: shellcheck $(git ls-files '*.sh')
if: always()

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --workspace --all-features
env:
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg docsrs
- run: tools/check-workflow.sh
if: always()

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

ci-success:
name: ci
if: github.event_name == 'push' && success()
needs:
- test
- build
- msrv
- miri
- san
- valgrind
- codegen
- tidy
- docs
needs: [test, build, no-std, msrv, miri, san, valgrind, codegen, docs, tidy] # tidy:needs
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
Expand Down
41 changes: 41 additions & 0 deletions tools/check-workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# shellcheck disable=SC2046
set -euo pipefail
IFS=$'\n\t'
cd "$(dirname "$0")"/..

# USAGE:
# ./tools/check-workflow.sh
#
# Note: This script requires the following tools:
# - jq
# - yq

bail() {
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
echo "::error::$*"
else
echo "error: $*" >&2
fi
exit 1
}

if [[ $# -gt 0 ]]; then
cat <<EOF
USAGE:
$0
EOF
exit 1
fi

# shellcheck disable=SC2207
jobs_actual=($(yq '.jobs' .github/workflows/ci.yml | jq -r 'keys_unsorted[]'))
unset 'jobs_actual[${#jobs_actual[@]}-1]'
# shellcheck disable=SC2207
jobs_expected=($(yq -r '.jobs."ci-success".needs[]' .github/workflows/ci.yml))
if [[ "${jobs_actual[*]}" != "${jobs_expected[*]+"${jobs_expected[*]}"}" ]]; then
printf -v jobs '%s, ' "${jobs_actual[@]}"
sed -i "s/needs: \[.*\] # tidy:needs/needs: [${jobs%, }] # tidy:needs/" .github/workflows/ci.yml
git --no-pager diff .github/workflows/ci.yml
bail "please update 'needs' section in 'ci-success' job to '[${jobs%, }]'"
fi

0 comments on commit c0a175e

Please sign in to comment.