|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + |
| 10 | +env: |
| 11 | + CI: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + name: Run tests |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + os: |
| 23 | + - macos-latest |
| 24 | + - ubuntu-latest |
| 25 | + - windows-latest |
| 26 | + steps: |
| 27 | + - name: Install clang for Windows |
| 28 | + if: runner.os == 'Windows' |
| 29 | + run: | |
| 30 | + iwr -useb get.scoop.sh -outfile 'install.ps1' |
| 31 | + .\install.ps1 -RunAsAdmin |
| 32 | + scoop install llvm --global |
| 33 | +
|
| 34 | + # Scoop modifies the PATH so we make the modified PATH global. |
| 35 | + echo $env:PATH >> $env:GITHUB_PATH |
| 36 | +
|
| 37 | + - name: Check out repository |
| 38 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 39 | + with: |
| 40 | + fetch-depth: 1 |
| 41 | + |
| 42 | + # Skip macOS & Windows, cache there is slower |
| 43 | + - name: Restore node_modules cache for Linux |
| 44 | + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 |
| 45 | + if: runner.os == 'Linux' |
| 46 | + with: |
| 47 | + path: ~/.npm |
| 48 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-node- |
| 51 | +
|
| 52 | + - name: Install dependencies |
| 53 | + run: npm ci --ignore-scripts |
| 54 | + |
| 55 | + # Custom script, because progress looks not good in CI |
| 56 | + - name: Run tests |
| 57 | + run: npm run test |
| 58 | + |
| 59 | + lint: |
| 60 | + name: Run Lint |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Fetch code |
| 64 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 65 | + with: |
| 66 | + fetch-depth: 1 |
| 67 | + |
| 68 | + - name: Restore node_modules cache |
| 69 | + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 |
| 70 | + with: |
| 71 | + path: ~/.npm |
| 72 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 73 | + restore-keys: | |
| 74 | + ${{ runner.os }}-node- |
| 75 | +
|
| 76 | + - name: Install dependencies |
| 77 | + run: npm ci --ignore-scripts |
| 78 | + |
| 79 | + - name: Run lint command |
| 80 | + run: npm run lint |
0 commit comments