|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v2 |
| 11 | + |
| 12 | + - uses: actions/setup-node@v2 |
| 13 | + with: |
| 14 | + node-version: 14 |
| 15 | + |
| 16 | + - run: npm ci |
| 17 | + |
| 18 | + - run: >- |
| 19 | + npm run format && git diff --exit-code || (echo -e '\n\033[31mERROR:\033[0m |
| 20 | + Project is not formatted. Please run "npm run format".' && false) |
| 21 | + tests-local: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - uses: actions/setup-node@v2 |
| 28 | + with: |
| 29 | + node-version: 14 |
| 30 | + |
| 31 | + - name: Restore node_modules |
| 32 | + id: cache |
| 33 | + uses: actions/cache@v2 |
| 34 | + with: |
| 35 | + path: node_modules |
| 36 | + # Bump the number after `lit-element-2.x-node-modules` to force a |
| 37 | + # cache update. Note there are cache actions in other jobs in this |
| 38 | + # file that should all keep keys in sync. |
| 39 | + key: lit-element-2.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }} |
| 40 | + |
| 41 | + - name: NPM install |
| 42 | + if: steps.cache.outputs.cache-hit != 'true' |
| 43 | + run: npm ci |
| 44 | + |
| 45 | + - name: Install XVFB |
| 46 | + run: sudo apt-get install xvfb |
| 47 | + |
| 48 | + - name: Build |
| 49 | + run: npm run build |
| 50 | + |
| 51 | + - name: Test |
| 52 | + run: xvfb-run npx wct --npm |
| 53 | + |
| 54 | + tests-sauce: |
| 55 | + # We can't run Sauce tests on PRs from forked repos, since they don't have |
| 56 | + # access to secrets. |
| 57 | + if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository |
| 58 | + |
| 59 | + runs-on: ubuntu-latest |
| 60 | + |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v2 |
| 63 | + |
| 64 | + - uses: actions/setup-node@v2 |
| 65 | + with: |
| 66 | + node-version: 14 |
| 67 | + |
| 68 | + - name: Restore node_modules |
| 69 | + id: cache |
| 70 | + uses: actions/cache@v2 |
| 71 | + with: |
| 72 | + path: node_modules |
| 73 | + # Bump the number after `lit-element-2.x-node-modules` to force a |
| 74 | + # cache update. Note there are cache actions in other jobs in this |
| 75 | + # file that should all keep keys in sync. |
| 76 | + key: lit-element-2.x-node-modules-0-${{ runner.os }}-${{ hashFiles('package-lock.json') }} |
| 77 | + |
| 78 | + - name: NPM install |
| 79 | + if: steps.cache.outputs.cache-hit != 'true' |
| 80 | + run: npm ci |
| 81 | + |
| 82 | + - name: Build |
| 83 | + run: npm run build |
| 84 | + |
| 85 | + - name: Test |
| 86 | + env: |
| 87 | + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} |
| 88 | + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} |
| 89 | + # This list of browsers originally included 'os x 10.12/safari@10' and |
| 90 | + # 'Linux/firefox', but these browsers both time out after running all |
| 91 | + # tests. This doesn't happen locally, so I'm not sure what's different |
| 92 | + # in GitHub actions that would break this. |
| 93 | + run: > |
| 94 | + npx wct --npm |
| 95 | + -s 'windows 10/microsoftedge@15' |
| 96 | + -s 'windows 10/microsoftedge@17' |
| 97 | + -s 'windows 8.1/internet explorer@11' |
| 98 | + -s 'os x 10.11/safari@9' |
| 99 | + -s 'macos 10.13/safari@11' |
| 100 | + -s 'Linux/chrome@41' |
0 commit comments