| 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: ${{ matrix.os }} |
| 18 | |
| 19 | strategy: |
| 20 | matrix: |
| 21 | os: [windows-latest, macos-latest, ubuntu-latest] |
| 22 | node: ['16.x', '18.x'] |
| 23 | |
| 24 | steps: |
| 25 | - name: Checkout |
| 26 | uses: actions/checkout@v3 |
| 27 | with: |
| 28 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis. This is needed for better sonar |
| 29 | |
| 30 | - name: Set node version to ${{ matrix.node }} |
| 31 | uses: actions/setup-node@v3 |
| 32 | with: |
| 33 | node-version: ${{ matrix.node }} |
| 34 | |
| 35 | - name: Install |
| 36 | run: npm ci |
| 37 | |
| 38 | - name: Build |
| 39 | run: npm run build --if-present |
| 40 | |
| 41 | - name: Lint |
| 42 | run: npm run lint |
| 43 | |
| 44 | - name: Tests |
| 45 | if: "matrix.os != 'windows-latest' || matrix.node != '18.x'" |
| 46 | run: npm run test |
| 47 | |
| 48 | - name: Coverage & Linter Reports |
| 49 | if: "github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '16.x'" |
| 50 | run: | |
| 51 | npm run coverage |
| 52 | npm run lint:report |
| 53 | |
| 54 | - name: Sonar Code Analysis |
| 55 | if: "github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '16.x'" |
| 56 | uses: sonarsource/sonarcloud-github-action@master |
| 57 | env: |
| 58 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 59 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 60 | |
| 61 | - name: Benchmark |
| 62 | if: github.event.inputs.withBenchmark |
| 63 | run: npm run benchmark |