Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: continue BSP building workflow if build any BSP fails #745

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/list-BSPs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ runs:
- id: compute-matrix
shell: bash
run: |
matrix_json=$(cat crates.json | jq -Mr -c '{ "bsp": (.boards | keys ), "toolchain": ["stable", "nightly"] }')
matrix_json=$(cat crates.json | jq -Mr -c '{ "bsp": [ (.boards | to_entries | .[] | {"name": (.key), "tier": .value.tier}) ] , "toolchain": ["stable", "nightly"] }')
echo "matrix=${matrix_json}" >> $GITHUB_OUTPUT
66 changes: 56 additions & 10 deletions .github/workflows/build-bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,89 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-matrix
uses: ./.github/actions/list-BSPs

build:
name: "${{matrix.bsp.name}} (Tier ${{matrix.bsp.tier}}, ${{matrix.toolchain}})"
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
# There is a subtle difference between continue-on-error and setting
# strategy.fail-fast=false. Both will allow all jobs to run to completion,
# however continue-on-error lets the next workflow stage run regardless of
# failed jobs, strategy.fail-fast=false will skip subsequent stages if any
# job fails.
continue-on-error: true
needs: setup
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust
run: |
rustup set profile minimal
rustup override set ${{ matrix.toolchain }}
target=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .target')
target=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp.name }}' -c '.boards | .[$board] | .target')
rustup target add ${target}
rustup component add clippy

- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Build ${{ matrix.bsp }}
- name: Build ${{ matrix.bsp.name }}
run: |
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .build')
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp.name }}' -c '.boards | .[$board] | .build')
set -ex
cd boards/${{ matrix.bsp }}
pushd boards/${{ matrix.bsp.name }}
$(${build_invocation})
popd
mkdir -p output
touch "output/build"

- name: Clippy ${{ matrix.bsp }}
- name: Clippy ${{ matrix.bsp.name }}
if: ${{ matrix.toolchain == 'nightly' }}
run: |
set -ex
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .build')
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp.name }}' -c '.boards | .[$board] | .build')
clippy_invocation=$(echo ${build_invocation} | sed 's/cargo build/cargo clippy/g')
cd boards/${{ matrix.bsp }}
cd boards/${{ matrix.bsp.name }}
$(${clippy_invocation})

- name: Done
uses: actions/upload-artifact@v4
with:
# name needs to be unique in the workspace
name: "${{ matrix.bsp.name }}-${{ matrix.toolchain }}"
path: output

check:
runs-on: ubuntu-latest
needs: [setup, build]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: successful-jobs
- name: Tier 1 BSPs built on stable
env:
MATRIX: ${{ needs.setup.outputs.matrix }}
run: |
tier_1_bsps=$(jq -Mr -c '.bsp[] | select(.tier == 1) | .name' <<< ${MATRIX})

success="true"
for bsp in ${tier_1_bsps}; do
if [ -f successful-jobs/"${bsp}"-stable/build ]; then
echo "${bsp}" built on stable toolchain
else
echo "${bsp}" failed to build on stable toolchain
success="false"
fi
done

if [ ${success} = "true" ]; then
echo "Tier 1 BSPs all built on stable"
else
false
fi
4 changes: 2 additions & 2 deletions .github/workflows/build-hal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- id: set-matrix
uses: ./.github/actions/list-HAL-variants

Expand All @@ -20,7 +20,7 @@ jobs:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup set profile minimal
Expand Down
Loading