From 27d834b33a881ce79b98f7970cd423d2670560c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 09:50:24 +0100 Subject: [PATCH 1/2] Add nightly.yaml --- .github/workflows/labels.yaml | 1 + .github/workflows/nightly.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .github/workflows/nightly.yaml diff --git a/.github/workflows/labels.yaml b/.github/workflows/labels.yaml index 89ff7a3..d748890 100644 --- a/.github/workflows/labels.yaml +++ b/.github/workflows/labels.yaml @@ -49,6 +49,7 @@ jobs: 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'); diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 0000000..ee0ede5 --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,27 @@ +name: Nightly Build +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + full-validation: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run tests (random success/failure) + run: | + echo "Running nightly tests..." + if [ $((RANDOM % 2)) -eq 0 ]; then + echo "Tests passed!" + exit 0 + else + echo "Tests failed!" + exit 0 + fi + + - name: Mark workflow as successful + if: success() + run: echo "Tests passed successfully!" \ No newline at end of file From 0f53998e1dd125a5284e6e0ee7d04c151ed5f748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 20 Jan 2025 10:07:12 +0100 Subject: [PATCH 2/2] Add validate.yaml --- .github/workflows/labels.yaml | 69 --------------------------------- .github/workflows/validate.yaml | 41 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/labels.yaml create mode 100644 .github/workflows/validate.yaml diff --git a/.github/workflows/labels.yaml b/.github/workflows/labels.yaml deleted file mode 100644 index d748890..0000000 --- a/.github/workflows/labels.yaml +++ /dev/null @@ -1,69 +0,0 @@ -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 diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..3abc60e --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,41 @@ +name: PR Validation +on: + pull_request: + types: [opened, synchronize, labeled, unlabeled] + branches: + - main + +jobs: + check-full-validation: + runs-on: ubuntu-latest + steps: + - name: Check 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: check-full-validation + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run Quick Validation + run: | + echo "Running quick validation:" + # Your quick validation steps here