diff --git a/.github/workflows/percy otp2.yml b/.github/workflows/percy otp2.yml new file mode 100644 index 000000000..40c12d462 --- /dev/null +++ b/.github/workflows/percy otp2.yml @@ -0,0 +1,33 @@ +name: Percy OTP2 + +on: + push: + branches: + - master + pull_request: + +jobs: + test-build-release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + # This allows us to work with the repository during the lint step + fetch-depth: 2 + - name: Use Node.js 16.x + uses: actions/setup-node@v1 + with: + node-version: 16.x + - name: Install npm packages using cache + uses: bahmutov/npm-install@v1 + - name: Download OTP2 config file + run: curl $PERCY_OTP2_CONFIG_URL --output /tmp/otp2config.yml + env: + PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_OTP2_CONFIG_URL }} + - name: Take Percy Snapshots + # Move everything from latest commit back to staged + run: npx percy exec -- npx jest percy/percy.test.js --force-exit + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} + PERCY_OTP_CONFIG_OVERRIDE: /tmp/otp2config.yml diff --git a/percy/percy.test.js b/percy/percy.test.js index d201e8b6a..711f5261e 100644 --- a/percy/percy.test.js +++ b/percy/percy.test.js @@ -54,7 +54,9 @@ beforeAll(async () => { ]) // grab ATL har file to tmp - await execa('curl', [process.env.HAR_URL, '-s', '--output', 'mock.har']) + if (process.env.HAR_URL) { + await execa('curl', [process.env.HAR_URL, '-s', '--output', 'mock.har']) + } } catch (error) { console.log(error) } @@ -66,9 +68,11 @@ beforeAll(async () => { }).stdout.pipe(process.stdout) // Launch mock OTP server - execa('yarn', ['percy-har-express', '-p', '9999', 'mock.har'], { - signal: harAbortController.signal - }).stdout.pipe(process.stdout) + if (process.env.HAR_URL) { + execa('yarn', ['percy-har-express', '-p', '9999', 'mock.har'], { + signal: harAbortController.signal + }).stdout.pipe(process.stdout) + } // Web security is disabled to allow requests to the mock OTP server browser = await puppeteer.launch({