From b5130292fb410d7416d4aebc909451a8d12a7dfd Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Wed, 7 Sep 2022 17:46:50 +0300 Subject: [PATCH 1/7] Skip screener checks for draft PRs with exception of appropriately labeled PRs --- .github/workflows/screener-build.yml | 66 ++++++++++++++++++++-------- .github/workflows/screener-run.yml | 23 ++++++++++ 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index b4873c6550d88..56cfbd19cc93e 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -1,11 +1,11 @@ name: Screener build on: - pull_request: push: branches: - - master - workflow_dispatch: + - main + pull_request: + types: [opened, reopened, synchronize, ready_for_review] env: DEPLOYHOST: 'fluentuipr.z22.web.core.windows.net' @@ -16,12 +16,6 @@ jobs: steps: - run: mkdir artifacts ########################################### - # Environment variables are passed as an artifact so that the run workflow - # can download and access them. There are two workflows used- `screener-build.yml` - # and `screener-run.yml` so that the screener checks can also be triggered by - # pull requests from forks. Note: This is a temporary change. - ########################################### - ########################################### # BROWSERSLIST_IGNORE_OLD_DATA = Prevents failures on CI when "caniuse-lite" becomes outdated # DEPLOYHOST = address of host for screener tests deployment # BUILD_BUILDID = unique ID of the workflow run within the repo @@ -36,6 +30,39 @@ jobs: BUILD_SOURCEBRANCH=${{ github.ref }} SCREENER_BUILD=1 EOT + + - name: Set env variables if there is not a PR + run: | + cat <> artifacts/environment + DEPLOYBASEPATH=heads/${{github.ref_name}} + DEPLOYURL=https://${{env.DEPLOYHOST}}/heads/${{github.ref_name}} + BUILD_SOURCEBRANCHNAME=${{ github.ref_name }} + EOT + if: github.event_name == 'push' + + - name: script_label + uses: actions/github-script@v6 + with: + script: | + let labels = await github.rest.issues.listLabelsOnIssue({ + issue_number: ${{github.event.pull_request.number}}, + owner: context.repo.owner, + repo: context.repo.repo + }); + console.log(labels); + let foundLabel = labels.data.find((label) => {return label.name == 'Ready for VR'}); + if(foundLabel === undefined) + core.exportVariable('SKIP_SCREENER', true); + if: github.event.pull_request.draft == true && github.event_name == 'pull_request' + + - run: echo "SKIP_SCREENER=${{env.SKIP_SCREENER}}" >> skip-screener + + - name: Upload environment variables artifact + uses: actions/upload-artifact@v3 + with: + name: skip-screener + path: skip-screener + ########################################### # SYSTEM_PULLREQUEST_TARGETBRANCH = target branch name # SYSTEM_PULLREQUEST_SOURCEBRANCH = source branch name @@ -56,24 +83,21 @@ jobs: DEPLOYURL=https://${{env.DEPLOYHOST}}/pull/${{github.event.pull_request.number}} BUILD_SOURCEBRANCHNAME='merge' EOT - if: ${{startsWith(github.ref, 'refs/pull/')}} - - - name: Set env variables if there is not a PR - run: | - cat <> artifacts/environment - DEPLOYBASEPATH=heads/${{github.ref_name}} - DEPLOYURL=https://${{env.DEPLOYHOST}}/heads/${{github.ref_name}} - BUILD_SOURCEBRANCHNAME=${{ github.ref_name }} - EOT - if: ${{!startsWith(github.ref, 'refs/pull/')}} + if: ${{env.SKIP_SCREENER == ''}} - name: Upload environment variables artifact uses: actions/upload-artifact@v3 with: name: env-artifact path: artifacts/environment + if: ${{env.SKIP_SCREENER == ''}} + + outputs: + SKIP_SCREENER: ${{env.SKIP_SCREENER}} screener-react-northstar: + if: needs.environment-upload.outputs.SKIP_SCREENER == '' + needs: environment-upload runs-on: 'ubuntu-latest' name: Screener @fluentui/react-northstar steps: @@ -137,6 +161,8 @@ jobs: if: ${{env.SKIP_SCREENER_BUILD == 'false'}} screener-react: + if: needs.environment-upload.outputs.SKIP_SCREENER == '' + needs: environment-upload runs-on: 'ubuntu-latest' name: Screener @fluentui/react steps: @@ -198,6 +224,8 @@ jobs: if: ${{env.SKIP_SCREENER_BUILD == 'false'}} screener-react-components: + if: needs.environment-upload.outputs.SKIP_SCREENER == '' + needs: environment-upload runs-on: 'ubuntu-latest' name: Screener @fluentui/react-components steps: diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 5173978050c8c..0b77f8724320a 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -9,7 +9,26 @@ on: env: AZURE_STORAGE_CONNECTION_STRING: ${{secrets.AZURE_STORAGE_CONNECTION_STRING}} jobs: + determine-if-skipping: + runs-on: 'ubuntu-latest' + steps: + - name: Download environment variables artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: learn-github-actions.yml + run_id: ${{github.event.workflow_run.id}} + name: skip-screener + + - name: Define env variable + run: | + var=$(head -1 skip-screener) + echo "$var" >> $GITHUB_ENV + outputs: + SKIP_SCREENER: ${{env.SKIP_SCREENER}} + screener-react-northstar: + if: needs.determine-if-skipping.outputs.SKIP_SCREENER == '' + needs: determine-if-skipping runs-on: 'ubuntu-latest' name: Screener @fluentui/react-northstar steps: @@ -87,6 +106,8 @@ jobs: SCREENER_API_KEY: ${{secrets.SCREENER_API_KEY}} screener-react: + if: needs.determine-if-skipping.outputs.SKIP_SCREENER == '' + needs: determine-if-skipping runs-on: 'ubuntu-latest' name: Screener @fluentui/react steps: @@ -161,6 +182,8 @@ jobs: SCREENER_API_KEY: ${{secrets.SCREENER_API_KEY}} screener-react-components: + if: needs.determine-if-skipping.outputs.SKIP_SCREENER == '' + needs: determine-if-skipping runs-on: 'ubuntu-latest' name: Screener @fluentui/react-components steps: From a960c3ca53e8614b0777586b6bf5d90bce2b3775 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Wed, 7 Sep 2022 17:51:27 +0300 Subject: [PATCH 2/7] Test labelled PR checks --- .github/workflows/screener-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 56cfbd19cc93e..fe57bfa62faaa 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -15,6 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - run: mkdir artifacts + ########################################### # BROWSERSLIST_IGNORE_OLD_DATA = Prevents failures on CI when "caniuse-lite" becomes outdated # DEPLOYHOST = address of host for screener tests deployment From 05afd521b05387abaa7f0ef17a9406e558b19c14 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Wed, 7 Sep 2022 19:02:12 +0300 Subject: [PATCH 3/7] Remove redundant log --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index fe57bfa62faaa..86dccfec499d3 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -50,7 +50,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo }); - console.log(labels); + let foundLabel = labels.data.find((label) => {return label.name == 'Ready for VR'}); if(foundLabel === undefined) core.exportVariable('SKIP_SCREENER', true); From 9c47dbc76d8f6d33001929959b51ef7ed5f24208 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 11:07:34 +0300 Subject: [PATCH 4/7] Make changes according to review --- .github/workflows/screener-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 86dccfec499d3..55639b2bae69e 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -41,7 +41,7 @@ jobs: EOT if: github.event_name == 'push' - - name: script_label + - name: Check if draft PR has 'Ready for VR' label uses: actions/github-script@v6 with: script: | @@ -54,7 +54,7 @@ jobs: let foundLabel = labels.data.find((label) => {return label.name == 'Ready for VR'}); if(foundLabel === undefined) core.exportVariable('SKIP_SCREENER', true); - if: github.event.pull_request.draft == true && github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && github.event.pull_request.draft == true - run: echo "SKIP_SCREENER=${{env.SKIP_SCREENER}}" >> skip-screener From 86332f3579fad4d9c201644d20fc6648ac626667 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 11:47:01 +0300 Subject: [PATCH 5/7] Update default branch name --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 55639b2bae69e..2af3f8a247b84 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -3,7 +3,7 @@ name: Screener build on: push: branches: - - main + - master pull_request: types: [opened, reopened, synchronize, ready_for_review] From 833ca1040d125bcb4d73816a2529c7a3f9595d1e Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 11:49:38 +0300 Subject: [PATCH 6/7] Additional check for setting env variables --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 2af3f8a247b84..adb8dc91db155 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -84,7 +84,7 @@ jobs: DEPLOYURL=https://${{env.DEPLOYHOST}}/pull/${{github.event.pull_request.number}} BUILD_SOURCEBRANCHNAME='merge' EOT - if: ${{env.SKIP_SCREENER == ''}} + if: github.event_name == 'pull_request' && ${{env.SKIP_SCREENER == ''}} - name: Upload environment variables artifact uses: actions/upload-artifact@v3 From 7860774fa978f666aa6432a6872cdce360b3110e Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 12:30:47 +0300 Subject: [PATCH 7/7] Fix check for setting env variables for PRs --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index adb8dc91db155..d5a294d64a3d7 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -84,7 +84,7 @@ jobs: DEPLOYURL=https://${{env.DEPLOYHOST}}/pull/${{github.event.pull_request.number}} BUILD_SOURCEBRANCHNAME='merge' EOT - if: github.event_name == 'pull_request' && ${{env.SKIP_SCREENER == ''}} + if: ${{ github.event_name == 'pull_request' && env.SKIP_SCREENER == ''}} - name: Upload environment variables artifact uses: actions/upload-artifact@v3