|
| 1 | +name: Node CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + |
| 11 | + with: |
| 12 | + fetch-depth: 0 |
| 13 | + |
| 14 | + - name: Use Node.js |
| 15 | + |
| 16 | + with: |
| 17 | + node-version: 22 |
| 18 | + |
| 19 | + - name: Get yarn cache directory path |
| 20 | + id: yarn-cache-dir-path |
| 21 | + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 22 | + |
| 23 | + - name: Restore cache for yarn and lerna |
| 24 | + |
| 25 | + id: yarn-cache |
| 26 | + with: |
| 27 | + path: | |
| 28 | + ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 29 | + node_modules |
| 30 | + */*/node_modules |
| 31 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-yarn- |
| 34 | +
|
| 35 | + - name: Install dependencies |
| 36 | + run: yarn install --frozen-lockfile |
| 37 | + |
| 38 | + - name: Run ESLint |
| 39 | + run: | |
| 40 | + BASE_BRANCH=${GITHUB_BASE_REF:-master} |
| 41 | + BASE_COMMIT=$(git merge-base HEAD origin/${BASE_BRANCH}) |
| 42 | + yarn lint-staged --concurrent=false --diff="${BASE_COMMIT}..HEAD" --verbose |
| 43 | +
|
| 44 | + test: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + node-version: [20.x, 22.x] |
| 50 | + |
| 51 | + steps: |
| 52 | + |
| 53 | + |
| 54 | + - name: Use Node.js ${{ matrix.node-version }} |
| 55 | + |
| 56 | + with: |
| 57 | + node-version: ${{ matrix.node-version }} |
| 58 | + |
| 59 | + - name: Get yarn cache directory path |
| 60 | + id: yarn-cache-dir-path |
| 61 | + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 62 | + |
| 63 | + - name: Restore cache for yarn and lerna |
| 64 | + |
| 65 | + id: yarn-cache |
| 66 | + with: |
| 67 | + path: | |
| 68 | + ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 69 | + node_modules |
| 70 | + */*/node_modules |
| 71 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 72 | + restore-keys: | |
| 73 | + ${{ runner.os }}-yarn- |
| 74 | +
|
| 75 | + - name: Install dependencies |
| 76 | + run: yarn install --frozen-lockfile |
| 77 | + |
| 78 | + - name: Build |
| 79 | + run: yarn build |
| 80 | + |
| 81 | + - name: Test |
| 82 | + run: yarn test |
| 83 | + |
| 84 | + build: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + |
| 87 | + strategy: |
| 88 | + matrix: |
| 89 | + node-version: [20.x, 22.x] |
| 90 | + |
| 91 | + steps: |
| 92 | + |
| 93 | + |
| 94 | + - name: Use Node.js ${{ matrix.node-version }} |
| 95 | + |
| 96 | + with: |
| 97 | + node-version: ${{ matrix.node-version }} |
| 98 | + |
| 99 | + - name: Get yarn cache directory path |
| 100 | + id: yarn-cache-dir-path |
| 101 | + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 102 | + |
| 103 | + - name: Restore cache for yarn and lerna |
| 104 | + |
| 105 | + id: yarn-cache |
| 106 | + with: |
| 107 | + path: | |
| 108 | + ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 109 | + node_modules |
| 110 | + */*/node_modules |
| 111 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 112 | + restore-keys: | |
| 113 | + ${{ runner.os }}-yarn- |
| 114 | +
|
| 115 | + - name: Install dependencies |
| 116 | + run: yarn install --frozen-lockfile |
| 117 | + |
| 118 | + - name: Build |
| 119 | + run: yarn build |
0 commit comments