-
Notifications
You must be signed in to change notification settings - Fork 18
Add: CI test workflow and build dependencies #107
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
997f28e
Add: CI test workflow and build dependencies
DFanso f610d2b
Potential fix for code scanning alert no. 3: Workflow does not contai…
DFanso ab8bd5d
Add: Auto-formatting to CI workflows
DFanso 21e8b6d
Merge branch 'dev' of https://github.com/DFanso/commit-msg into dev
DFanso ec65aa7
fmt
DFanso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: Test | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| go-version: ['1.21', '1.22', '1.23'] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
|
|
||
| - name: Cache Go modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/go-build | ||
| ~/go/pkg/mod | ||
| key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-go-${{ matrix.go-version }}- | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Verify dependencies | ||
| run: go mod verify | ||
|
|
||
| - name: Run go vet | ||
| run: go vet ./... | ||
|
|
||
| - name: Run go fmt | ||
| run: | | ||
| # Auto-format all Go files | ||
| gofmt -s -w . | ||
|
|
||
| # Check if any files were formatted (would indicate pre-existing formatting issues) | ||
| if [ -n "$(git status --porcelain 2>/dev/null)" ]; then | ||
| echo "Some files were auto-formatted. Consider running 'gofmt -s -w .' locally before committing." | ||
| git diff --name-only | ||
| fi | ||
|
|
||
| # Final check to ensure all files are properly formatted | ||
| if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | ||
| echo "The following files are still not formatted after auto-format:" | ||
| gofmt -s -l . | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Run tests | ||
| run: go test -v -race -coverprofile=coverage.out ./... | ||
|
|
||
| - name: Run tests with short mode | ||
| run: go test -v -short ./... | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| file: ./coverage.out | ||
| flags: unittests | ||
| name: codecov-umbrella | ||
| fail_ci_if_error: false | ||
|
|
||
| - name: Generate coverage report | ||
| run: go tool cover -html=coverage.out -o coverage.html | ||
|
|
||
| - name: Upload coverage report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-report-go${{ matrix.go-version }} | ||
| path: coverage.html | ||
|
|
||
| test-build: | ||
| name: Test Build | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.23' | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Build | ||
| run: go build -v -o commit ./cmd/commit-msg | ||
|
|
||
| - name: Verify binary | ||
| run: ./commit --help || true | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.