|
1 | | -name: Node.js CI |
| 1 | +name: CI |
2 | 2 |
|
3 | | -on: [push, pull_request] |
| 3 | +on: ['push', 'pull_request'] |
4 | 4 |
|
5 | 5 | jobs: |
6 | | - build: |
| 6 | + setup: |
7 | 7 | runs-on: ubuntu-latest |
8 | 8 | steps: |
9 | | - - name: Checkout |
| 9 | + - name: checkout |
10 | 10 | uses: actions/checkout@v4 |
11 | | - - name: Install Node.js |
12 | | - uses: actions/setup-node@v3 |
| 11 | + |
| 12 | + - uses: actions/setup-node@v4 |
| 13 | + with: |
| 14 | + node-version: '20' |
| 15 | + |
| 16 | + - name: cache package-lock.json |
| 17 | + uses: actions/cache@v4 |
| 18 | + with: |
| 19 | + path: package-temp-dir |
| 20 | + key: lock-${{ github.sha }} |
| 21 | + |
| 22 | + - name: create package-lock.json |
| 23 | + run: npm i --package-lock-only --ignore-scripts |
| 24 | + |
| 25 | + - name: hack for singe file |
| 26 | + run: | |
| 27 | + if [ ! -d "package-temp-dir" ]; then |
| 28 | + mkdir package-temp-dir |
| 29 | + fi |
| 30 | + cp package-lock.json package-temp-dir |
| 31 | +
|
| 32 | + - name: cache node_modules |
| 33 | + id: node_modules_cache_id |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + path: node_modules |
| 37 | + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} |
| 38 | + |
| 39 | + - name: install |
| 40 | + if: steps.node_modules_cache_id.outputs.cache-hit != 'true' |
| 41 | + run: npm ci |
| 42 | + |
| 43 | + lint: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - name: checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: restore cache from package-lock.json |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: package-temp-dir |
| 53 | + key: lock-${{ github.sha }} |
| 54 | + |
| 55 | + - name: restore cache from node_modules |
| 56 | + uses: actions/cache@v4 |
13 | 57 | with: |
14 | | - node-version: 18.x |
15 | | - - name: Install dependencies |
16 | | - run: npm install |
| 58 | + path: node_modules |
| 59 | + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} |
| 60 | + |
17 | 61 | - name: lint |
18 | 62 | run: npm run lint |
| 63 | + |
| 64 | + needs: setup |
| 65 | + |
| 66 | + compile: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + steps: |
| 69 | + - name: checkout |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: restore cache from package-lock.json |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: package-temp-dir |
| 76 | + key: lock-${{ github.sha }} |
| 77 | + |
| 78 | + - name: restore cache from node_modules |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: node_modules |
| 82 | + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} |
| 83 | + |
19 | 84 | - name: compile |
20 | 85 | run: npm run tsc && npm run compile |
21 | | - - name: test |
22 | | - run: npm run coverage |
23 | | - - name: Upload coverage reports to Codecov |
| 86 | + |
| 87 | + needs: setup |
| 88 | + |
| 89 | + coverage: |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: checkout |
| 93 | + uses: actions/checkout@v4 |
| 94 | + |
| 95 | + - name: restore cache from package-lock.json |
| 96 | + uses: actions/cache@v4 |
| 97 | + with: |
| 98 | + path: package-temp-dir |
| 99 | + key: lock-${{ github.sha }} |
| 100 | + |
| 101 | + - name: restore cache from node_modules |
| 102 | + uses: actions/cache@v4 |
| 103 | + with: |
| 104 | + path: node_modules |
| 105 | + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} |
| 106 | + |
| 107 | + - name: coverage |
| 108 | + run: npm test -- --coverage |
| 109 | + |
| 110 | + - name: Upload coverage to Codecov |
24 | 111 | uses: codecov/codecov-action@v4 |
25 | 112 | with: |
26 | | - fail_ci_if_error: true |
27 | | - env: |
28 | | - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 113 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 114 | + |
| 115 | + needs: setup |
0 commit comments