Skip to content

Commit 6d79342

Browse files
Init project for the orchestration agent
1 parent 89b55de commit 6d79342

File tree

9 files changed

+380
-14
lines changed

9 files changed

+380
-14
lines changed

.circleci/config.yml

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
version: 2.1
22

3+
parameters:
4+
release-name:
5+
type: string
6+
default: "runner-init"
7+
38
orbs:
49
slack: circleci/[email protected]
510

11+
x-data:
12+
linux_machine_image: &linux_machine_image ubuntu-2204:2024.02.7
13+
go_image: &go_image cimg/go:1.22
14+
615
workflows:
716
main-workflow:
817
jobs:
18+
- lint
919
- prepare-agents:
1020
context: org-global
1121
- build-and-publish-images:
@@ -30,15 +40,46 @@ workflows:
3040
- build-and-publish-image-amd64
3141
- build-and-publish-image-arm64
3242

33-
parameters:
34-
release-name:
35-
type: string
36-
default: "runner-init"
37-
3843
jobs:
44+
lint:
45+
docker:
46+
- image: *go_image
47+
resource_class: circleci-runner/rum-large
48+
steps:
49+
- setup
50+
- run:
51+
name: Lint report
52+
command: ./do lint-report
53+
- run:
54+
name: Check `go mod tidy`
55+
command: |
56+
./do go-mod-tidy
57+
git --no-pager diff --exit-code go.mod go.sum
58+
- run:
59+
name: Check the CHANGELOG.md has been updated
60+
command: |
61+
if [[ -z "${CIRCLE_PULL_REQUEST}" ]] && [[ "${CIRCLE_BRANCH}" != 'main' ]]; then
62+
echo 'Only check on a PR or main' && exit 0
63+
fi
64+
65+
if git --no-pager diff main --exit-code changelog.md; then
66+
# Only check actual customer-facing changes have been made
67+
git --no-pager diff main --exit-code -- \
68+
':*.go' \
69+
':*Dockerfile' \
70+
':!*_test.go' \
71+
':!*internal/*'
72+
fi
73+
- run:
74+
name: Try running `./do lint --fix` if this fails
75+
command: ./do lint
76+
when: on_fail
77+
- store_results
78+
- notify_failing_main
79+
3980
prepare-agents:
4081
machine:
41-
image: ubuntu-2204:2024.02.7
82+
image: *linux_machine_image
4283
resource_class: large
4384
steps:
4485
- checkout
@@ -60,7 +101,7 @@ jobs:
60101
type: string
61102
default: amd64
62103
machine:
63-
image: ubuntu-2204:2024.02.7
104+
image: *linux_machine_image
64105
resource_class: << parameters.resource>>
65106
steps:
66107
- checkout
@@ -77,7 +118,7 @@ jobs:
77118

78119
publish-manifest:
79120
machine:
80-
image: ubuntu-2204:2024.02.7
121+
image: *linux_machine_image
81122
resource_class: small
82123
steps:
83124
- checkout
@@ -86,13 +127,33 @@ jobs:
86127
- notify_failing_main
87128

88129
commands:
130+
setup:
131+
steps:
132+
- checkout
133+
- run: go mod download
134+
- run: ./do install-devtools
135+
136+
store_results:
137+
steps:
138+
- run:
139+
name: Strip ANSI codes from xunit output
140+
when: always
141+
command: |
142+
# The test output produces ANSI codes, which the XML writer converts into annoying
143+
# \0xfffd characters - we'll strip these out to make the XML a bit more readable
144+
sed -i 's/�\[[0-9;]*[a-zA-Z]//g' test-reports/*.xml || true
145+
- store_artifacts:
146+
path: test-reports
147+
- store_test_results:
148+
path: test-reports
149+
89150
docker_login:
90151
steps:
91152
- run:
92153
name: "Log into Docker Hub"
93154
command: |
94155
docker login -u "${DOCKER_HUB_USER}" -p "${DOCKER_HUB_PASSWORD}"
95-
156+
96157
notify_failing_main:
97158
steps:
98159
- slack/notify:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
:gear: **Issue**
2+
3+
**Ticket/s**:
4+
5+
---
6+
7+
:gear: **Change Description**
8+
9+
**Change Type**:
10+
11+
*Why this change? Reference the ticket and acceptance criteria if any. Specify the type of change: bug fix, new feature, breaking change, documentation update, security, etc.*
12+
13+
**Acceptance Criteria**:
14+
15+
---
16+
17+
:white_check_mark: **Solution**
18+
19+
*What was the solution? How did you fix the issue or implement the new feature?*
20+
21+
---
22+
23+
:question: **Testing**
24+
25+
*Describe what was tested. Remember to include changes in functionality, edge cases, and enough detail that another developer can replicate your progress.*
26+
27+
- [ ] Created and updated tests where applicable
28+
29+
---
30+
31+
:book: **Documentation Updates**
32+
33+
*Have any updates been made to the documentation?*
34+
35+
- [ ] Updated related documentation, if applicable
36+
- [ ] Updated [changelog](https://github.com/circleci/runner-init/blob/main/CHANGELOG.md)

.golangci.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
run:
2+
build-tags:
3+
- smoke
4+
5+
# Do not treat these as gospel, adjust as appropriate
6+
linters-settings:
7+
govet:
8+
check-shadowing: false
9+
golint:
10+
min-confidence: 0
11+
gocyclo:
12+
min-complexity: 15
13+
maligned:
14+
suggest-new: true
15+
depguard:
16+
rules:
17+
main:
18+
deny:
19+
- pkg: log
20+
- pkg: github.com/davecgh/go-spew
21+
- pkg: github.com/cenkalti/backof[f]
22+
desc: use github.com/cenkalti/backoff/v4 instead
23+
- pkg: gotest.tools/assert
24+
desc: use gotest.tools/v3/assert instead
25+
- pkg: gotest.tools/assert/cmp
26+
desc: use gotest.tools/v3/assert/cmp instead
27+
- pkg: gotest.tools/env
28+
desc: use gotest.tools/v3/env instead
29+
- pkg: gotest.tools/fs
30+
desc: use gotest.tools/v3/fs instead
31+
- pkg: gotest.tools/golden
32+
desc: use gotest.tools/v3/golden instead
33+
- pkg: gotest.tools/icmd
34+
desc: use gotest.tools/v3/icmd instead
35+
- pkg: gotest.tools/poll
36+
desc: use gotest.tools/v3/poll instead
37+
- pkg: gotest.tools/skip
38+
desc: use gotest.tools/v3/skip instead
39+
dupl:
40+
threshold: 100
41+
goconst:
42+
min-len: 6
43+
min-occurrences: 8
44+
lll:
45+
line-length: 120
46+
funlen:
47+
lines: 80
48+
goimports:
49+
local-prefixes: github.com/circleci/runner-init
50+
nakedret:
51+
max-func-lines: 0
52+
gci:
53+
sections:
54+
- standard
55+
- default
56+
- prefix(github.com/circleci/runner-init)
57+
custom-order: true
58+
59+
issues:
60+
# If the default exclude list seems rather aggressive, opt in when needed instead
61+
exclude-use-default: false
62+
63+
exclude-rules:
64+
# Duplicated errcheck checks
65+
- linters: [gosec]
66+
text: G104
67+
# Ignore aliasing in tests
68+
- linters: [gosec]
69+
text: G601
70+
path: _test\.go
71+
# Non-secure URLs are okay in tests
72+
- linters: [gosec]
73+
text: G107
74+
path: _test\.go
75+
# Duplicated errcheck checks
76+
- linters: [revive]
77+
text: 'package-comments: should have a package comment'
78+
# Nil pointers will fail tests anyway
79+
- linters: [staticcheck]
80+
text: SA5011
81+
path: _test\.go
82+
# Duplicated errcheck checks
83+
- linters: [staticcheck]
84+
text: SA5001
85+
# Duplicated function naming check
86+
- linters: [stylecheck]
87+
text: ST1003
88+
# We don't require comments on everything
89+
- linters: [golint]
90+
text: should have( a package)? comment
91+
# Very long lines are ok if they're URLs
92+
- linters: [lll]
93+
source: https?://
94+
# Very long lines are ok if they're in http response message fields
95+
- linters: [ lll ]
96+
source: '"message":'
97+
# Very long lines are ok if they're in CLI config
98+
- linters: [ lll ]
99+
source: 'env:"'
100+
# Ignore errcheck on a deferred Close
101+
- linters: [errcheck]
102+
source: ^\s*defer .*\.Close(.*)$
103+
# Ignore long tests
104+
- linters: [funlen]
105+
text: ^Function 'Test.*
106+
# Ignore fixture setup
107+
- linters: [funlen]
108+
text: ^Function 'runServices.*
109+
# We don't require package docs
110+
- linters: [stylecheck]
111+
text: ST1000
112+
# unparam is allowed in tests
113+
- linters: [unparam]
114+
path: _test\.go
115+
# We aren't that bothered about undocumented structs
116+
- linters: [revive]
117+
text: 'exported:'
118+
# I'd rather keep all assignments to ctx, actually
119+
- linters: [ineffassign]
120+
text: 'ineffectual assignment to ctx'
121+
# Duplicate of above
122+
- linters: [staticcheck]
123+
text: 'SA4006: this value of `ctx` is never used'
124+
- linters: [gocyclo]
125+
text: func `TestE2E.*
126+
127+
linters:
128+
disable-all: true
129+
enable:
130+
- bodyclose
131+
- depguard
132+
- errcheck
133+
- funlen
134+
- gci
135+
- goconst
136+
- gocyclo
137+
- gofmt
138+
- goimports
139+
- gosec
140+
- gosimple
141+
- govet
142+
- ineffassign
143+
- lll
144+
- misspell
145+
- nakedret
146+
- prealloc
147+
- revive
148+
- staticcheck
149+
- stylecheck
150+
- typecheck
151+
- unconvert
152+
- unparam
153+
- unused

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# CircleCI Init Changelog
2+
3+
This document serves to keep track of all changes made to the Runner init images and agents. Please follow the guidelines below while adding an entry:
4+
5+
- Each code change that is not related to tests or CI/CD should have its own entry under the `Edge` section.
6+
- Every entry should include the pull request number associated with the change.
7+
- Internal changes with no visible or functional impact on users should be marked as 'Internal'.
8+
9+
By following these guidelines, we can easily determine which changes should be included in the public changelog located at [https://circleci.com/changelog/runner/](https://circleci.com/changelog/runner/). Thank you for your contribution!
10+
11+
## Edge
12+
13+
- [#10] [INTERNAL] Set up linting tools, initiated a changelog, and performed other configurations in preparation for the orchestration agent.

0 commit comments

Comments
 (0)