From 7b35fd18c527b94bd63ca143806ca849a9f163e5 Mon Sep 17 00:00:00 2001 From: chenhang Date: Thu, 2 Jul 2026 13:17:21 +0800 Subject: [PATCH] ci: add verification workflow --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++++++++ next.config.ts | 12 ++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..0c0b519d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + pull_request: + push: + branches: + - dev + - main + - test + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify: + name: Lint, Test, Build + runs-on: ubuntu-latest + env: + NEXT_PUBLIC_APP_ENV: test + NEXT_TELEMETRY_DISABLED: "1" + SENTRY_UPLOAD_SOURCEMAPS: "0" + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.30.3 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Lint + run: pnpm lint + + - name: Test + run: pnpm test + + - name: Build + run: pnpm build diff --git a/next.config.ts b/next.config.ts index f1606f4e..78a65bd6 100644 --- a/next.config.ts +++ b/next.config.ts @@ -41,6 +41,9 @@ const nextConfig: NextConfig = { }, }; +const shouldUploadSentrySourcemaps = + process.env.CI !== "true" || process.env.SENTRY_UPLOAD_SOURCEMAPS === "1"; + export default withSentryConfig(withSerwist(nextConfig), { // For all available options, see: // https://www.npmjs.com/package/@sentry/webpack-plugin#options @@ -52,12 +55,21 @@ export default withSentryConfig(withSerwist(nextConfig), { // Only print logs for uploading source maps in CI silent: !process.env.CI, + // Keep build metadata local; application errors/performance are configured separately. + telemetry: false, + // For all available options, see: // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ // Upload a larger set of source maps for prettier stack traces (increases build time) widenClientFileUpload: true, + // PR/branch CI should validate builds without uploading source maps. Release jobs can + // set SENTRY_UPLOAD_SOURCEMAPS=1 to enable uploads explicitly. + sourcemaps: { + disable: !shouldUploadSentrySourcemaps, + }, + // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. // This can increase your server load as well as your hosting bill. // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-