|
| 1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: ci |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - '**' |
| 13 | + |
| 14 | +env: |
| 15 | + CI: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + cleanup-runs: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: rokroskar/workflow-run-cleanup-action@master |
| 22 | + env: |
| 23 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" |
| 25 | + |
| 26 | + lint: |
| 27 | + name: Running ESLint |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v2 |
| 31 | + - name: Get npm cache |
| 32 | + id: npm-cache |
| 33 | + run: echo "::set-output name=dir::$(npm config get cacheFolder)" |
| 34 | + - uses: actions/cache@v2 |
| 35 | + with: |
| 36 | + path: ${{ steps.npm-cache.outputs.dir }} |
| 37 | + key: ubuntu-latest-node-12.x-npm-${{ hashFiles('**/package-lock.json') }} |
| 38 | + restore-keys: | |
| 39 | + ubuntu-latest-node-12.x-npm- |
| 40 | + |
| 41 | + with: |
| 42 | + node-version: 12.x |
| 43 | + - name: Install and build |
| 44 | + run: npm ci |
| 45 | + - name: Run eslint |
| 46 | + run: npm run lint |
| 47 | + |
| 48 | + test: |
| 49 | + name: Node v${{ matrix.node-version }} on ${{ matrix.os }} |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + node-version: [10.x, 12.x, 14.x] |
| 54 | + os: [ ubuntu-latest ] |
| 55 | + runs-on: ${{ matrix.os }} |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Set git config |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + git config --global core.autocrlf false |
| 62 | + git config --global core.symlinks true |
| 63 | + if: runner.os == 'Windows' |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - name: Get npm cache |
| 66 | + id: npm-cache |
| 67 | + run: echo "::set-output name=dir::$(npm config get cacheFolder)" |
| 68 | + - uses: actions/cache@v2 |
| 69 | + with: |
| 70 | + path: ${{ steps.npm-cache.outputs.dir }} |
| 71 | + key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} |
| 72 | + restore-keys: | |
| 73 | + ${{ runner.os }}-node-${{ matrix.node-version }}-npm- |
| 74 | + - name: Use Node.js ${{ matrix.node-version }} |
| 75 | + |
| 76 | + with: |
| 77 | + node-version: ${{ matrix.node-version }} |
| 78 | + - name: Install and build |
| 79 | + run: npm ci |
| 80 | + - name: Run tests with coverage |
| 81 | + run: npm run test -- --coverage && cat ./coverage/lcov.info |
| 82 | + - name: Run real repo tests |
| 83 | + run: npm run test:external-repos |
| 84 | + - name: Coveralls parallel |
| 85 | + uses: coverallsapp/github-action@master |
| 86 | + with: |
| 87 | + github-token: ${{ secrets.github_token }} |
| 88 | + flag-name: run-${{ matrix.node-version }} |
| 89 | + parallel: true |
| 90 | + |
| 91 | + finish: |
| 92 | + needs: test |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - name: Coveralls finished |
| 96 | + uses: coverallsapp/github-action@master |
| 97 | + with: |
| 98 | + github-token: ${{ secrets.github_token }} |
| 99 | + parallel-finished: true |
0 commit comments