From f1160d284ff7b29681fefbbd2ff9d7a2423e585a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 10:46:44 +0100 Subject: [PATCH 1/7] Renove all workflows from main --- .github/workflows/nightly.yaml | 41 --------- .github/workflows/validate.yaml | 152 -------------------------------- 2 files changed, 193 deletions(-) delete mode 100644 .github/workflows/nightly.yaml delete mode 100644 .github/workflows/validate.yaml diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml deleted file mode 100644 index 4d2c538..0000000 --- a/.github/workflows/nightly.yaml +++ /dev/null @@ -1,41 +0,0 @@ -name: Nightly Build -on: - workflow_dispatch: - # schedule: - # - cron: "0 0 * * *" - -jobs: - full-validation: - runs-on: ubuntu-latest - environment: DEV - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Run tests (controlled via environment variable) - run: | - echo "Running nightly tests..." - echo "TEST_RESULT_OVERRIDE: ${{ vars.TEST_RESULT_OVERRIDE }}" - - if [ -n "${{ vars.TEST_RESULT_OVERRIDE }}" ]; then - if [ "${{ vars.TEST_RESULT_OVERRIDE }}" == "pass" ]; then - echo "Tests passed by override (via environment)!" - exit 0 - elif [ "${{ vars.TEST_RESULT_OVERRIDE }}" == "fail" ]; then - echo "Tests failed by override (via environment)!" - exit 1 - fi - else - echo "Random test result mode..." - if [ $((RANDOM % 2)) -eq 0 ]; then - echo "Tests passed!" - exit 0 - else - echo "Tests failed!" - exit 1 - fi - fi - - - name: Mark workflow as successful - if: success() - run: echo "Tests passed successfully!" \ No newline at end of file diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml deleted file mode 100644 index 843446c..0000000 --- a/.github/workflows/validate.yaml +++ /dev/null @@ -1,152 +0,0 @@ -name: 'PR Review Comment' - -on: - issue_comment: - types: [created, edited] - -jobs: - sfp-validate-pool: - runs-on: ubuntu-latest - permissions: - pull-requests: write - if: > - github.event.issue.pull_request && - ( - contains(github.event.comment.body, '/quick-validation') || - contains(github.event.comment.body, '/full-validation') - ) - steps: - - name: Fetch Branch Name - id: fetch-branch-name - uses: xt0rted/pull-request-comment-branch@v2 - - - name: Check out code from ${{ steps.fetch-branch-name.outputs.head_ref }} - uses: actions/checkout@v3 - with: - ref: ${{ steps.fetch-branch-name.outputs.head_ref }} - - - name: Process PR Comment - id: process-comment - run: | - COMMENT_ID="${{ github.event.comment.id }}" - COMMENT_BODY="${{ github.event.comment.body }}" - echo "COMMENT_ID: $COMMENT_ID" - echo "COMMENT_BODY: $COMMENT_BODY" - echo "::set-output name=comment-id::$COMMENT_ID" - if [[ "$COMMENT_BODY" == *"/quick-validation"* ]]; then - echo "::set-output name=validation-type::quick" - elif [[ "$COMMENT_BODY" == *"/full-validation"* ]]; then - echo "::set-output name=validation-type::full" - fi - - # - name: Checkout - # uses: actions/checkout@v3 - - - name: Run Validation - id: validate - run: | - if [[ "${{ steps.process-comment.outputs.validation-type }}" == "quick" ]]; then - echo "Running Quick Validation..." - sleep 5 # Simulate quick validation - echo "Quick Validation Successful" > result.txt - elif [[ "${{ steps.process-comment.outputs.validation-type }}" == "full" ]]; then - echo "Running Full Validation..." - sleep 60 # Simulate full validation - echo "Full Validation Successful" > result.txt - fi - continue-on-error: true - - - name: Post Validation Status to PR - uses: mshick/add-pr-comment@v2 - with: - message: | - Validation run completed: **${{ steps.process-comment.outputs.validation-type }}** - Status: ${{ steps.validate.outcome == 'success' && '✅ Success' || '❌ Failed' }} - [View the workflow run here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - - - - - - - - - - - - - - - - - -# name: Validate and Run Commands Based on PR Labels - -# on: -# pull_request: -# types: [opened, synchronize, labeled, unlabeled] - -# jobs: -# validate-and-execute: -# 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 -# run: | -# echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}" \ No newline at end of file From 4dbb45183e400dda3c7daf6f4baf2f72c3c5f33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 12:25:18 +0100 Subject: [PATCH 2/7] Testing phase1 --- .github/workflows/validate.yaml | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/validate.yaml diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..71fd9c3 --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,53 @@ + +on: + pull_request: + # types: [opened, synchronize, reopened, labeled, unlabeled] + types: [labeled] + pull_request_target: + types: [labeled] + + +permissions: + issues: write # Allows the token to modify issues (needed for label management) + pull-requests: write # Allows the token to interact with pull requests + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + validate: + name: 'Validate Changed Packages' + if: contains(github.event.pull_request.labels.*.name, 'full validation') + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run Validation Script + run: | + echo "Running validation because 'full validation' label was added" + # Add your validation logic here (e.g., linting, testing) + + remove-label: + needs: validate + if: always() # Ensures this runs even if validation fails + runs-on: ubuntu-latest + + steps: + - name: Remove 'needs-validation' label + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + REPO=${{ github.repository }} + LABEL="full validation" + ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g') + + echo $ENCODED_LABEL + echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL" + curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}" \ No newline at end of file From a8dfee422526692fd8412ecec5dde47760c164e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 12:26:30 +0100 Subject: [PATCH 3/7] Testing phase1-b --- .github/workflows/validate.yaml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 71fd9c3..ab46d6b 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -33,13 +33,11 @@ jobs: echo "Running validation because 'full validation' label was added" # Add your validation logic here (e.g., linting, testing) - remove-label: - needs: validate - if: always() # Ensures this runs even if validation fails - runs-on: ubuntu-latest + # Simulate failure + exit 1 - steps: - name: Remove 'needs-validation' label + if: always() run: | PR_NUMBER=${{ github.event.pull_request.number }} REPO=${{ github.repository }} @@ -50,4 +48,23 @@ jobs: echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL" curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}" \ No newline at end of file + "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}" + +# remove-label: +# needs: validate +# if: always() # Ensures this runs even if validation fails +# runs-on: ubuntu-latest + +# steps: +# - name: Remove 'needs-validation' label +# run: | +# PR_NUMBER=${{ github.event.pull_request.number }} +# REPO=${{ github.repository }} +# LABEL="full validation" +# ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g') + +# echo $ENCODED_LABEL +# echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL" +# curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ +# -H "Accept: application/vnd.github.v3+json" \ +# "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}" \ No newline at end of file From 5f533d1b0d4e5964b664e7ad11d32983abe1c9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 12:30:20 +0100 Subject: [PATCH 4/7] Testing phase1-b --- .github/workflows/validate.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index ab46d6b..bf29475 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -33,6 +33,8 @@ jobs: echo "Running validation because 'full validation' label was added" # Add your validation logic here (e.g., linting, testing) + sleep 30 + # Simulate failure exit 1 From 8f5a4448a2a9273082415cd15cf477c6e3b627a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 12:34:52 +0100 Subject: [PATCH 5/7] Testing phase1-b --- .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 bf29475..b9fa397 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -36,7 +36,7 @@ jobs: sleep 30 # Simulate failure - exit 1 + exit 0 - name: Remove 'needs-validation' label if: always() From 44498f153114f9707c455ddba279cbebcea2cf22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 13:57:01 +0100 Subject: [PATCH 6/7] Testing phase1-b --- .github/workflows/validate.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index b9fa397..3cf42ed 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -1,11 +1,7 @@ on: pull_request: - # types: [opened, synchronize, reopened, labeled, unlabeled] types: [labeled] - pull_request_target: - types: [labeled] - permissions: issues: write # Allows the token to modify issues (needed for label management) @@ -38,15 +34,16 @@ jobs: # Simulate failure exit 0 - - name: Remove 'needs-validation' label + - name: Remove label if: always() run: | PR_NUMBER=${{ github.event.pull_request.number }} REPO=${{ github.repository }} LABEL="full validation" + + # URL-encodes the label by replacing special characters with their percent-encoded equivalents. ENCODED_LABEL=$(printf "%s" "$LABEL" | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g') - echo $ENCODED_LABEL echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL" curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ From 5916f6eebbbd16a3a7a1e91a8b41d1c027c9c561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Fri, 31 Jan 2025 14:00:14 +0100 Subject: [PATCH 7/7] Testing phase1-b --- .github/workflows/validate.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 3cf42ed..584d2c2 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -4,8 +4,7 @@ on: types: [labeled] permissions: - issues: write # Allows the token to modify issues (needed for label management) - pull-requests: write # Allows the token to interact with pull requests + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -29,9 +28,7 @@ jobs: echo "Running validation because 'full validation' label was added" # Add your validation logic here (e.g., linting, testing) - sleep 30 - - # Simulate failure + sleep 10 exit 0 - name: Remove label