|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + - renovate/* |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + node-version: [20.x] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Setup timezone |
| 23 | + uses: zcong1993/setup-timezone@master |
| 24 | + with: |
| 25 | + timezone: Asia/Shanghai |
| 26 | + |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Use Node.js ${{ matrix.node-version }} |
| 30 | + uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: ${{ matrix.node-version }} |
| 33 | + registry-url: 'https://registry.npmjs.org' |
| 34 | + |
| 35 | + - name: Get yarn cache directory path |
| 36 | + id: yarn-cache-dir-path |
| 37 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 38 | + |
| 39 | + - name: Cache for yarn |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 43 | + key: node-cache-${{ runner.os }}-yarn-master-${{ hashFiles('yarn.lock') }} |
| 44 | + restore-keys: | |
| 45 | + node-cache-${{ runner.os }}-yarn-master- |
| 46 | + if: (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'push' && github.ref_name == 'master') |
| 47 | + |
| 48 | + - name: Cache for nx (master) |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + save-always: true |
| 52 | + path: .cache |
| 53 | + key: ${{ runner.os }}-nx-master-${{ hashFiles('yarn.lock', 'package.json') }}-${{ hashFiles('**/package.json') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-nx-master-${{ hashFiles('yarn.lock', 'package.json') }}- |
| 56 | + if: (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'push' && github.ref_name == 'master') |
| 57 | + |
| 58 | + # Fix `yarn install --frozen-lockfile` not working in monorepo. |
| 59 | + # https://github.com/yarnpkg/yarn/issues/5840#issuecomment-468782288 |
| 60 | + - name: Get checksum before yarn install |
| 61 | + id: yarn-lock-check-before |
| 62 | + run: echo "::set-output name=sum::$(cksum yarn.lock)" |
| 63 | + |
| 64 | + - run: yarn install --frozen-lockfile |
| 65 | + |
| 66 | + - name: Get checksum after yarn install |
| 67 | + id: yarn-lock-check-after |
| 68 | + run: echo "::set-output name=sum::$(cksum yarn.lock)" |
| 69 | + |
| 70 | + - name: Exit if yarn.lock updated |
| 71 | + run: exit 1 |
| 72 | + if: steps.yarn-lock-check-before.outputs.sum != steps.yarn-lock-check-after.outputs.sum |
| 73 | + |
| 74 | + - run: yarn build --concurrency 1 |
| 75 | + env: |
| 76 | + NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' |
| 77 | + - run: yarn test:ci |
| 78 | + env: |
| 79 | + NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' |
| 80 | + |
| 81 | + - name: Get coverage files |
| 82 | + run: | |
| 83 | + echo "COVERAGE_FILES=$(find ./packages -maxdepth 1 -mindepth 1 -type d -exec echo "{}/.coverage/cobertura-coverage.xml" \; | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV |
| 84 | +
|
| 85 | + - name: Codecov |
| 86 | + uses: codecov/codecov-action@v4 |
| 87 | + with: |
| 88 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 89 | + files: ${{ env.COVERAGE_FILES }} |
| 90 | + disable_search: true |
| 91 | + |
| 92 | + - id: next-publish-from-tags |
| 93 | + uses: easyops-cn/actions-next-publish-from-tags@master |
| 94 | + with: |
| 95 | + npm-token: ${{ secrets.NPM_TOKEN }} |
| 96 | + if: github.event_name == 'push' && github.ref_name == 'master' |
| 97 | + |
| 98 | + - name: Sync taobao npm mirror |
| 99 | + run: npx lerna exec -- curl -sLX PUT 'https://registry-direct.npmmirror.com/-/package/$LERNA_PACKAGE_NAME/syncs' |
| 100 | + if: github.event_name == 'push' && github.ref_name == 'master' && steps.next-publish-from-tags.outputs.has-tags |
| 101 | + continue-on-error: true |
0 commit comments