Skip to content

Commit 68df738

Browse files
committed
ci: add makefile & ci
1 parent 62a3fae commit 68df738

6 files changed

Lines changed: 183 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Setup Go"
2+
description: |
3+
Sets up the Go environment for tests, builds, etc.
4+
inputs:
5+
version:
6+
description: "The Go version to use."
7+
default: "1.24.6"
8+
use-cache:
9+
description: "Whether to use the cache."
10+
default: "true"
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Setup Go
15+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
16+
with:
17+
go-version: ${{ inputs.version }}
18+
cache: ${{ inputs.use-cache }}
19+
20+
# It isn't necessary that we ever do this, but it helps separate the "setup"
21+
# from the "run" times.
22+
- name: go mod download
23+
shell: bash
24+
run: go mod download -x

.github/workflows/ci.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: quality
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
# Cancel in-progress runs for pull requests when developers push additional
14+
# changes.
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
18+
19+
jobs:
20+
fmt:
21+
name: fmt
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
persist-credentials: false
28+
29+
- name: make fmt
30+
run: make fmt
31+
32+
- name: Check unstaged
33+
run: |
34+
if [[ -n $(git ls-files --other --modified --exclude-standard) ]]; then
35+
echo "Unexpected difference in directories after formatting. Run 'make fmt' and include the output in the commit."
36+
exit 1
37+
fi
38+
39+
lint:
40+
name: lint
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
with:
46+
persist-credentials: false
47+
48+
- name: Setup Go
49+
uses: ./.github/actions/setup-go
50+
51+
- name: make lint
52+
run: make lint
53+
54+
test:
55+
name: test
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 15
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
61+
with:
62+
persist-credentials: false
63+
64+
- name: Setup Go
65+
uses: ./.github/actions/setup-go
66+
67+
- name: make test
68+
run: make test

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Code coverage profiles and other test artifacts
12+
*.out
13+
coverage.*
14+
*.coverprofile
15+
profile.cov
16+
17+
# Go workspace file
18+
go.work
19+
go.work.sum
20+
21+
# env file
22+
.env
23+
24+
# Editor/IDE
25+
.idea/
26+
.vscode/
27+
28+
# Key files
29+
*.key
30+
*.pub
31+
*.pem
32+
33+
# Output directory
34+
build/

.golangci.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "2"
2+
3+
linters:
4+
enable:
5+
- goconst
6+
- gocritic
7+
- gosec
8+
- misspell
9+
- nakedret
10+
- revive
11+
- unconvert
12+
- unparam
13+
settings:
14+
govet:
15+
enable:
16+
- shadow
17+
misspell:
18+
locale: US
19+
revive:
20+
rules:
21+
- name: package-comments
22+
disabled: true

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FIND_EXCLUSIONS= \
2+
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path '*/.terraform/*' \) -prune \)
3+
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
4+
GO_FMT_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -print0 | xargs -0 grep -E --null -L '^// Code generated .* DO NOT EDIT\.$$' | tr '\0' ' ')
5+
6+
default: build
7+
8+
build/paralleltestctx: $(GO_SRC_FILES) go.mod go.sum
9+
mkdir -p ./build
10+
go build -o ./build/paralleltestctx .
11+
12+
build: build/paralleltestctx
13+
.PHONY: build
14+
15+
fmt:
16+
go mod tidy
17+
go run golang.org/x/tools/cmd/goimports@v0.35.0 -w $(GO_FMT_FILES)
18+
go run mvdan.cc/gofumpt@v0.8.0 -w -l $(GO_FMT_FILES)
19+
.PHONY: fmt
20+
21+
lint:
22+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0 run ./...
23+
.PHONY: lint
24+
25+
test:
26+
go test -test.v -timeout 30s -cover ./...
27+
.PHONY: test

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import (
4+
"github.com/coder/paralleltestctx/pkg/paralleltestctx"
5+
"golang.org/x/tools/go/analysis/singlechecker"
6+
)
7+
8+
func main() { singlechecker.Main(paralleltestctx.Analyzer()) }

0 commit comments

Comments
 (0)