-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add actions * devcontainers * fmt * go 1.20 and 1.21
- Loading branch information
Showing
11 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,39 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/go | ||
{ | ||
"name": "Go", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/go:1.21-bookworm", | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
"settings": {}, | ||
"extensions": [ | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
} | ||
} | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [9000], | ||
|
||
// Use 'portsAttributes' to set default properties for specific forwarded ports. | ||
// More info: https://containers.dev/implementors/json_reference/#port-attributes | ||
// "portsAttributes": { | ||
// "9000": { | ||
// "label": "Hello Remote World", | ||
// "onAutoForward": "notify" | ||
// } | ||
//} | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "go version", | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains 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,3 @@ | ||
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf |
This file contains 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,18 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
commit-message: | ||
prefix: "deps:" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "monday" | ||
time: "12:00" | ||
- package-ecosystem: "github-actions" | ||
commit-message: | ||
prefix: "deps:" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "monday" | ||
time: "12:00" |
This file contains 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,80 @@ | ||
name: build | ||
|
||
permissions: {} # no need any permissions | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: '0 10 * * 1' # run "At 10:00 on Monday" | ||
workflow_call: | ||
inputs: | ||
skipTests: | ||
description: 'Skip tests, useful when there is a dedicated CI job for tests' | ||
default: false | ||
required: false | ||
type: boolean | ||
|
||
jobs: | ||
run: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
go: ['stable', 'oldstable'] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
check-latest: true | ||
|
||
- name: Go Format | ||
run: gofmt -s -w . && git diff --exit-code | ||
|
||
- name: Go Vet | ||
run: go vet ./... | ||
|
||
- name: Go Tidy | ||
run: go mod tidy && git diff --exit-code | ||
|
||
- name: Go Mod | ||
run: go mod download | ||
|
||
- name: Go Mod Verify | ||
run: go mod verify | ||
|
||
- name: Go Generate | ||
run: go generate ./... && git diff --exit-code | ||
|
||
- name: Go Build | ||
run: go build -o /dev/null ./... | ||
|
||
- name: Go Compile Tests | ||
if: ${{ inputs.skipTests }} | ||
run: go test -exec /bin/true ./... | ||
|
||
- name: Go Test | ||
if: ${{ !inputs.skipTests }} | ||
run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./... | ||
|
||
- name: Go Benchmark | ||
if: ${{ !inputs.skipTests }} | ||
run: go test -v -shuffle=on -run=- -bench=. -benchtime=1x ./... | ||
|
||
- name: Upload Coverage | ||
if: ${{ !inputs.skipTests }} | ||
uses: codecov/codecov-action@v3 | ||
continue-on-error: true | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
file: ./coverage.txt | ||
fail_ci_if_error: false |
This file contains 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,34 @@ | ||
name: lint | ||
|
||
permissions: {} # no need any permissions | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
workflow_call: | ||
|
||
jobs: | ||
run: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
check-latest: true | ||
|
||
- name: Lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: latest | ||
args: --timeout 5m |
This file contains 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,35 @@ | ||
name: test | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
run: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
go: ['stable', 'oldstable'] | ||
|
||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
check-latest: true | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run tests | ||
run: go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./... | ||
|
||
- name: Upload Coverage | ||
uses: codecov/codecov-action@v3 | ||
continue-on-error: true | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
file: ./coverage.txt | ||
fail_ci_if_error: false |
This file contains 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,36 @@ | ||
name: vuln | ||
|
||
permissions: {} # no need any permissions | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: '0 10 * * 1' # run "At 10:00 on Monday" | ||
workflow_call: | ||
|
||
jobs: | ||
run: | ||
name: Vuln | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
|
||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 'stable' | ||
check-latest: true | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install govulncheck | ||
run: go install golang.org/x/vuln/cmd/govulncheck@latest | ||
|
||
- name: Run govulncheck | ||
run: govulncheck -test ./... |
This file contains 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# .github-go | ||
GitHub actions for Go projects | ||
|
||
See [Reusing Workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows) |
This file contains 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,3 @@ | ||
module github.com/franchb/.github-go | ||
|
||
go 1.20 |
This file contains 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 main | ||
|
||
func main() { | ||
println("github.com/franchb/.github-go ready") | ||
} |
This file contains 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,9 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestSimple(t *testing.T) { | ||
if 0 == 1 { | ||
t.Fatal("impossible") | ||
} | ||
} |