Skip to content

Commit

Permalink
Use labels to adjust CI behavior (#3766)
Browse files Browse the repository at this point in the history
* draft label-based-builds

Signed-off-by: MarkAckert <[email protected]>

* build label processing

Signed-off-by: MarkAckert <[email protected]>

* build: none short-circuit

Signed-off-by: MarkAckert <[email protected]>

* Change test label to silly

Signed-off-by: MarkAckert <[email protected]>

* better log message

Signed-off-by: MarkAckert <[email protected]>

* update pr comment trigger conditional

Signed-off-by: MarkAckert <[email protected]>

* support issue comment checkout

Signed-off-by: MarkAckert <[email protected]>

* update ci trigger, label detection test

Signed-off-by: MarkAckert <[email protected]>

* add debug statements

Signed-off-by: MarkAckert <[email protected]>

* correct syntax, another logic debug statement

Signed-off-by: MarkAckert <[email protected]>

* more debug

Signed-off-by: MarkAckert <[email protected]>

* fix if condition

Signed-off-by: MarkAckert <[email protected]>

* defensive quotes for empty vars

Signed-off-by: MarkAckert <[email protected]>

* conditional updates and debug

Signed-off-by: MarkAckert <[email protected]>

* re-order debug and comment check

Signed-off-by: MarkAckert <[email protected]>

* make condition truth more explicit (result is a string type?)

Signed-off-by: MarkAckert <[email protected]>

* painful debugging

Signed-off-by: MarkAckert <[email protected]>

* set conditions in a separate step

Signed-off-by: MarkAckert <[email protected]>

* cleanup unused vars

Signed-off-by: MarkAckert <[email protected]>

* remove debug statements

Signed-off-by: MarkAckert <[email protected]>

* fix missing quotes in 6a

Signed-off-by: MarkAckert <[email protected]>

* add inputs_build vars to 6a

Signed-off-by: MarkAckert <[email protected]>

* Update jobname

Signed-off-by: MarkAckert <[email protected]>

---------

Signed-off-by: MarkAckert <[email protected]>
  • Loading branch information
MarkAckert authored Mar 22, 2024
1 parent 5bdd3b4 commit fa2ec5b
Showing 1 changed file with 92 additions and 8 deletions.
100 changes: 92 additions & 8 deletions .github/workflows/build-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
- v2.x/staging
pull_request:
types: [opened, synchronize]
issue_comment:
types: [created, edited]

workflow_dispatch:
inputs:
Expand Down Expand Up @@ -41,6 +43,38 @@ on:
type: string

jobs:

pr-comment-check:

name: 'PR Comment Check'
runs-on: ubuntu-latest
outputs:
issue_run_ci: ${{ steps.check-comment.outputs.issue_run_ci }}
steps:
- name: Check for a comment triggering a build
id: check-comment
run: |
echo "issue_run_ci=false" >> $GITHUB_OUTPUT
if [[ ! -z "${{ github.event.issue.pull_request }}" && ${{ github.event_name == 'issue_comment' }} && "${{ github.event.comment.body }}" = '/ci' ]]; then
echo "issue_run_ci=true" >> $GITHUB_OUTPUT
fi
set-run-conditions:
runs-on: ubuntu-latest
needs: pr-comment-check
outputs:
should-build: ${{ steps.check-build.outputs.run_build }}
should-test: ${{ steps.check-test.outputs.run_test}}
steps:
- id: check-build
name: 'export conditional used to determine if we should run a build'
run: |
echo "run_build=${{ (github.event_name != 'issue_comment' || needs.pr-comment-check.outputs.issue_run_ci == 'true') && (github.event_name == 'workflow_dispatch' || !contains(github.event.pull_request.labels.*.name, 'Build: None')) }}" >> $GITHUB_OUTPUT
- id: check-test
name: 'export conditional used to determine if we should run a test suite'
run: |
echo "run_test=${{ ( github.event_name == 'push' && contains(github.ref, 'staging') ) || ( (github.event_name == 'pull_request' || github.event_name == 'issue_comment') && !contains(github.event.pull_request.labels.*.name, 'Build: None') && !contains(github.event.pull_request.labels.*.name, 'Test: None') ) }}" >> $GITHUB_OUTPUT
display-dispatch-event-id:
if: github.event.inputs.RANDOM_DISPATCH_EVENT_ID != ''
runs-on: ubuntu-latest
Expand All @@ -56,13 +90,17 @@ jobs:
uses: zowe-actions/shared-actions/permission-check@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

regular-build:

if: ${{ needs.set-run-conditions.outputs.should-build == 'true' }}
runs-on: ubuntu-latest
needs: check-permission
needs: [set-run-conditions, check-permission]
steps:
- name: '[Prep 1] Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}

- name: '[Prep 2] Setup jFrog CLI'
uses: jfrog/setup-jfrog-cli@v2
Expand Down Expand Up @@ -112,10 +150,37 @@ jobs:
console.error('Cannot read manifest or manifest is invalid.');
}
- name: '[Prep 6] Process github.event.inputs'
id: process-inputs
- name: '[Prep 6a] Process labels for ci build (pull, push, comment)'
id: process-labels
if: github.event_name != 'workflow_dispatch'
run: |
BUILD_WHAT="PAX"
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Build: PSWI') }}" == "true" ]]; then
echo INPUTS_BUILD_PSWI=true >> $GITHUB_ENV
echo INPUTS_BUILD_SMPE=true >> $GITHUB_ENV
BUILD_WHAT=$BUILD_WHAT", SMPE, PSWI"
else
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Build: SMPE') }}" == "true" ]]; then
echo INPUTS_BUILD_SMPE=true >> $GITHUB_ENV
BUILD_WHAT=$BUILD_WHAT", SMPE"
fi
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Build: Kubernetes') }}" == "true" ]]; then
echo INPUTS_BUILD_KUBERNETES=true >> $GITHUB_ENV
BUILD_WHAT=$BUILD_WHAT", K8S"
fi
echo "INPUTS_KEEP_TEMP_PAX_FOLDER=${{ contains(github.event.pull_request.labels.*.name, 'Build: Debug-Remote') }}" >> $GITHUB_ENV
echo BUILD_WHAT=$BUILD_WHAT >> $GITHUB_OUTPUT
- name: '[Prep 6b] Process github.event.inputs for manually triggered build'
id: process-inputs
if: github.event_name == 'workflow_dispatch'
run: |
BUILD_WHAT="${{ steps.process-labels.outputs.BUILD_WHAT_LABELS }}"
echo INPUTS_BUILD_PSWI=${{ github.event.inputs.BUILD_PSWI }} >> $GITHUB_ENV
if [[ "${{ github.event.inputs.BUILD_PSWI }}" == true ]]; then
Expand Down Expand Up @@ -327,9 +392,11 @@ jobs:
# only run auto integration tests when the workflow is triggered by pull request
# default running Convenience Pax on any zzow server
call-integration-test:
needs: regular-build

needs: [set-run-conditions, regular-build]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(github.ref, 'staging'))
if: ${{ needs.set-run-conditions.outputs.should-test == 'true' }}

steps:
- name: 'Determine branch name'
run: |
Expand All @@ -339,6 +406,23 @@ jobs:
echo "BRANCH_NAME=$(echo ${GITHUB_REF_NAME})" >> $GITHUB_ENV
fi
- name: 'Determine test suite'
id: get-test-suite
run: |
TEST_SUITE="Convenience Pax"
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Test: Basic') }}" = "true" ]]; then
TEST_SUITE="Convenience Pax"
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'Test: SMPE') }}" = "true" ]]; then
TEST_SUITE="SMPE PTF"
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'Test: Extended') }}" = "true" ]]; then
TEST_SUITE="Zowe Nightly Tests"
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'Test: Silly') }}" = "true" ]]; then
TEST_SUITE="Zowe Release Tests"
else
echo "Unknown test label encountered; defaulting to 'Test: Basic' and running Convenience Pax tests."
fi
echo "TEST_SUITE=$TEST_SUITE" >> $GITHUB_OUTPUT
- name: 'Call test workflow'
uses: zowe-actions/shared-actions/workflow-remote-call-wait@main
id: call-test
Expand All @@ -349,7 +433,7 @@ jobs:
workflow-filename: cicd-test.yml
branch-name: ${{ env.BRANCH_NAME }}
poll-frequency: 3
inputs-json-string: '{"custom-zowe-artifactory-pattern-or-build-number":"${{ github.run_number }}"}'
inputs-json-string: '{"custom-zowe-artifactory-pattern-or-build-number":"${{ github.run_number }}", "install-test": "${{ steps.get-test-suite.outputs.TEST_SUITE }}"}'
# env:
# DEBUG: 'workflow-remote-call-wait'

Expand Down

0 comments on commit fa2ec5b

Please sign in to comment.