From 4a92b76df33946cacf6504c9ad0270551795f5b7 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 1 Sep 2022 11:17:06 -0700 Subject: [PATCH 1/2] ci(screener): disable screener PR checks --- .github/workflows/pr-screener.yml | 41 ++----------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/.github/workflows/pr-screener.yml b/.github/workflows/pr-screener.yml index eab09394663..a250f9c13b4 100644 --- a/.github/workflows/pr-screener.yml +++ b/.github/workflows/pr-screener.yml @@ -1,10 +1,6 @@ name: Screener on: - pull_request: - branches: [master] - # need to run on the base branch when merging to keep the baseline state up to date - push: - branches: [master] + workflow_dispatch: jobs: screenshot_tests: runs-on: ubuntu-latest @@ -12,48 +8,15 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: skip for markdown only prs - id: one - run: | - current_branch=$(git rev-parse --abbrev-ref HEAD) - echo "branch: $current_branch" - if [ "$current_branch" == "master" ]; then - # diff of last commit excluding md (assumes squash merge) - screenable_changes=$(git diff --name-only @~..@ -- . ':(exclude)*.md*') - echo "push run" - else - # diff of branch excluding md - screenable_changes=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" origin/master) -- . ':(exclude)*.md*') - echo "pr run" - fi - echo "changed files: $screenable_changes" - # skip if there are only md changes - if [ -z "$screenable_changes" ]; then - echo "skip screener" - echo "::set-output name=skip::skip" - else - echo "run screener" - echo "::set-output name=skip::screen" - fi - uses: actions/setup-node@v2 with: node-version: lts/* cache: npm - run: npm ci --legacy-peer-deps - - if: steps.one.outputs.skip == 'screen' - name: run screener check + - name: run screener check env: SCREENER_API_KEY: ${{ secrets.SCREENER_API_KEY }} COMMIT_SHA: ${{github.event.pull_request.head.sha || github.sha}} SAUCE_ACCESS_NAME: ${{ secrets.SAUCE_ACCESS_NAME}} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} run: npm run test:storybook || true - - if: steps.one.outputs.skip == 'skip' - name: skip screener - uses: Sibz/github-status-action@v1 - with: - authToken: ${{ secrets.GITHUB_TOKEN }} - context: screener - description: Screener run skipped (markdown PRs) - state: success - sha: ${{github.event.pull_request.head.sha || github.sha}} From 4f9e503dc45396c7e36360e1a348b14dad568222 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 1 Sep 2022 19:10:59 -0700 Subject: [PATCH 2/2] skip screener using label and only run on ready for review event --- .github/workflows/pr-screener.yml | 54 ++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-screener.yml b/.github/workflows/pr-screener.yml index a250f9c13b4..fdefeba3672 100644 --- a/.github/workflows/pr-screener.yml +++ b/.github/workflows/pr-screener.yml @@ -1,22 +1,74 @@ name: Screener on: workflow_dispatch: + pull_request: + branches: [master] + types: [ready_for_review] + # need to run on the base branch when merging to keep the baseline state up to date + push: + branches: [master] jobs: screenshot_tests: + if: "!contains(github.event.pull_request.labels.*.name, 'pr has no visual changes') && github.actor!='dependabot-preview[bot]'" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 + - name: skip for markdown only prs + id: one + run: | + current_branch=$(git rev-parse --abbrev-ref HEAD) + echo "branch: $current_branch" + if [ "$current_branch" == "master" ]; then + # diff of last commit excluding md (assumes squash merge) + screenable_changes=$(git diff --name-only @~..@ -- . ':(exclude)*.md*') + echo "push run" + else + # diff of branch excluding md + screenable_changes=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" origin/master) -- . ':(exclude)*.md*') + echo "pr run" + fi + echo "changed files: $screenable_changes" + # skip if there are only md changes + if [ -z "$screenable_changes" ]; then + echo "skip screener" + echo "::set-output name=skip::skip" + else + echo "run screener" + echo "::set-output name=skip::screen" + fi - uses: actions/setup-node@v2 with: node-version: lts/* cache: npm - run: npm ci --legacy-peer-deps - - name: run screener check + - if: steps.one.outputs.skip == 'screen' + name: run screener check env: SCREENER_API_KEY: ${{ secrets.SCREENER_API_KEY }} COMMIT_SHA: ${{github.event.pull_request.head.sha || github.sha}} SAUCE_ACCESS_NAME: ${{ secrets.SAUCE_ACCESS_NAME}} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} run: npm run test:storybook || true + - if: steps.one.outputs.skip == 'skip' + name: skip screener for markdown PRs + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + context: screener + description: Screener run skipped (markdown PRs) + state: success + sha: ${{github.event.pull_request.head.sha || github.sha}} + skip_screenshot_tests: + if: "contains(github.event.pull_request.labels.*.name, 'pr has no visual changes') || github.actor=='dependabot-preview[bot]'" + runs-on: ubuntu-latest + steps: + - name: skip screener for dependabot PRs or no visual changes + uses: Sibz/github-status-action@v1 + with: + authToken: ${{ secrets.GITHUB_TOKEN }} + context: screener + description: Screener run skipped (no visual changes or dependabot PR) + state: success + sha: ${{github.event.pull_request.head.sha || github.sha}}