From 9e5958cbb0071e533d412672616affa0c8104c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 11:15:18 +0100 Subject: [PATCH 1/5] Add a workflow to simulate quick validation with required full validation check --- .github/workflows/validate.yaml | 88 +++++++++++---------------------- 1 file changed, 30 insertions(+), 58 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index d748890..6954d5e 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -1,69 +1,41 @@ -name: Validate and Run Commands Based on PR Labels - +name: PR Validation on: pull_request: types: [opened, synchronize, labeled, unlabeled] + branches: + - main jobs: - validate-and-execute: + last-full-validation-status: + runs-on: ubuntu-latest + steps: + - name: Get Last Full Validation Status + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const { owner, repo } = context.repo; + const runs = await github.rest.actions.listWorkflowRuns({ + owner, + repo, + workflow_id: 'nightly.yaml', + branch: 'main', + status: 'completed' + }); + if (runs.data.workflow_runs.length === 0) { + core.setFailed('No successful nightly runs found.'); + } else if (runs.data.workflow_runs[0].conclusion !== 'success') { + core.setFailed(`Last nightly run failed. See: ${runs.data.workflow_runs[0].html_url}`); + } + + quick-validation: + needs: last-full-validation-status runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v3 - # - name: Get PR Labels - # id: get-labels - # uses: actions/github-script@v6 - # with: - # script: | - # const labels = context.payload.pull_request.labels.map(label => label.name); - # return labels; - # result-encoding: string - - # - name: Determine Validation Type - # id: determine-validation-mode - # run: | - # labels="${{ steps.get-labels.outputs.result }}" - - # validation_mode="thorough" - # if echo "$labels" | grep -q "quick validation"; then - # validation_mode="individual" - # fi - - # echo "validation_mode=$validation_mode" | tee -a $GITHUB_OUTPUT - - # # Validate source and trigger test, skipping if there are no deployable changes - # - name: 'If deployable changes were made, push source to a scratch org' - # run: | - # labels="${{ steps.get-labels.outputs.result }}" - - # validation_mode="thorough" - # if echo "$labels" | grep -q "quick validation"; then - # validation_mode="individual" - # fi - # echo $validation_mode - - - name: Get SFP Pool Validation Mode from the PR labels - id: sfp-validation-mode - uses: actions/github-script@v7 - with: - script: | - - const labels = context.payload.pull_request.labels.map(label => label.name); - const hasQuickValidation = labels.includes('quick validation'); - const hasFullValidation = labels.includes('full validation'); - - let validationMode = 'thorough'; - - if (hasQuickValidation && !hasFullValidation) { - validationMode = 'individual'; - } - - console.log(`SFP Validation Mode: ${validationMode}`); - return validationMode; - result-encoding: string - - - name: Run Commands Based on the Validation Mode + - name: Run Quick Validation run: | - echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}" \ No newline at end of file + echo "Running quick validation:" + # Your quick validation steps here From 9b38fea1859149ea2ffd2af21f8329613b925c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 11:31:33 +0100 Subject: [PATCH 2/5] wip --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 6954d5e..46e343d 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -29,7 +29,7 @@ jobs: } quick-validation: - needs: last-full-validation-status + # needs: last-full-validation-status runs-on: ubuntu-latest steps: - name: Checkout code From 190e0b86f49d9bce7c3bddcbc061ed473515b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 16:02:37 +0100 Subject: [PATCH 3/5] 1 --- .github/workflows/validate.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 46e343d..dd84f52 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -38,4 +38,5 @@ jobs: - name: Run Quick Validation run: | echo "Running quick validation:" + sleep 300 # Your quick validation steps here From 9d613d05a68b24b58a626cab3a4f0d43952d9ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 16:06:57 +0100 Subject: [PATCH 4/5] Add concurrency --- .github/workflows/validate.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index dd84f52..33b02c7 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -5,6 +5,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: last-full-validation-status: runs-on: ubuntu-latest From 14fbc60441f380400cf0d8f491c4cfde9d9858bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 16:08:27 +0100 Subject: [PATCH 5/5] 2 --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 33b02c7..c8066d2 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -43,4 +43,4 @@ jobs: run: | echo "Running quick validation:" sleep 300 - # Your quick validation steps here + # Your quick validation steps here 2