| 1 | name: CI |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - master |
| 7 | pull_request: |
| 8 | workflow_dispatch: |
| 9 | inputs: |
| 10 | withBenchmark: |
| 11 | description: 'With Benchmark?' |
| 12 | default: false |
| 13 | |
| 14 | jobs: |
| 15 | build: |
| 16 | runs-on: ubuntu-latest |
| 17 | |
| 18 | strategy: |
| 19 | matrix: |
| 20 | node-version: [12.x, 14.x] |
| 21 | |
| 22 | steps: |
| 23 | - name: Checkout |
| 24 | uses: actions/checkout@v2 |
| 25 | with: |
| 26 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis. This is needed for better sonar |
| 27 | |
| 28 | - name: Set node version to ${{ matrix.node-version }} |
| 29 | uses: actions/setup-node@v1 |
| 30 | with: |
| 31 | node-version: ${{ matrix.node-version }} |
| 32 | |
| 33 | - name: Install |
| 34 | run: npm ci |
| 35 | |
| 36 | - name: Build |
| 37 | run: npm run build --if-present |
| 38 | |
| 39 | - name: Lint |
| 40 | run: npm run lint |
| 41 | |
| 42 | - name: Tests & Coverage |
| 43 | run: | |
| 44 | npm run test |
| 45 | npm run coverage |
| 46 | env: |
| 47 | CI: true |
| 48 | |
| 49 | - name: Sonar Code Analysis |
| 50 | if: "github.repository == 'pioardi/poolifier'" |
| 51 | run: | |
| 52 | npm run sonar |
| 53 | env: |
| 54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 55 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 56 | |
| 57 | - name: Benchmark |
| 58 | if: github.event.inputs.withBenchmark |
| 59 | run: npm run benchmark |