Skip to content

Feature: Add test step to CI workflow.#3459

Open
twoGiants wants to merge 1 commit intoknative:mainfrom
twoGiants:issue-781-ci-test-step
Open

Feature: Add test step to CI workflow.#3459
twoGiants wants to merge 1 commit intoknative:mainfrom
twoGiants:issue-781-ci-test-step

Conversation

@twoGiants
Copy link
Contributor

Changes

  • 🎁 Add --test-step flag to func config ci, enabled by default, disable with --test-step=false
  • 🎁 Generate a "Run tests" step in the GitHub Actions workflow that executes before deployment
  • 🎁 Select the test command based on function runtime: go test ./... for Go, npm test for Node.js, python -m pytest for Python
  • 🎁 Skip the test step with a warning for unsupported runtimes

/kind enhancement

Relates to #3256

Release Note

New `--test-step` flag for `func config ci` adds a runtime-appropriate test step to the CI workflow before deployment.

Docs


@knative-prow
Copy link

knative-prow bot commented Feb 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: twoGiants
Once this PR has been reviewed and has the lgtm label, please assign jrangelramos for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 27, 2026
@twoGiants
Copy link
Contributor Author

/cc @matejvasek @lkingland @gauron99

Next one is ready for review! 😸 👍

The generated GitHub workflow now includes a "Run tests"
step that runs before deployment. The test command is
selected based on the function runtime: `go test ./...` for
Go, `npm test` for Node.js, and `python -m pytest` for Python.
Unsupported runtimes skip the step with a warning. The step
can be disabled via --test-step=false.

Issue 3256

Signed-off-by: Stanislav Jakuschevskij <[email protected]>
@twoGiants twoGiants force-pushed the issue-781-ci-test-step branch from 700184d to b04f22b Compare February 27, 2026 15:50
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 73.14815% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.70%. Comparing base (fbd2f4f) to head (b04f22b).

Files with missing lines Patch % Lines
cmd/ci/workflow.go 40.62% 16 Missing and 3 partials ⚠️
cmd/ci/config.go 63.63% 8 Missing ⚠️
cmd/ci/common.go 0.00% 0 Missing and 1 partial ⚠️
cmd/ci/printer.go 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3459      +/-   ##
==========================================
- Coverage   54.71%   54.70%   -0.01%     
==========================================
  Files         181      181              
  Lines       20394    20425      +31     
==========================================
+ Hits        11158    11174      +16     
- Misses       8059     8074      +15     
  Partials     1177     1177              
Flag Coverage Δ
e2e 38.26% <0.00%> (-0.07%) ⬇️
e2e go 32.50% <0.00%> (-0.06%) ⬇️
e2e node 28.31% <0.00%> (-0.04%) ⬇️
e2e python 31.89% <0.00%> (-0.08%) ⬇️
e2e quarkus 28.45% <0.00%> (-0.06%) ⬇️
e2e rust 27.87% <0.00%> (-0.03%) ⬇️
e2e springboot 26.32% <0.00%> (-0.07%) ⬇️
e2e typescript 28.42% <0.00%> (-0.06%) ⬇️
integration 17.42% <0.00%> (-0.05%) ⬇️
unit macos-14 42.63% <72.63%> (+0.01%) ⬆️
unit macos-latest 42.63% <72.63%> (+0.01%) ⬆️
unit ubuntu-24.04-arm 42.89% <73.14%> (+0.01%) ⬆️
unit ubuntu-latest 43.52% <72.63%> (+0.01%) ⬆️
unit windows-latest 42.65% <72.63%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gauron99 gauron99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! just few questions from me

})
}

func TestNewConfigCICmd_TestStepPerRuntime(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also add go runtime here for completeness?

}

func NewGitHubWorkflow(conf CIConfig) *githubWorkflow {
func NewGitHubWorkflow(conf CIConfig, runtime string, messageWriter io.Writer) *githubWorkflow {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense here to have runtime as part of the CIConfig as well? not sure about the messageWriter

testStep.withRun("npm test")
case "python":
testStep.withRun("python -m pytest")
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add quarkus -- ./mvnw test.

case "go":
testStep.withRun("go test ./...")
case "node":
testStep.withRun("npm test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to call npm install first?

case "node":
testStep.withRun("npm test")
case "python":
testStep.withRun("python -m pytest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to call pip instal… first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants