ci: add Codecov bundle and test reporting
This commit is contained in:
1 parent
e6ac6ab03c
commit
acf5d40e57
5 files changed
+1130
-10
No files matched your search
@@ -57,17 +57,15 @@ jobs:
|
|||||||
- name: Build application
|
- name: Build application
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Upload bundle analysis to Codecov
|
||||||
|
env:
|
||||||
|
CODECOV_BUNDLE_ANALYSIS: 'true'
|
||||||
|
run: npx next build --webpack
|
||||||
|
|
||||||
- name: Run integration tests with coverage
|
- name: Run integration tests with coverage
|
||||||
run: |
|
run: |
|
||||||
npx c8 \
|
mkdir -p .coverage-tmp
|
||||||
--all \
|
NODE_V8_COVERAGE="$PWD/.coverage-tmp" node scripts/start.js > server.log 2>&1 &
|
||||||
--include 'app/**/*.js' \
|
|
||||||
--include 'lib/**/*.js' \
|
|
||||||
--exclude-after-remap \
|
|
||||||
--reporter lcov \
|
|
||||||
--reports-dir coverage \
|
|
||||||
--temp-directory .coverage-tmp \
|
|
||||||
node scripts/start.js > server.log 2>&1 &
|
|
||||||
server_pid=$!
|
server_pid=$!
|
||||||
cleanup() {
|
cleanup() {
|
||||||
kill "$server_pid" 2>/dev/null || true
|
kill "$server_pid" 2>/dev/null || true
|
||||||
@@ -86,12 +84,40 @@ jobs:
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
npm test
|
node --test \
|
||||||
|
--test-concurrency=1 \
|
||||||
|
--test-reporter=spec \
|
||||||
|
--test-reporter=junit \
|
||||||
|
--test-reporter-destination=stdout \
|
||||||
|
--test-reporter-destination=test-results.xml \
|
||||||
|
test/*.test.js
|
||||||
|
cleanup
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
npx c8 report \
|
||||||
|
--all \
|
||||||
|
--include 'app/**/*.js' \
|
||||||
|
--include 'lib/**/*.js' \
|
||||||
|
--exclude-after-remap \
|
||||||
|
--reporter lcov \
|
||||||
|
--reports-dir coverage \
|
||||||
|
--temp-directory .coverage-tmp
|
||||||
|
test -s coverage/lcov.info
|
||||||
|
test -s test-results.xml
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
use_oidc: true
|
use_oidc: true
|
||||||
files: coverage/lcov.info
|
files: coverage/lcov.info
|
||||||
|
disable_search: true
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
verbose: true
|
verbose: true
|
||||||
|
|
||||||
|
- name: Upload test results to Codecov
|
||||||
|
uses: codecov/test-results-action@v1
|
||||||
|
with:
|
||||||
|
use_oidc: true
|
||||||
|
file: test-results.xml
|
||||||
|
disable_search: true
|
||||||
|
fail_ci_if_error: true
|
||||||
@@ -5,6 +5,7 @@ out/
|
|||||||
*.log
|
*.log
|
||||||
coverage/
|
coverage/
|
||||||
.coverage-tmp/
|
.coverage-tmp/
|
||||||
|
test-results.xml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# 环境变量:.env 是用户本地环境变量(不提交),模板 .env.example 进仓库
|
# 环境变量:.env 是用户本地环境变量(不提交),模板 .env.example 进仓库
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
const enableCodecovBundleAnalysis = process.env.CODECOV_BUNDLE_ANALYSIS === 'true';
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
// 本地开发允许的来源:默认本机;局域网/其他设备通过环境变量追加
|
// 本地开发允许的来源:默认本机;局域网/其他设备通过环境变量追加
|
||||||
@@ -14,6 +16,20 @@ const nextConfig = {
|
|||||||
{ source: '/uploads/:name', destination: '/api/uploads/:name' },
|
{ source: '/uploads/:name', destination: '/api/uploads/:name' },
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
...(enableCodecovBundleAnalysis ? {
|
||||||
|
webpack(config) {
|
||||||
|
const { codecovWebpackPlugin } = require('@codecov/webpack-plugin');
|
||||||
|
config.plugins.push(codecovWebpackPlugin({
|
||||||
|
enableBundleAnalysis: true,
|
||||||
|
bundleName: 'forumlify-next',
|
||||||
|
gitService: 'github',
|
||||||
|
dryRun: process.env.GITHUB_ACTIONS !== 'true',
|
||||||
|
oidc: { useGitHubOIDC: true },
|
||||||
|
}));
|
||||||
|
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
} : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
Generated
+1075
File diff suppressed because it is too large.
Load diff
@@ -27,9 +27,11 @@
|
|||||||
"sanitize-html": "^2.17.6"
|
"sanitize-html": "^2.17.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@codecov/webpack-plugin": "^2.0.1",
|
||||||
"@opennextjs/cloudflare": "^1.20.2",
|
"@opennextjs/cloudflare": "^1.20.2",
|
||||||
"c8": "^10.1.3",
|
"c8": "^10.1.3",
|
||||||
"puppeteer-core": "^25.5.0",
|
"puppeteer-core": "^25.5.0",
|
||||||
|
"webpack": "^5.109.2",
|
||||||
"wrangler": "^4.120.0"
|
"wrangler": "^4.120.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user