Skip to content

Commit

Permalink
PR label test
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-h committed Jan 30, 2024
1 parent e827feb commit 5fcfaa8
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions .github/workflows/test-hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,42 @@ concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.number }}
cancel-in-progress: true

#
# https://stackoverflow.com/questions/59882715/use-environment-variable-in-github-action-if
# https://stackoverflow.com/questions/75844035/github-action-how-to-reference-env-variable-in-the-job-and-step-if-condition

env:
IS_LABEL_BUILD: ${{ (github.event.action == 'labeled' &&
github.event.label.name == 'hw-build') ||
(github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'hw-build')) }}
IS_LABEL_RUN: ${{ (github.event.action == 'labeled' &&
github.event.label.name == 'hw-test') ||
(github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'hw-test')) }}


jobs:
check_labels:
outputs:
build: ${{ (github.event.action == 'labeled' &&
github.event.label.name == 'hw-build') ||
(github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'hw-build')) }}
run: ${{ (github.event.action == 'labeled' &&
github.event.label.name == 'hw-test') ||
(github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'hw-test')) }}
steps:
- id: dummy

code:
name: Freeze Code
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' ||
github.event_name == 'pull_request_target' &&
github.event.action != 'labeled' &&
(contains(github.event.pull_request.labels.*.name, 'hw-build') ||
contains(github.event.pull_request.labels.*.name, 'hw-test')) ||
github.event_name == 'pull_request_target' &&
github.event.action == 'labeled' &&
(github.event.label.name == 'hw-build' ||
github.event.label.name == 'hw-test') }}
needs: [check_labels]
if: ${{ fromJSON(needs.check_labels.outputs.build) ||
fromJSON(needs.check_labels.outputs.run) }}

outputs:
xml: ${{ steps.repo.outputs.xml }}
steps:
Expand All @@ -55,7 +78,7 @@ jobs:

build:
name: Build
needs: code
needs: [code]
runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand All @@ -75,15 +98,9 @@ jobs:
run:
name: Hardware
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.check_labels.outputs.run) &&
github.repository_owner == 'seL4' }}
needs: [build]
if: ${{ github.repository_owner == 'seL4' &&
(github.event_name == 'push' ||
github.event_name == 'pull_request_target' &&
github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'hw-test') ||
github.event_name == 'pull_request_target' &&
github.event.action == 'labeled' &&
github.event.label.name == 'hw-test') }}
strategy:
fail-fast: true
matrix:
Expand Down

0 comments on commit 5fcfaa8

Please sign in to comment.