Skip to content

Commit 9f29754

Browse files
authored
Merge pull request #2896 from gophercloud/revert-2891-t
Revert "test: Restructure actions"
2 parents 2e3f8f7 + 833d504 commit 9f29754

7 files changed

Lines changed: 68 additions & 44 deletions

File tree

.github/workflows/go-fmt.yaml

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

.github/workflows/go-vet.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ permissions:
66
jobs:
77
test:
88
runs-on: ubuntu-latest
9-
109
steps:
1110
- uses: actions/checkout@v4
1211
- uses: actions/setup-go@v5
1312
with:
1413
go-version: '1'
15-
16-
- run: |
17-
if [ $(go mod tidy && git diff | wc -l) -gt 0 ]; then git diff && exit 1; fi
14+
- run: if [ $(go mod tidy && git diff | wc -l) -gt 0 ]; then git diff && exit 1; fi
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ jobs:
77
test:
88
runs-on: ubuntu-latest
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
go-version:
12-
- '1'
13+
- "1"
1314

1415
steps:
1516
- name: Setup Go ${{ matrix.go-version }}
@@ -21,4 +22,4 @@ jobs:
2122

2223
- name: Run reauth retests
2324
run: |
24-
go test -v -race -count=5 ./testing
25+
./script/unittest

.github/workflows/unit.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
on: [push, pull_request]
2-
name: Unit tests
2+
name: Unit Testing
33
permissions:
44
contents: read
55

@@ -13,20 +13,32 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
go-version:
16-
- '1.21'
17-
- '1'
16+
- "1.21"
17+
- "1"
18+
19+
env:
20+
GO111MODULE: "on"
1821

1922
steps:
20-
- uses: actions/checkout@v4
2123
- name: Setup Go ${{ matrix.go-version }}
2224
uses: actions/setup-go@v5
2325
with:
2426
go-version: ${{ matrix.go-version }}
2527

28+
- uses: actions/checkout@v4
2629

2730
- name: Setup environment
2831
run: |
32+
# Changing into a different directory to avoid polluting go.sum with "go get"
33+
cd "$(mktemp -d)"
34+
go mod init unit_tests
35+
2936
go install github.com/wadey/gocovmerge@master
37+
go install golang.org/x/tools/cmd/goimports@latest
38+
39+
- name: Run go vet
40+
run: |
41+
go vet ./...
3042
3143
- name: Run unit tests
3244
run: |

script/format

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
goimports="goimports"
4+
5+
find_files() {
6+
find . -not \( \
7+
\( \
8+
-wholename './output' \
9+
-o -wholename './_output' \
10+
-o -wholename './_gopath' \
11+
-o -wholename './release' \
12+
-o -wholename './target' \
13+
-o -wholename '*/third_party/*' \
14+
-o -wholename '*/vendor/*' \
15+
\) -prune \
16+
\) -name '*.go'
17+
}
18+
19+
ignore_files=(
20+
"./openstack/compute/v2/extensions/quotasets/testing/fixtures.go"
21+
"./openstack/networking/v2/extensions/vpnaas/ikepolicies/testing/requests_test.go"
22+
)
23+
24+
bad_files=$(find_files | xargs ${goimports} -l)
25+
26+
final_files=()
27+
for bad_file in $bad_files; do
28+
found=
29+
for ignore_file in "${ignore_files[@]}"; do
30+
[[ "${bad_file}" == "${ignore_file}" ]] && { found=1; break; }
31+
done
32+
[[ -n $found ]] || final_files+=("$bad_file")
33+
done
34+
35+
if [[ "${#final_files[@]}" -gt 0 ]]; then
36+
diff=$(echo "${final_files[@]}" | xargs ${goimports} -d -e 2>&1)
37+
if [[ -n "${diff}" ]]; then
38+
echo "${diff}"
39+
exit 1
40+
fi
41+
fi

script/unittest

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
#
3+
# Run the unit tests.
4+
5+
# Do extra rounds of testing to help identify reauth concurrency issues.
6+
# All other packages are tested in the `coverage` tests.
7+
go test -v -race -count=5 ./testing

0 commit comments

Comments
 (0)