Skip to content

the ability to automatically run unit tests after creating a pull request. #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

AsterZephyr
Copy link

@AsterZephyr AsterZephyr commented Jan 14, 2025

What this PR does:

  1. Add unit test workflow to automatically run tests on PR
  2. Separate unit tests from integration tests
  3. Add coverage report upload to codecov

Which issue(s) this PR fixes:

Fixes #762

Special notes for your reviewer:

  1. Added new workflow file .github/workflows/unit-test.yml
  2. Kept integration tests in original workflow
  3. Added timeout settings and better error reporting

@github-actions github-actions bot added the ci/cd label Jan 14, 2025
@luky116
Copy link
Contributor

luky116 commented Jan 18, 2025

看下 CI 问题

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

Copy link

@luky116 luky116 requested a review from Copilot May 19, 2025 00:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a dedicated unit-test workflow and cleans up the existing build workflow to separate unit tests and coverage reporting.

  • Introduces a new .github/workflows/unit-test.yml to run unit tests with coverage and archive results.
  • Updates .github/workflows/build.yml to focus on build-only, removing prior test and codecov steps.
  • Aligns CI jobs with PR events and push-to-master triggers.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/unit-test.yml New workflow for Go unit tests, coverage profile generation, and artifact upload.
.github/workflows/build.yml Renames workflow and removes test/coverage steps to preserve integration tests elsewhere.
Comments suppressed due to low confidence (3)

.github/workflows/build.yml:60

  • Removing the test and Codecov steps from the build workflow means no tests run on push. Ensure integration tests are moved to a separate workflow or re-add necessary test steps.
-      - name: "run go test and out codecov"

.github/workflows/unit-test.yml:76

  • [nitpick] The artifact is actually a coverage profile; consider renaming test-results to something like coverage-profile for clarity.
        name: test-results

.github/workflows/unit-test.yml:18

  • [nitpick] The workflow name is singular; consider using Unit Tests to match plural naming and reflect multiple tests being run.
name: "Unit Test"

fi
echo "✅ Unit tests completed successfully"

- name: "Archive test results"
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The PR description mentions uploading coverage to Codecov, but there’s no codecov/codecov-action step in this workflow. Add a step after archiving to upload coverage.txt to Codecov.

Copilot uses AI. Check for mistakes.

Comment on lines +66 to +71
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
if [ $? -ne 0 ]; then
echo "❌ Unit tests failed"
exit 1
fi
echo "✅ Unit tests completed successfully"
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

[nitpick] This explicit exit check is redundant—GitHub Actions will fail on a non-zero exit by default. Consider simplifying by running go test ... directly.

Suggested change
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
if [ $? -ne 0 ]; then
echo "❌ Unit tests failed"
exit 1
fi
echo "✅ Unit tests completed successfully"
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m && echo "✅ Unit tests completed successfully"

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

feat:the ability to automatically run unit tests after creating a pull request.
5 participants