forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,80 @@ | ||
#### | ||
name: Reusable workflow #### | ||
#### Comment | ||
name: 'Arch' | ||
description: 'TODO' #### | ||
inputs: | ||
os: | ||
description: "A username passed from the caller workflow" #### | ||
required: true | ||
type: string | ||
board: | ||
description: "A username passed from the caller workflow" #### | ||
required: true | ||
type: string | ||
outputs: | ||
skip_build: | ||
description: "Set to 1 if the build should be skipped" | ||
value: ${{ steps.get-arch.outputs.skip_build }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get arch | ||
id: get-arch | ||
run: | | ||
# Get the Labels for the PR: "Arch: risc-v \n Size: XS" | ||
pr=${{github.event.pull_request.number}} | ||
if [[ "$pr" == "" ]]; then | ||
exit | ||
fi | ||
numlabels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.[] | length') | ||
labels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.labels[] | .name') | ||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
description: "A username passed from the caller workflow" #### | ||
required: true | ||
type: string | ||
board: | ||
description: "A username passed from the caller workflow" #### | ||
required: true | ||
type: string | ||
outputs: | ||
skip_build: | ||
description: "Set to 1 if the build should be skipped" | ||
value: ${{ jobs.arch.outputs.skip_build }} | ||
# Identify the Size and Arch Labels | ||
if [[ "$labels" == *"Size: "* ]]; then | ||
labels_contain_size=1 | ||
fi | ||
if [[ "$labels" == *"Arch: arm"* ]]; then | ||
arch_contains_arm_arm64=1 | ||
fi | ||
if [[ "$labels" == *"Arch: risc-v"* ]]; then | ||
arch_contains_riscv=1 | ||
fi | ||
if [[ "$labels" == *"Arch: xtensa"* ]]; then | ||
arch_contains_xtensa=1 | ||
fi | ||
jobs: | ||
|
||
# Get the Arch for the PR: arm, arm64, risc-v, xtensa, ... | ||
arch: | ||
name: Generate output ### | ||
runs-on: ubuntu-latest | ||
outputs: | ||
skip_build: ${{ steps.get-arch.outputs.skip_build }} | ||
steps: | ||
- name: Get arch | ||
id: get-arch | ||
run: | | ||
# Get the Labels for the PR: "Arch: risc-v \n Size: XS" | ||
pr=${{github.event.pull_request.number}} | ||
if [[ "$pr" == "" ]]; then | ||
exit | ||
fi | ||
numlabels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.[] | length') | ||
labels=$(gh pr view $pr --repo $GITHUB_REPOSITORY --json labels --jq '.labels[] | .name') | ||
# Identify the Size and Arch Labels | ||
if [[ "$labels" == *"Size: "* ]]; then | ||
labels_contain_size=1 | ||
fi | ||
if [[ "$labels" == *"Arch: arm"* ]]; then | ||
arch_contains_arm_arm64=1 | ||
fi | ||
if [[ "$labels" == *"Arch: risc-v"* ]]; then | ||
arch_contains_riscv=1 | ||
fi | ||
if [[ "$labels" == *"Arch: xtensa"* ]]; then | ||
arch_contains_xtensa=1 | ||
fi | ||
# We consider only PRs with 2 labels, including size | ||
if [ $numlabels -ne 2 ] || [ $labels_contain_size -ne 1 ]; then | ||
exit | ||
fi | ||
# If "Arch: arm / arm64" is the only non-size label, then build other, arm-01, arm-02, ... | ||
if [[ "$arch_contains_arm_arm64" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "arm"* ]] || [[ "${{inputs.board}}" == "other"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
# We consider only PRs with 2 labels, including size | ||
if [ $numlabels -ne 2 ] || [ $labels_contain_size -ne 1 ]; then | ||
exit | ||
fi | ||
# If "Arch: arm / arm64" is the only non-size label, then build other, arm-01, arm-02, ... | ||
if [[ "$arch_contains_arm_arm64" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "arm"* ]] || [[ "${{inputs.board}}" == "other"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
fi | ||
# If "Arch: risc-v" is the only non-size label, then build risc-v-01, risc-v-02 | ||
if [[ "$arch_contains_riscv" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "risc-v"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
# If "Arch: risc-v" is the only non-size label, then build risc-v-01, risc-v-02 | ||
if [[ "$arch_contains_riscv" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "risc-v"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
fi | ||
# If "Arch: xtensa" is the only non-size label, then build xtensa-01, xtensa-02 | ||
if [[ "$arch_contains_xtensa" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "xtensa"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
# If "Arch: xtensa" is the only non-size label, then build xtensa-01, xtensa-02 | ||
if [[ "$arch_contains_xtensa" == "1" ]]; then | ||
if [[ "${{inputs.board}}" == "xtensa"* ]]; then | ||
echo Allow build: ${{inputs.board}} | ||
else | ||
echo Skip build: ${{inputs.board}} | ||
echo "skip_build=1" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |