Skip to content

Commit a4aafbd

Browse files
Parallel exec for UTs and cache go dep (dapr#1226)
* Parallel exec for UTs and cache go dep Signed-off-by: Pravin Pushkar <[email protected]> * update go version Signed-off-by: Pravin Pushkar <[email protected]> --------- Signed-off-by: Pravin Pushkar <[email protected]>
1 parent de997a9 commit a4aafbd

File tree

9 files changed

+113
-6
lines changed

9 files changed

+113
-6
lines changed

.github/workflows/dapr_cli.yaml

+31-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
3030
runs-on: ${{ matrix.os }}
3131
env:
32-
GOVER: 1.19.3
32+
GOVER: 1.19.6
3333
GOLANG_CI_LINT_VER: v1.49.0
3434
GOOS: ${{ matrix.target_os }}
3535
GOARCH: ${{ matrix.target_arch }}
@@ -63,6 +63,36 @@ jobs:
6363
go-version: ${{ env.GOVER }}
6464
- name: Check out code into the Go module directory
6565
uses: actions/checkout@v2
66+
- name: Cache Go modules (Linux)
67+
if: matrix.target_os == 'linux'
68+
uses: actions/cache@v3
69+
with:
70+
path: |
71+
~/.cache/go-build
72+
~/go/pkg/mod
73+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
74+
restore-keys: |
75+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
76+
- name: Cache Go modules (Windows)
77+
if: matrix.target_os == 'windows'
78+
uses: actions/cache@v3
79+
with:
80+
path: |
81+
~\AppData\Local\go-build
82+
~\go\pkg\mod
83+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
84+
restore-keys: |
85+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
86+
- name: Cache Go modules (macOS)
87+
if: matrix.target_os == 'darwin'
88+
uses: actions/cache@v3
89+
with:
90+
path: |
91+
~/Library/Caches/go-build
92+
~/go/pkg/mod
93+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
94+
restore-keys: |
95+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
6696
- name: Run golangci-lint
6797
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
6898
uses: golangci/[email protected]

.github/workflows/kind_e2e.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
name: E2E tests for K8s (KinD)
5151
runs-on: ubuntu-latest
5252
env:
53-
GOVER: 1.19.3
53+
GOVER: 1.19.6
5454
DAPR_RUNTIME_PINNED_VERSION: 1.10.0
5555
DAPR_DASHBOARD_PINNED_VERSION: 0.12.0
5656
DAPR_RUNTIME_LATEST_STABLE_VERSION:
@@ -88,6 +88,15 @@ jobs:
8888
uses: actions/checkout@v2
8989
with:
9090
path: ./src/github.com/dapr/cli
91+
- name: Cache Go modules
92+
uses: actions/cache@v3
93+
with:
94+
path: |
95+
~/.cache/go-build
96+
~/go/pkg/mod
97+
key: ${{ matrix.k8s-version }}-${{ matrix.kind-version }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
98+
restore-keys: |
99+
${{ matrix.k8s-version }}-${{ matrix.kind-version }}-go-${{ env.GOVER }}-
91100
92101
- name: Configure KinD
93102
# Generate a KinD configuration file that uses:

.github/workflows/self_hosted_e2e.yaml

+32-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
name: Run Self-Hosted E2E tests in ${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ matrix.dapr_install_mode }}
3636
runs-on: ${{ matrix.os }}
3737
env:
38-
GOVER: 1.19.3
38+
GOVER: 1.19.6
3939
GOOS: ${{ matrix.target_os }}
4040
GOARCH: ${{ matrix.target_arch }}
4141
GOPROXY: https://proxy.golang.org
@@ -65,7 +65,37 @@ jobs:
6565
with:
6666
go-version: ${{ env.GOVER }}
6767
- name: Check out code into the Go module directory
68-
uses: actions/checkout@v2
68+
uses: actions/checkout@v3
69+
- name: Cache Go modules (Linux)
70+
if: matrix.target_os == 'linux'
71+
uses: actions/cache@v3
72+
with:
73+
path: |
74+
~/.cache/go-build
75+
~/go/pkg/mod
76+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
77+
restore-keys: |
78+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
79+
- name: Cache Go modules (Windows)
80+
if: matrix.target_os == 'windows'
81+
uses: actions/cache@v3
82+
with:
83+
path: |
84+
~\AppData\Local\go-build
85+
~\go\pkg\mod
86+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
87+
restore-keys: |
88+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
89+
- name: Cache Go modules (macOS)
90+
if: matrix.target_os == 'darwin'
91+
uses: actions/cache@v3
92+
with:
93+
path: |
94+
~/Library/Caches/go-build
95+
~/go/pkg/mod
96+
key: ${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
97+
restore-keys: |
98+
${{ matrix.target_os }}-${{ matrix.target_arch }}-go-${{ env.GOVER }}-
6999
- name: Install podman - MacOS
70100
if: matrix.os == 'macos-latest' && matrix.dapr_install_mode == 'complete'
71101
run: |

.github/workflows/upgrade_e2e.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
name: Upgrade path tests (KinD)
5151
runs-on: ubuntu-latest
5252
env:
53-
GOVER: 1.19.3
53+
GOVER: 1.19.6
5454
strategy:
5555
fail-fast: false # Keep running if one leg fails.
5656
matrix:
@@ -80,9 +80,19 @@ jobs:
8080
with:
8181
go-version: ${{ env.GOVER }}
8282
- name: Check out code onto GOPATH
83-
uses: actions/checkout@v2
83+
uses: actions/checkout@v3
8484
with:
8585
path: ./src/github.com/dapr/cli
86+
- name: Cache Go modules
87+
uses: actions/cache@v3
88+
with:
89+
path: |
90+
~/.cache/go-build
91+
~/go/pkg/mod
92+
key: ${{ matrix.k8s-version }}-${{ matrix.kind-version }}-go-${{ env.GOVER }}-${{ hashFiles('**/go.sum') }}
93+
restore-keys: |
94+
${{ matrix.k8s-version }}-${{ matrix.kind-version }}-go-${{ env.GOVER }}-
95+
8696
8797
- name: Configure KinD
8898
# Generate a KinD configuration file that uses:

pkg/standalone/dashboard_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
)
2121

2222
func TestDashboardRun(t *testing.T) {
23+
t.Parallel()
2324
t.Run("build Cmd", func(t *testing.T) {
2425
cmd, err := NewDashboardCmd("", 9090)
2526

pkg/standalone/runfileconfig/run_file_config_parser_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
)
3333

3434
func TestRunConfigFile(t *testing.T) {
35+
t.Parallel()
3536
t.Run("test parse valid run template", func(t *testing.T) {
3637
appsRunConfig := RunFileConfig{}
3738
err := appsRunConfig.parseAppsConfig(validRunFilePath)

pkg/standalone/standalone_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ func TestResolveImageWithGHCR(t *testing.T) {
9696
}
9797

9898
for _, test := range tests {
99+
test := test
99100
t.Run(test.name, func(t *testing.T) {
101+
t.Parallel()
100102
got, err := resolveImageURI(test.args)
101103
assert.Equal(t, test.expectErr, err != nil)
102104
assert.Equal(t, test.expect, got)
@@ -140,7 +142,9 @@ func TestResolveImageWithDockerHub(t *testing.T) {
140142
}
141143

142144
for _, test := range tests {
145+
test := test
143146
t.Run(test.name, func(t *testing.T) {
147+
t.Parallel()
144148
got, err := resolveImageURI(test.args)
145149
assert.Equal(t, test.expectErr, err != nil)
146150
assert.Equal(t, test.expect, got)
@@ -184,7 +188,9 @@ func TestResolveImageWithPrivateRegistry(t *testing.T) {
184188
}
185189

186190
for _, test := range tests {
191+
test := test
187192
t.Run(test.name, func(t *testing.T) {
193+
t.Parallel()
188194
got, err := resolveImageURI(test.args)
189195
assert.Equal(t, test.expectErr, err != nil)
190196
assert.Equal(t, test.expect, got)

tests/e2e/standalone/init_negative_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestStandaloneInitNegatives(t *testing.T) {
3333
require.NoError(t, err, "expected no error on querying for os home dir")
3434

3535
t.Run("run without install", func(t *testing.T) {
36+
t.Parallel()
3637
output, err := cmdRun("")
3738
require.Error(t, err, "expected error status on run without install")
3839
path := filepath.Join(homeDir, ".dapr", "components")
@@ -44,18 +45,21 @@ func TestStandaloneInitNegatives(t *testing.T) {
4445
})
4546

4647
t.Run("list without install", func(t *testing.T) {
48+
t.Parallel()
4749
output, err := cmdList("")
4850
require.NoError(t, err, "expected no error status on list without install")
4951
require.Equal(t, "No Dapr instances found.\n", output)
5052
})
5153

5254
t.Run("stop without install", func(t *testing.T) {
55+
t.Parallel()
5356
output, err := cmdStopWithAppID("test")
5457
require.NoError(t, err, "expected no error on stop without install")
5558
require.Contains(t, output, "failed to stop app id test: couldn't find app id test", "expected output to match")
5659
})
5760

5861
t.Run("uninstall without install", func(t *testing.T) {
62+
t.Parallel()
5963
output, err := cmdUninstall()
6064
require.NoError(t, err, "expected no error on uninstall without install")
6165
require.Contains(t, output, "Removing Dapr from your machine...", "expected output to contain message")

utils/utils_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func TestContainerRuntimeUtils(t *testing.T) {
7575
}
7676

7777
for _, tc := range testcases {
78+
tc := tc
7879
t.Run(tc.name, func(t *testing.T) {
80+
t.Parallel()
7981
actualValid := IsValidContainerRuntime(tc.input)
8082
if actualValid != tc.valid {
8183
t.Errorf("expected %v, got %v", tc.valid, actualValid)
@@ -117,7 +119,9 @@ func TestContains(t *testing.T) {
117119
}
118120

119121
for _, tc := range testcases {
122+
tc := tc
120123
t.Run(tc.name, func(t *testing.T) {
124+
t.Parallel()
121125
actualValid := Contains(tc.input, tc.expected)
122126
if actualValid != tc.valid {
123127
t.Errorf("expected %v, got %v", tc.valid, actualValid)
@@ -160,7 +164,9 @@ func TestGetVersionAndImageVariant(t *testing.T) {
160164
}
161165

162166
for _, tc := range testcases {
167+
tc := tc
163168
t.Run(tc.name, func(t *testing.T) {
169+
t.Parallel()
164170
version, imageVariant := GetVersionAndImageVariant(tc.input)
165171
assert.Equal(t, tc.expectedVersion, version)
166172
assert.Equal(t, tc.expectedImageVariant, imageVariant)
@@ -195,7 +201,9 @@ func TestValidateFilePaths(t *testing.T) {
195201
}
196202

197203
for _, tc := range testcases {
204+
tc := tc
198205
t.Run(tc.name, func(t *testing.T) {
206+
t.Parallel()
199207
actual := ValidateFilePath(tc.input)
200208
assert.Equal(t, tc.expectedErr, actual != nil)
201209
})
@@ -235,7 +243,9 @@ func TestGetAbsPath(t *testing.T) {
235243
}
236244

237245
for _, tc := range testcases {
246+
tc := tc
238247
t.Run(tc.name, func(t *testing.T) {
248+
t.Parallel()
239249
actual := GetAbsPath(baseDir, tc.input)
240250
assert.Equal(t, tc.expected, actual)
241251
})
@@ -262,7 +272,9 @@ func TestReadFile(t *testing.T) {
262272
},
263273
}
264274
for _, tc := range testcases {
275+
tc := tc
265276
t.Run(tc.name, func(t *testing.T) {
277+
t.Parallel()
266278
_, actual := ReadFile(tc.input)
267279
assert.Equal(t, tc.expectedErr, actual != nil)
268280
})
@@ -323,7 +335,9 @@ func TestFindFileInDir(t *testing.T) {
323335
},
324336
}
325337
for _, tc := range testcases {
338+
tc := tc
326339
t.Run(tc.name, func(t *testing.T) {
340+
t.Parallel()
327341
filePath, err := FindFileInDir(tc.input, "dapr.yaml")
328342
assert.Equal(t, tc.expectedErr, err != nil)
329343
assert.Equal(t, tc.expectedFilePath, filePath)
@@ -403,7 +417,9 @@ func TestPrintDetail(t *testing.T) {
403417
}
404418

405419
for _, tc := range testcases {
420+
tc := tc
406421
t.Run(tc.name, func(t *testing.T) {
422+
t.Parallel()
407423
var buf bytes.Buffer
408424
err := PrintDetail(&buf, tc.format, tc.list)
409425
if tc.shouldError {

0 commit comments

Comments
 (0)