Merge pull request #4545 from easyops-cn/renovate/next-mini-css-extra… #13772
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
- next | |
- v3 | |
pull_request: | |
branches: | |
- master | |
- next | |
- v3 | |
- renovate/* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Setup timezone | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: Asia/Shanghai | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache for yarn (master) | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-master-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn-master- | |
if: (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'push' && github.ref_name == 'master') | |
- name: Cache for yarn (v3) | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-v3-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn-v3- | |
if: (github.event_name == 'pull_request' && github.base_ref == 'v3') || (github.event_name == 'push' && github.ref_name == 'v3') | |
- name: Get week number (next) | |
id: week-number | |
run: echo "::set-output name=num::$(date +'%U')" | |
if: (github.event_name == 'pull_request' && github.base_ref == 'next') || (github.event_name == 'push' && github.ref_name == 'next') | |
- name: Cache for yarn (next) | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-next-${{ steps.week-number.outputs.num }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn-next- | |
if: (github.event_name == 'pull_request' && github.base_ref == 'next') || (github.event_name == 'push' && github.ref_name == 'next') | |
- name: Cache for nx (master) | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: .cache | |
key: ${{ runner.os }}-nx-master-${{ hashFiles('yarn.lock', 'package.json') }}-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-nx-master-${{ hashFiles('yarn.lock', 'package.json') }}- | |
if: (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'push' && github.ref_name == 'master') | |
- name: Cache for nx (v3) | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: .cache | |
key: ${{ runner.os }}-nx-v3-${{ hashFiles('yarn.lock', 'package.json') }}-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-nx-v3-${{ hashFiles('yarn.lock', 'package.json') }}- | |
if: (github.event_name == 'pull_request' && github.base_ref == 'v3') || (github.event_name == 'push' && github.ref_name == 'v3') | |
- name: Cache for npx | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-wait-on--start-serve-and-test | |
restore-keys: | | |
${{ runner.os }}-wait-on--start-serve-and-test | |
- name: Get cypress version | |
id: cypress-version | |
run: echo "::set-output name=ver::$(cat package.json|grep '\"cypress\":'|awk -F '[:,\"]' '{print $5}')" | |
- name: Cache for cypress | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/Cypress | |
key: cypress-${{ runner.os }}-cypress-${{ steps.cypress-version.outputs.ver }} | |
# Fix `yarn install --frozen-lockfile` not working in monorepo. | |
# https://github.com/yarnpkg/yarn/issues/5840#issuecomment-468782288 | |
- name: Get checksum before yarn install | |
id: yarn-lock-check-before | |
run: echo "::set-output name=sum::$(cksum yarn.lock)" | |
- run: yarn install --frozen-lockfile | |
env: | |
CYPRESS_INSTALL_BINARY: '' | |
CYPRESS_DOWNLOAD_MIRROR: '' | |
- name: Get checksum after yarn install | |
id: yarn-lock-check-after | |
run: echo "::set-output name=sum::$(cksum yarn.lock)" | |
- name: Exit if yarn.lock updated | |
run: exit 1 | |
if: steps.yarn-lock-check-before.outputs.sum != steps.yarn-lock-check-after.outputs.sum | |
- run: yarn build --concurrency 1 | |
env: | |
NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' | |
- run: yarn test:ci | |
env: | |
NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' | |
- name: Get coverage files | |
run: | | |
echo "COVERAGE_FILES=$(find ./packages -maxdepth 1 -mindepth 1 -type d -exec echo "{}/.coverage/cobertura-coverage.xml" \; | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV | |
- name: Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ${{ env.COVERAGE_FILES }} | |
disable_search: true | |
- run: yarn test:e2e:ci | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
- id: next-publish-from-tags | |
uses: easyops-cn/actions-next-publish-from-tags@master | |
with: | |
npm-token: ${{ secrets.NPM_TOKEN }} | |
if: github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'v3') | |
- name: Sync taobao npm mirror | |
run: npx lerna exec -- curl -sLX PUT 'https://registry-direct.npmmirror.com/-/package/$LERNA_PACKAGE_NAME/syncs' | |
if: github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'v3') && steps.next-publish-from-tags.outputs.has-tags | |
continue-on-error: true |