From 862832341276448029ae74c8d89bfa53023b2398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 17 Mar 2025 13:15:10 +0100 Subject: [PATCH 1/2] wip --- .github/workflows/validate.yaml | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 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..5b7b3ac --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,77 @@ + +on: + pull_request: + types: [labeled] + +permissions: + pull-requests: write + +# Ensures that multiple validation job runs do not execute concurrently on the same PR. +# If a new run is triggered, any in-progress run for the same group is canceled. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + multiple-labels: + name: 'Check that only one validation label is applied' + if: > + contains(fromJSON('["run-full-validation", "run-full-validation-long", "run-quick-validation"]').*, + github.event.pull_request.labels.*.name) > 1 + # if: > + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')) || + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) || + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) + runs-on: ubuntu-latest + steps: + - env: + GH_TOKEN: ${{ secrets.GH_PAT }} + run: | + echo "Multiple validation labels detected. Removing labels..." + + # Remove appropriate labels based on which ones are present + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') }}" == "true" ]]; then + gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation-long" + fi + + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation') }}" == "true" ]]; then + gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation" + fi + + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then + gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-quick-validation" + fi + + echo "Completed label cleanup" + exit 1 + + + validate: + name: 'Validate Changed Packages - Github Hosted' + runs-on: ubuntu-latest + if: > + contains(github.event.pull_request.labels.*.name, 'run-full-validation') || + contains(github.event.pull_request.labels.*.name, 'run-quick-validation') + # if: > + # contains(github.event.pull_request.labels.*.name, 'run-full-validation') && + # !contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') + + steps: + - name: Run Validation Script + run: | + echo "Running validation because 'full validation' label was added" + # Add your validation logic here (e.g., linting, testing) + + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then + # Perform validation in 'Individual" mode + echo "Running Quick Validation..." + else + Perform validation in 'Thorough' mode + echo "Running Full Validation..." + fi + + sleep 5 + exit 0 + + \ No newline at end of file From 052b0eee985c10b727543ed02ddcfab94b3acadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20K=C3=B6r?= Date: Mon, 17 Mar 2025 17:07:00 +0100 Subject: [PATCH 2/2] wip --- .github/workflows/validate.yaml | 56 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 5b7b3ac..f1f5c2b 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -15,36 +15,44 @@ concurrency: jobs: multiple-labels: - name: 'Check that only one validation label is applied' - if: > - contains(fromJSON('["run-full-validation", "run-full-validation-long", "run-quick-validation"]').*, - github.event.pull_request.labels.*.name) > 1 - # if: > - # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')) || - # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) || - # (contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) runs-on: ubuntu-latest steps: - - env: - GH_TOKEN: ${{ secrets.GH_PAT }} + - name: Check Labels run: | - echo "Multiple validation labels detected. Removing labels..." - - # Remove appropriate labels based on which ones are present - if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') }}" == "true" ]]; then - gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation-long" + COUNT=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq '[.[] | select(.name | test("run-full-validation|run-full-validation-long|run-quick-validation"))] | length') + if [[ "$COUNT" -gt 1 ]]; then + echo "More than one validation label found. Failing the job." + exit 1 fi + shell: bash + # multiple-labels: + # name: 'Check that only one validation label is applied' + # if: > + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-full-validation-long')) || + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) || + # (contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') && contains(github.event.pull_request.labels.*.name, 'run-quick-validation')) + # runs-on: ubuntu-latest + # steps: + # - env: + # GH_TOKEN: ${{ secrets.GH_PAT }} + # run: | + # echo "Multiple validation labels detected. Removing labels..." + + # # Remove appropriate labels based on which ones are present + # if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation-long') }}" == "true" ]]; then + # gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation-long" + # fi - if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation') }}" == "true" ]]; then - gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation" - fi + # if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-full-validation') }}" == "true" ]]; then + # gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-full-validation" + # fi - if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then - gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-quick-validation" - fi + # if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-quick-validation') }}" == "true" ]]; then + # gh pr edit ${{ github.event.pull_request.number }} --repo $GITHUB_REPOSITORY --remove-label "run-quick-validation" + # fi - echo "Completed label cleanup" - exit 1 + # echo "Completed label cleanup" + # exit 1 validate: @@ -67,7 +75,7 @@ jobs: # Perform validation in 'Individual" mode echo "Running Quick Validation..." else - Perform validation in 'Thorough' mode + # Perform validation in 'Thorough' mode echo "Running Full Validation..." fi