Skip to content

Commit 12b88dc

Browse files
authored
Merge pull request #1235 from CircleCI-Public/all-checks-can-be-local
add `check`/`ci:check` commands that run all static checks
2 parents c8aade7 + 25fa91b commit 12b88dc

4 files changed

Lines changed: 72 additions & 14 deletions

File tree

.circleci/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,15 @@ executors:
113113
GOCACHE: 'C:\Users\circleci\.cache\go-build'
114114

115115
jobs:
116-
lint:
116+
check:
117117
executor: linux
118118
steps:
119119
- setup
120120
- go/with-cache:
121121
golangci-lint: true
122122
steps:
123-
- run: task ci:lint
123+
- run: task ci:check
124124
- store_results
125-
- run: task ci:diff
126125

127126
test:
128127
parameters:
@@ -141,7 +140,7 @@ jobs:
141140
workflows:
142141
ci:
143142
jobs:
144-
- lint
143+
- check
145144
- test:
146145
matrix:
147146
parameters:

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# circleci-cli-v2
22
Use CircleCI from the command line
3+
4+
## Development
5+
6+
### Local
7+
8+
This repository makes use [Task](https://taskfile.dev/#/) which can be installed (on MacOS) with:
9+
10+
```
11+
$ brew install go-task/tap/go-task
12+
```
13+
14+
Most other tools referenced in the `Taskfile.yml` are managed by the go.mod tool section.
15+
16+
TODO: add instructions to install other tools.
17+
18+
See the full list of available tasks by running `task -l`, or, see the [Taskfile.yml](./Taskfile.yml) script.
19+
20+
```sh
21+
# Run all static checks
22+
task check
23+
# Format all the code
24+
task fmt
25+
# Apply licence headers
26+
task licence
27+
28+
# Run all the tests
29+
task test
30+
# Run the quick tests
31+
task test -- -short ./...
32+
# Run the quick tests for one package
33+
task test -- -short ./api/...

Taskfile.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ tasks:
4040
cmds:
4141
- go tool gotestsum -- -race {{.ARGS}}
4242

43+
check:
44+
desc: Run all static checks
45+
cmds:
46+
- task: lint
47+
- task: license
48+
vars:
49+
CLI_ARGS: -check .
50+
- task: mod-tidy
51+
vars:
52+
CLI_ARGS: -diff
53+
4354
lint:
4455
desc: Run golangci-lint
4556
vars:
@@ -54,10 +65,28 @@ tasks:
5465
cmds:
5566
- go tool golangci-lint fmt {{.ARGS}}
5667

68+
license:
69+
desc: Manage license headers
70+
vars:
71+
ARGS: '{{default "." .CLI_ARGS}}'
72+
cmds:
73+
- |
74+
go tool addlicense \
75+
-c "Circle Internet Services, Inc." \
76+
-l mit \
77+
-s \
78+
-ignore ".idea/**" \
79+
-ignore ".circleci/**" \
80+
-ignore ".claude/**" \
81+
-ignore "test-reports/**" \
82+
{{.ARGS}}
83+
5784
mod-tidy:
5885
desc: Run 'go mod tidy'
86+
vars:
87+
ARGS: '{{default "-v" .CLI_ARGS}}'
5988
cmds:
60-
- go mod tidy -v
89+
- go mod tidy {{.ARGS}}
6190

6291
mod-download:
6392
desc: Run 'go mod download'
@@ -144,10 +173,15 @@ tasks:
144173
- mkdir -p {{.RESULTS_DIR}}
145174
- go tool gotestsum --junitfile="{{.TEST_REPORT}}" -- {{.RACE}} -count=1 {{.ARGS}}
146175

147-
ci:diff:
176+
ci:check:
148177
desc: Check no uncommitted diffs after generate/fmt/tidy
149178
cmds:
150-
- task: generate
151-
- task: fmt
179+
- task: ci:lint
180+
- task: license
181+
vars:
182+
CLI_ARGS: -check .
152183
- task: mod-tidy
184+
vars:
185+
CLI_ARGS: -diff
186+
- task: generate
153187
- git diff --exit-code

licence.go

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)