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