Skip to content

Commit

Permalink
ci: update GitHub workflows and Code Coverage settings (#955)
Browse files Browse the repository at this point in the history
* ci: update GitHub workflows

* ci: add codecov.yml

* ci(codecov): enable bundle analysis

* ci: save Algolia application ID to secrets

* ci: update the bundle name for codecov bundle analysis report
  • Loading branch information
cheton authored Dec 6, 2024
1 parent d797c22 commit 5e10b69
Show file tree
Hide file tree
Showing 25 changed files with 468 additions and 65 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/algolia-search-indexing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@ on:
workflow_dispatch:

env:
ALGOLIA_APPLICATION_ID: 7V00GBK8V8
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
ALGOLIA_INDEX: tonic-ui-v2

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: npm install -g yarn
- name: Install and build
run: |
yarn up
yarn install
yarn build
- name: Algolia search indexing
env:
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
run: |
cd packages/react-docs; ../../node_modules/.bin/babel-node scripts/algolia-search-indexing.js
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch the entire Git history to access the latest tag release
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install yarn
run: npm install -g yarn
- name: Install and build
run: |
yarn up
yarn install
yarn build
- name: Algolia search indexing
env:
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
run: |
cd packages/react-docs; ../../node_modules/.bin/babel-node scripts/algolia-search-indexing.js
7 changes: 6 additions & 1 deletion .github/workflows/ci-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- v2
schedule:
# run daily
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
Expand All @@ -25,7 +28,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Check installed versions
run: |
Expand Down Expand Up @@ -54,6 +57,8 @@ jobs:
yarn install
- name: Build & Test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
yarn build
yarn lint
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Check installed versions
run: |
Expand Down Expand Up @@ -58,6 +58,8 @@ jobs:
yarn install
- name: Build & Test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
yarn build
yarn lint
Expand Down Expand Up @@ -114,7 +116,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Configure environment variables
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install packages
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Check installed versions
run: |
Expand Down Expand Up @@ -54,6 +54,8 @@ jobs:
yarn install
- name: Build & Test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
yarn build
yarn lint
Expand Down
38 changes: 17 additions & 21 deletions .github/workflows/update-yarn-lock-file.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Update yarn.lock file
name: Update `yarn.lock` file

on:
# run daily
schedule:
- cron: '0 0 * * *'

# allow manual trigger
workflow_dispatch:

# Ensure only one lock action can run at a time
Expand All @@ -18,19 +13,20 @@ jobs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: npm install -g yarn
- name: Update yarn.lock
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
scripts/update-yarn-lock-file.sh
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch the entire Git history to access the latest tag release
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install yarn
run: npm install -g yarn
- name: Update yarn.lock
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
scripts/update-yarn-lock-file.sh
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coverage:
# https://docs.codecov.com/docs/commit-status
status:
project:
default:
target: auto
threshold: 2%
patch:
default:
target: auto
threshold: 2%
1 change: 1 addition & 0 deletions packages/changelog-github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@babel/eslint-plugin": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@codecov/rollup-plugin": "^1.5.1",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@trendmicro/babel-config": "^1.0.2",
Expand Down
19 changes: 17 additions & 2 deletions packages/changelog-github/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { codecovRollupPlugin } from '@codecov/rollup-plugin';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const pkg = createRequire(import.meta.url)('./package.json');
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

Expand All @@ -27,6 +30,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
},
{
Expand All @@ -40,6 +49,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import jscodeshift from 'jscodeshift';
import transform from '@tonic-ui/codemod/src/react/v2.0.0/import-react-icons';

Expand Down
1 change: 1 addition & 0 deletions packages/react-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@codecov/rollup-plugin": "^1.5.1",
"@emotion/babel-plugin": "^11.10.0",
"@emotion/jest": "^11.10.0",
"@rollup/plugin-babel": "^6.0.0",
Expand Down
19 changes: 17 additions & 2 deletions packages/react-base/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { codecovRollupPlugin } from '@codecov/rollup-plugin';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const pkg = createRequire(import.meta.url)('./package.json');
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

Expand All @@ -26,6 +29,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
},
{
Expand All @@ -39,6 +48,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}
];
1 change: 1 addition & 0 deletions packages/react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@codecov/rollup-plugin": "^1.5.1",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@testing-library/jest-dom": "^6.0.0",
Expand Down
19 changes: 17 additions & 2 deletions packages/react-hooks/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { codecovRollupPlugin } from '@codecov/rollup-plugin';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const pkg = createRequire(import.meta.url)('./package.json');
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

Expand All @@ -27,6 +30,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
},
{
Expand All @@ -40,6 +49,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}
];
1 change: 1 addition & 0 deletions packages/react-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.23.3",
"@codecov/rollup-plugin": "^1.5.1",
"@emotion/babel-plugin": "^11.11.0",
"@emotion/react": "11.x",
"@trendmicro/babel-config": "^1.0.2",
Expand Down
19 changes: 17 additions & 2 deletions packages/react-icons/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { codecovRollupPlugin } from '@codecov/rollup-plugin';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const pkg = createRequire(import.meta.url)('./package.json');
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

Expand All @@ -26,6 +29,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
},
{
Expand All @@ -39,6 +48,12 @@ export default [
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
// Put the Codecov rollup plugin after all other plugins
codecovRollupPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: pkg.name,
uploadToken: process.env.CODECOV_TOKEN,
}),
],
}
];
Loading

0 comments on commit 5e10b69

Please sign in to comment.