[CW-27778] feat: add unit_test_than_build_image reusable workflow#39
Merged
Conversation
Add a new reusable workflow that runs `npm test` directly on the GitHub Actions runner BEFORE the docker build/save/upload steps, so test failures fail-fast without paying the image build cost. The existing `build_and_test_image.yml` is kept untouched (callers that still depend on its in-container test behavior remain unaffected). 1. New workflow exposes `inputs.node-version` (default '22.16.0') so callers can override the Node version without touching the template. 2. `DEVOPS_READ_PACKAGE_TOKEN` is `required: true` in the new workflow (vs `required: false` in the old one) because `npm ci` now runs on the runner and needs the token for private packages. 3. Artifact contract preserved: still uploads `image.tar` under name `image` on dev/master, so downstream `push_and_rotate_image.yml` keeps working with no changes on the caller side. Includes the implementation plan under docs/plans/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Static Code Review 📊 ✅ All quality checks passed! |
GinaYYoung
approved these changes
May 4, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DEVOPS_READ_PACKAGE_TOKEN由 optional 變 required:新檔的npm ci直接在 runner 上跑,沒 token 會裝不到 private package。caller 切換前請確認 secret 已設定。image/ pathimage.tar上傳(dev/master 分支),下游push_and_rotate_image.yml完全不需修改。uses:路徑換成CoolBitX-Technology/cp-workflow-template/.github/workflows/unit_test_than_build_image.yml@master即可;舊build_and_test_image.yml保留不動,可同時並存。22.16.0,若 caller 需要其他版本可用with: { node-version: '<x.y.z>' }覆寫。Test Plan
uses:改成此 PR 的 branch 引用unit_testjob 先跑、log 看得到npm test輸出build_imagejob 不會被觸發Related
docs/plans/2026-05-04-unit-test-then-build-workflow.mdPR Summary by Typo
Overview
This PR introduces a new reusable GitHub Actions workflow (
unit_test_than_build_image.yml) designed to run unit tests directly on the runner before building a Docker image. This approach aims to provide faster feedback and more efficient CI by failing early if tests don't pass, without altering the existingbuild_and_test_image.ymlworkflow.Key Changes
.github/workflows/unit_test_than_build_image.ymlwith distinctunit_testandbuild_imagejobs.unit_testjob executesnpm ciandnpm testdirectly on the GitHub Actions runner, with thebuild_imagejob dependent on its success.node-versioninput and requiresDEVOPS_READ_PACKAGE_TOKENfor dependency installation.README.mdhas been updated to include the new workflow, and a detailed plan document has been added.Work Breakdown
To turn off PR summary, please visit Notification settings.