-
Notifications
You must be signed in to change notification settings - Fork 0
Initial commit for template #1
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # This workflow will build a golang project | ||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
|
||
| name: tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
|
|
||
| e2e: | ||
| # Only ubuntu allows for docker support - https://docs.github.com/en/actions/using-containerized-services/about-service-containers | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4.2.2 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5.3.0 | ||
| with: | ||
| go-version: '1.24' | ||
|
|
||
| - name: Build | ||
| run: go build -v ./... | ||
| - name: Test | ||
| run: | | ||
| sudo apt-get install moreutils -y | ||
| make test | ||
|
|
||
| # platforms: | ||
| # runs-on: ${{ matrix.os }} | ||
| # strategy: | ||
| # matrix: | ||
| # os: | ||
| # - "windows-latest" | ||
| # - "macos-latest" | ||
| # steps: | ||
| # - uses: actions/checkout@v4.2.2 | ||
| # - uses: actions/setup-go@v5.3.0 | ||
| # with: | ||
| # go-version: '1.24' | ||
| # - name: Test | ||
| # run: make short-test |
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,55 @@ | ||
| name: golangci-lint | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - main | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| # Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
| # pull-requests: read | ||
|
|
||
| jobs: | ||
| golangci: | ||
| name: lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.24' | ||
| cache: false | ||
| - name: golangci-lint | ||
| uses: golangci/golangci-lint-action@v7 | ||
| with: | ||
| # Require: The version of golangci-lint to use. | ||
| # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. | ||
| # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. | ||
| version: v2.1.1 | ||
|
|
||
| # Optional: working directory, useful for monorepos | ||
| # working-directory: somedir | ||
|
|
||
| # Optional: golangci-lint command line arguments. | ||
| # | ||
| # Note: By default, the `.golangci.yml` file should be at the root of the repository. | ||
| # The location of the configuration file can be changed by using `--config=` | ||
| # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 | ||
|
|
||
| # Optional: show only new issues if it's a pull request. The default value is `false`. | ||
| # only-new-issues: true | ||
|
|
||
| # Optional: if set to true, then all caching functionality will be completely disabled, | ||
| # takes precedence over all other caching options. | ||
| # skip-cache: true | ||
|
|
||
| # Optional: if set to true, then the action won't cache or restore ~/go/pkg. | ||
| # skip-pkg-cache: true | ||
|
|
||
| # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. | ||
| # skip-build-cache: true | ||
|
|
||
| # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. | ||
| # install-mode: "goinstall" |
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 |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ go.work.sum | |
|
|
||
| # env file | ||
| .env | ||
| /coverage | ||
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 @@ | ||
| version: "2" |
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,28 @@ | ||
| .PHONY: build | ||
| build: | ||
| go build . | ||
|
|
||
| test: | ||
| mkdir -p coverage/covdata | ||
| # Use the new binary format to ensure integration tests and cross-package calls are counted towards coverage | ||
| # https://go.dev/blog/integration-test-coverage | ||
| # -p 1 disable parallel testing in favor of streaming log output - https://github.com/golang/go/issues/24929#issuecomment-384484654 | ||
| go test -race -cover -covermode atomic -v -vet=all -timeout 15m -p 1\ | ||
| ./... \ | ||
| -args -test.gocoverdir="${PWD}/coverage/covdata" \ | ||
| | ts -s | ||
| # NB: ts command requires moreutils package; awk trick from https://stackoverflow.com/a/25764579 doesn't stream output | ||
| go tool covdata percent -i=./coverage/covdata | ||
| # Convert to old text format for coveralls upload | ||
| go tool covdata textfmt -i=./coverage/covdata -o ./coverage/covprofile | ||
| go tool cover -html=./coverage/covprofile -o ./coverage/coverage.html | ||
|
|
||
| .PHONY: short-test | ||
| short-test: | ||
| go test -v -short ./... | ||
|
|
||
| .PHONY: lint | ||
| lint: | ||
| golangci-lint run -v | ||
|
|
||
|
|
||
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,5 @@ | ||
| package template | ||
|
|
||
| func hello() string { | ||
| return "hello world" | ||
| } |
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,11 @@ | ||
| module github.com/sclgo/template | ||
|
|
||
| go 1.24.1 | ||
|
|
||
| require github.com/stretchr/testify v1.10.0 | ||
|
|
||
| require ( | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| ) |
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,10 @@ | ||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
| github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | ||
| github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
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,11 @@ | ||
| package template | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestHello(t *testing.T) { | ||
| require.Equal(t, "hello world", hello()) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a
cleantarget to remove build artifacts and coverage data. This can be helpful for ensuring a clean build environment.