From 34643e4c0821aeb8d6977c1942bc106c9363789a Mon Sep 17 00:00:00 2001 From: "JeongHoon Byun (a.k.a Outsider)" Date: Sun, 4 Apr 2021 19:49:25 +0900 Subject: [PATCH] Run browser tests on forked PRs by a dedicated label (#4616) * ci: don't run browser tests on forked PRs * ci: browser tests workflow for forked PRs * ci: remove the label after running browser test * ci: fyx typos and remove commnets --- .github/workflows/browser-test.yml | 41 ++++++++++++++++++++++++++++++ .github/workflows/mocha.yml | 2 ++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/browser-test.yml diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml new file mode 100644 index 0000000000..a06bdaf70d --- /dev/null +++ b/.github/workflows/browser-test.yml @@ -0,0 +1,41 @@ +name: Browser Tests for forked PRs +'on': + pull_request_target: + types: + - labeled + +jobs: + test-browser: + # TODO: configure to retain build artifacts in `.karma/` dir + name: 'Browser Tests' + timeout-minutes: 20 + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'run-browser-test') + steps: + - uses: actions/setup-node@v2 + with: + node-version: 14 + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: 'Cache node_modules' + uses: actions/cache@v2 + with: + path: '~/.npm' + key: "ubuntu-latest-node-full-v14-${{ hashFiles('**/package-lock.json') }}" + restore-keys: | + ubuntu-latest-node-full-v14- + - name: Install Dependencies + run: npm ci + - name: Run Browser Tests + run: npm start test.browser + env: + SAUCE_USERNAME: '${{secrets.SAUCE_USERNAME}}' + SAUCE_ACCESS_KEY: '${{secrets.SAUCE_ACCESS_KEY}}' + - name: remove 'run-browser-test' label + uses: buildsville/add-remove-label@v1 + if: ${{ always() }} + with: + token: ${{secrets.GITHUB_TOKEN}} + label: run-browser-test + type: remove diff --git a/.github/workflows/mocha.yml b/.github/workflows/mocha.yml index 4857876bdc..bd05376b69 100644 --- a/.github/workflows/mocha.yml +++ b/.github/workflows/mocha.yml @@ -174,6 +174,8 @@ jobs: needs: smoke timeout-minutes: 20 runs-on: ubuntu-latest + # Run 'push' event only because of sauce labs token + if: github.event_name == 'push' steps: - uses: actions/setup-node@v2 with: