|
| 1 | +name: build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - release |
| 7 | + pull_request: |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + node: ["12.19.0", "14.15.0", "15.2.0"] |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v2 |
| 17 | + - name: Extract branch name |
| 18 | + shell: bash |
| 19 | + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" |
| 20 | + id: extract-branch |
| 21 | + - name: Use Node.js |
| 22 | + uses: actions/setup-node@v1 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node }} |
| 25 | + - name: Cache node modules |
| 26 | + uses: actions/cache@v2 |
| 27 | + env: |
| 28 | + cache-name: cache-node-modules |
| 29 | + with: |
| 30 | + # npm cache files are stored in `~/.npm` on Linux/macOS |
| 31 | + path: ~/.npm |
| 32 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 35 | + ${{ runner.os }}-build- |
| 36 | + ${{ runner.os }}- |
| 37 | + - name: Install dependencies |
| 38 | + run: npm ci |
| 39 | + - name: Lint |
| 40 | + run: npm run lint |
| 41 | + - name: Test unit |
| 42 | + run: npm run test:unit |
| 43 | + - name: Upload test results |
| 44 | + uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + name: coverage-${{ matrix.node }} |
| 47 | + path: coverage |
| 48 | + retention-days: 1 |
| 49 | + quality: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: test |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v2 |
| 55 | + - name: Download test results |
| 56 | + uses: actions/download-artifact@v2 |
| 57 | + with: |
| 58 | + name: coverage-15.2.0 |
| 59 | + path: coverage |
| 60 | + - name: Coveralls |
| 61 | + uses: coverallsapp/github-action@master |
| 62 | + with: |
| 63 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + - name: SonarCloud Scan |
| 65 | + if: env.SONAR_TOKEN != '' |
| 66 | + uses: sonarsource/sonarcloud-github-action@master |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
0 commit comments