|
| 1 | +name: Unit Tests |
| 2 | + |
| 3 | +# all pull requests |
| 4 | +on: pull_request |
| 5 | + |
| 6 | +jobs: |
| 7 | + unit-tests-p2: |
| 8 | + name: Polymer 2 on the CI agent |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Set up Node 12.x |
| 12 | + uses: actions/setup-node@v2 |
| 13 | + with: |
| 14 | + node-version: 12.x |
| 15 | + |
| 16 | + - name: Check out the source code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: Install latest npm |
| 20 | + # magi-cli 1.0 requires npm 7 or higher |
| 21 | + run: "npm install -g npm@8" |
| 22 | + |
| 23 | + - name: Install global npm dependencies |
| 24 | + # bower is needed to run 'bower install' |
| 25 | + # polymer-cli is needed to run the lint step |
| 26 | + run: "npm install --quiet --no-progress --global bower polymer-cli" |
| 27 | + |
| 28 | + - name: Install project npm dependencies |
| 29 | + run: "npm ci" |
| 30 | + |
| 31 | + - name: Install project Bower dependencies |
| 32 | + run: "bower install --quiet" |
| 33 | + |
| 34 | + # the full set of environments is tested with Polymer 3 below |
| 35 | + - name: Run unit tests locally (in the VM instance running this job) |
| 36 | + run: "xvfb-run -s '-screen 0 1024x768x24' npm test" |
| 37 | + |
| 38 | + unit-tests-p3: |
| 39 | + name: Polymer 3 on SauceLabs |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - name: Set up Node 12.x |
| 43 | + uses: actions/setup-node@v2 |
| 44 | + with: |
| 45 | + node-version: 12.x |
| 46 | + |
| 47 | + - name: Check out the (Polymer 2) source code |
| 48 | + uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Install latest npm |
| 51 | + # magi-cli 1.0 requires npm 7 or higher |
| 52 | + run: "npm install -g npm@8" |
| 53 | + |
| 54 | + - name: Install global npm dependencies |
| 55 | + # bower and polymer-modulizer are needed to run the Polymer 3 conversion step |
| 56 | + run: "npm install --quiet --no-progress --global bower magi-cli polymer-modulizer" |
| 57 | + |
| 58 | + - name: Convert the source code to Polymer 3 |
| 59 | + run: | |
| 60 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 61 | + git config --local user.name "github-actions[bot]" |
| 62 | + magi p3-convert --out . --import-style=name |
| 63 | +
|
| 64 | + # workaround for running tests on Android on SauceLabs (see wct.conf.js) |
| 65 | + - name: Add 'localhost-for-saucelabs' to /etc/hosts |
| 66 | + run: echo "127.0.0.1 localhost-for-saucelabs" | sudo tee -a /etc/hosts |
| 67 | + |
| 68 | + - name: Run unit tests on SauceLabs |
| 69 | + run: "npm test -- --env saucelabs" |
| 70 | + env: |
| 71 | + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} |
| 72 | + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} |
0 commit comments