Skip to content

Commit 1c5f057

Browse files
carlydfCopilot
andauthored
Integration test framework (#78)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed Add integration tests Add CI job running linters, unit tests, and integration tests There is one TODO left in the test setup for creating a draining version. Not all possible pre-existing version statuses are tested right now, but this is ready for review while I concurrently add a few more test cases. ## Why? So that we don't break things ## Checklist <!--- add/delete as needed ---> 1. Closes <!-- add issue number here --> 2. How was this tested: <!--- Please describe how you tested your changes/how we can test them --> 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io --> --------- Co-authored-by: Copilot <[email protected]>
1 parent 4e67acc commit 1c5f057

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4126
-484
lines changed

.github/.golangci.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# https://golangci-lint.run/usage/configuration/#config-file
2+
linters:
3+
disable-all: true
4+
enable:
5+
- errcheck
6+
- goimports
7+
- importas
8+
# - paralleltest # missing the call to method parallel, but testify does not seem to work well with parallel test: https://github.com/stretchr/testify/issues/187
9+
- revive # revive supersedes golint, which is now archived
10+
- staticcheck
11+
- govet
12+
- forbidigo
13+
- exhaustive
14+
- godox
15+
issues:
16+
exclude-dirs:
17+
- ^api
18+
- ^proto
19+
- ^.git
20+
exclude-rules:
21+
- path-except: _test\.go|internal/tests/.+\.go
22+
text: "time.Sleep"
23+
linters:
24+
- forbidigo
25+
- path: _test\.go|internal/tests/.+\.go
26+
text: "(cyclomatic|cognitive)" # false positives when using subtests
27+
linters:
28+
- revive
29+
- path: _test\.go|internal/tests/.+\.go
30+
text: "(dot-imports|unchecked-type-assertion)" # helpful in tests
31+
linters:
32+
- revive
33+
- path: ^tools\/.+\.go
34+
linters:
35+
- revive
36+
linters-settings:
37+
godox:
38+
keywords:
39+
- FIXME # marks TODOs that must be fixed before merging
40+
govet:
41+
fieldalignment: 0
42+
forbidigo:
43+
forbid:
44+
- p: panic
45+
msg: "Please avoid using panic in application code"
46+
importas:
47+
# Enforce the aliases below.
48+
no-unaliased: true
49+
# Still allow aliases outside of the rules below.
50+
no-extra-aliases: false
51+
alias:
52+
# no pb services (or their mocks) are aliased - must be at the top!
53+
- pkg: go.temporal.io(/server)?/api/(\w+)service(mock)?/v1
54+
alias: # ie no alias - this can only be specified once!
55+
# public API pbs have a suffix
56+
- pkg: go.temporal.io/api/(\w+)/v1
57+
alias: ${1}pb
58+
# internal server pbs have their own suffix to avoid naming conflicts
59+
- pkg: go.temporal.io/server/api/(\w+)/v1
60+
alias: ${1}spb
61+
exhaustive:
62+
# Presence of "default" case in switch statements satisfies exhaustiveness,
63+
# even if all enum members are not listed.
64+
# Default: false
65+
default-signifies-exhaustive: true
66+
revive:
67+
severity: error
68+
confidence: 0.8
69+
enable-all-rules: true
70+
rules:
71+
# Disabled rules
72+
- name: add-constant
73+
disabled: true
74+
- name: argument-limit
75+
disabled: true
76+
- name: bare-return
77+
disabled: true
78+
- name: banned-characters
79+
disabled: true
80+
- name: bool-literal-in-expr
81+
disabled: true
82+
- name: confusing-naming
83+
disabled: true
84+
- name: empty-lines
85+
disabled: true
86+
- name: error-naming
87+
disabled: true
88+
- name: errorf
89+
disabled: true
90+
- name: exported
91+
disabled: true
92+
- name: file-header
93+
disabled: true
94+
- name: function-length
95+
disabled: true
96+
- name: imports-blacklist
97+
disabled: true
98+
- name: increment-decrement
99+
disabled: true
100+
- name: line-length-limit
101+
disabled: true
102+
- name: max-public-structs
103+
disabled: true
104+
- name: nested-structs
105+
disabled: true
106+
- name: package-comments
107+
disabled: true
108+
- name: string-format
109+
disabled: true
110+
- name: unexported-naming
111+
disabled: true
112+
- name: unexported-return
113+
disabled: true
114+
- name: unused-parameter
115+
disabled: true
116+
- name: unused-receiver
117+
disabled: true
118+
- name: use-any
119+
disabled: true
120+
- name: var-naming
121+
disabled: true
122+
- name: empty-block
123+
disabled: true
124+
- name: flag-parameter
125+
disabled: true
126+
- name: unnecessary-stmt
127+
disabled: true
128+
- name: range-val-in-closure
129+
disabled: true
130+
131+
# Rule tuning
132+
- name: cognitive-complexity
133+
arguments:
134+
- 25
135+
- name: cyclomatic
136+
arguments:
137+
- 25
138+
- name: function-result-limit
139+
arguments:
140+
- 5
141+
- name: unhandled-error
142+
arguments:
143+
- "fmt.*"
144+
- "bytes.Buffer.*"
145+
- "strings.Builder.*"

.github/workflows/linters.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: linters
2+
on:
3+
pull_request:
4+
permissions:
5+
contents: read
6+
jobs:
7+
lint-actions:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version-file: 'go.mod'
17+
check-latest: true
18+
19+
- name: lint actions
20+
run: |
21+
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
22+
make lint-actions
23+
shell: bash
24+
25+
fmt-imports:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version-file: 'go.mod'
35+
check-latest: true
36+
37+
- name: format golang import statements
38+
run: |
39+
make fmt-imports
40+
41+
- name: check-is-dirty
42+
run: |
43+
if [[ -n $(git status --porcelain) ]]; then
44+
echo "Detected uncommitted changes."
45+
git status
46+
git diff
47+
exit 1
48+
fi
49+
50+
golangci:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 0
56+
57+
- uses: actions/setup-go@v5
58+
with:
59+
go-version-file: 'go.mod'
60+
check-latest: true
61+
62+
- name: lint code
63+
run: |
64+
make GOLANGCI_LINT_FIX=false GOLANGCI_LINT_BASE_REV=HEAD~ lint-code
65+
66+
- name: check-is-dirty
67+
run: |
68+
if [[ -n $(git status --porcelain) ]]; then
69+
echo "Detected uncommitted changes."
70+
git status
71+
git diff
72+
exit 1
73+
fi
74+
75+
linters-succeed:
76+
name: All Linters Succeed
77+
needs:
78+
- lint-actions
79+
- fmt-imports
80+
- golangci
81+
runs-on: ubuntu-latest
82+
if: always()
83+
env:
84+
RESULTS: ${{ toJSON(needs.*.result) }}
85+
steps:
86+
- name: Check results
87+
run: |
88+
if [[ -n $(echo "$RESULTS" | jq '.[] | select (. != "success")') ]]; then
89+
exit 1
90+
fi
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Integration Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
test-integration:
10+
name: Run Integration Tests
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.21'
21+
cache: true
22+
23+
- name: Install Temporal CLI
24+
run: |
25+
curl -sSf https://temporal.download/cli.sh | sh
26+
echo "$HOME/.temporalio/bin" >> "$GITHUB_PATH"
27+
28+
- name: Install kubectl
29+
uses: azure/setup-kubectl@v3
30+
with:
31+
version: 'latest'
32+
33+
- name: Install Helm
34+
uses: azure/setup-helm@v3
35+
with:
36+
version: 'v3.14.3'
37+
38+
- name: Install controller-gen
39+
run: |
40+
go install sigs.k8s.io/controller-tools/cmd/[email protected]
41+
42+
- name: Install envtest
43+
run: |
44+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
45+
46+
- name: Download dependencies
47+
run: go mod download
48+
49+
- name: Run integration tests
50+
run: make test-integration
51+
52+
- name: Upload test results
53+
if: always()
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: test-results
57+
path: |
58+
cover.out
59+
bin/
60+
retention-days: 7
61+
62+
unit-test:
63+
name: Run Unit Tests
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Set up Go
71+
uses: actions/setup-go@v5
72+
with:
73+
go-version: '1.21'
74+
cache: true
75+
76+
- name: Download dependencies
77+
run: go mod download
78+
79+
- name: Run unit tests
80+
run: make test-unit
81+
82+
- name: Upload test results
83+
if: always()
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: unit-test-results
87+
path: |
88+
cover.out
89+
bin/
90+
retention-days: 7
91+
92+
go-vet:
93+
name: Run Go Vet
94+
runs-on: ubuntu-latest
95+
96+
steps:
97+
- name: Checkout code
98+
uses: actions/checkout@v4
99+
100+
- name: Set up Go
101+
uses: actions/setup-go@v5
102+
with:
103+
go-version: '1.21'
104+
cache: true
105+
106+
- name: Download dependencies
107+
run: go mod download
108+
109+
- name: Run go vet
110+
run: go vet ./...

0 commit comments

Comments
 (0)