Skip to content

Commit 66ec7dd

Browse files
committed
Managed by Terraform: Update config.yml github workflow
1 parent 270b9ff commit 66ec7dd

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed

.circleci/config.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
orbs:
2+
win: circleci/windows@1.0.0
3+
4+
version: 2.1
5+
6+
executors:
7+
golang:
8+
docker:
9+
- image: docker.mirror.hashicorp.services/circleci/golang:1.16
10+
resource_class: medium+
11+
darwin:
12+
macos:
13+
xcode: "12.0.0"
14+
15+
commands:
16+
install-go-run-tests-unix:
17+
parameters:
18+
GOOS:
19+
type: string
20+
GOVERSION:
21+
type: string
22+
HOME:
23+
type: string
24+
default: "~"
25+
steps:
26+
- checkout
27+
- run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.<< parameters.GOOS >>-amd64.tar.gz | tar -C << parameters.HOME >>/ -xz
28+
- run: << parameters.HOME >>/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic
29+
install-go-run-tests-windows:
30+
parameters:
31+
GOVERSION:
32+
type: string
33+
steps:
34+
- checkout
35+
- run: curl https://dl.google.com/go/go<< parameters.GOVERSION >>.windows-amd64.zip --output ~/go<< parameters.GOVERSION >>.windows-amd64.zip
36+
- run: unzip ~/go<< parameters.GOVERSION >>.windows-amd64.zip -d ~/
37+
- run: ~/go/bin/go test ./... -coverprofile=coverage.txt -covermode=atomic
38+
build-and-persist-plugin-binary:
39+
parameters:
40+
GOOS:
41+
type: string
42+
GOARCH:
43+
default: "amd64"
44+
type: string
45+
steps:
46+
- checkout
47+
- run: GOOS=<< parameters.GOOS >> GOARCH=<<parameters.GOARCH>> go build -o ./pkg/packer_plugin_hyperv_<< parameters.GOOS >>_<< parameters.GOARCH >> .
48+
- run: zip ./pkg/packer_plugin_hyperv_<< parameters.GOOS >>_<< parameters.GOARCH >>.zip ./pkg/packer_plugin_hyperv_<< parameters.GOOS >>_<< parameters.GOARCH >>
49+
- run: rm ./pkg/packer_plugin_hyperv_<< parameters.GOOS >>_<< parameters.GOARCH >>
50+
- persist_to_workspace:
51+
root: .
52+
paths:
53+
- ./pkg/
54+
55+
# Golang CircleCI 2.0 configuration file
56+
#
57+
# Check https://circleci.com/docs/2.0/language-go/ for more details
58+
jobs:
59+
test-linux:
60+
executor: golang
61+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
62+
steps:
63+
- checkout
64+
- run: go test -count 1 ./... -coverprofile=coverage.txt -covermode=atomic -timeout=3m
65+
test-darwin:
66+
executor: darwin
67+
working_directory: ~/go/github.com/hashicorp/packer-plugin-hyperv
68+
steps:
69+
- install-go-run-tests-unix:
70+
GOOS: darwin
71+
GOVERSION: "1.16"
72+
test-windows:
73+
executor:
74+
name: win/vs2019
75+
shell: bash.exe
76+
steps:
77+
- install-go-run-tests-windows:
78+
GOVERSION: "1.16"
79+
check-lint:
80+
executor: golang
81+
steps:
82+
- checkout
83+
- run: git fetch --all
84+
- run:
85+
command: |
86+
echo "==> Updating linter dependencies..."
87+
curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.8
88+
echo "==> Running linter on newly added Go source files..."
89+
GO111MODULE=on golangci-lint run --new-from-rev=$(shell git merge-base origin/main HEAD) ./...
90+
no_output_timeout: 30m
91+
check-fmt:
92+
executor: golang
93+
steps:
94+
- checkout
95+
- run: |
96+
go fmt ./...
97+
echo "==> Checking that code complies with go fmt requirements..."
98+
git diff --exit-code; if [ $$? -eq 1 ]; then \
99+
echo "Found files that are not fmt'ed."; \
100+
echo "You can use the command: \`go fmt ./...\` to reformat code."; \
101+
exit 1; \
102+
fi
103+
check-generate:
104+
executor: golang
105+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
106+
steps:
107+
- checkout
108+
- run: |
109+
make generate
110+
echo "==> Checking that auto-generated code is not changed..."
111+
git diff --exit-code; if [ $$? -eq 1 ]; then \
112+
echo "Found diffs in go generated code."; \
113+
echo "You can use the command: \`make generate\` to reformat code."; \
114+
exit 1; \
115+
fi
116+
build_linux:
117+
executor: golang
118+
steps:
119+
- build-and-persist-plugin-binary:
120+
GOOS: linux
121+
build_windows:
122+
executor: golang
123+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
124+
steps:
125+
- build-and-persist-plugin-binary:
126+
GOOS: windows
127+
build_darwin:
128+
executor: golang
129+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
130+
steps:
131+
- build-and-persist-plugin-binary:
132+
GOOS: darwin
133+
build_darwin_arm64:
134+
executor: golang
135+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
136+
steps:
137+
- build-and-persist-plugin-binary:
138+
GOOS: darwin
139+
GOARCH: arm64
140+
build_freebsd:
141+
executor: golang
142+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
143+
steps:
144+
- build-and-persist-plugin-binary:
145+
GOOS: freebsd
146+
build_solaris:
147+
executor: golang
148+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
149+
steps:
150+
- build-and-persist-plugin-binary:
151+
GOOS: solaris
152+
build_openbsd:
153+
executor: golang
154+
working_directory: /go/src/github.com/hashicorp/packer-plugin-hyperv
155+
steps:
156+
- build-and-persist-plugin-binary:
157+
GOOS: openbsd
158+
store_artifacts:
159+
executor: golang
160+
steps:
161+
- attach_workspace:
162+
at: .
163+
- store_artifacts:
164+
path: ./pkg/
165+
destination: /
166+
167+
workflows:
168+
version: 2
169+
test:
170+
jobs:
171+
- test-linux
172+
- test-darwin
173+
- test-windows
174+
check-code:
175+
jobs:
176+
- check-lint
177+
- check-fmt
178+
- check-generate
179+
build_plugin_binaries:
180+
jobs:
181+
- build_linux
182+
- build_darwin
183+
- build_darwin_arm64
184+
- build_windows
185+
- build_freebsd
186+
- build_openbsd
187+
- build_solaris
188+
- store_artifacts:
189+
requires:
190+
- build_linux
191+
- build_darwin
192+
- build_darwin_arm64
193+
- build_windows
194+
- build_freebsd
195+
- build_openbsd
196+
- build_solaris

0 commit comments

Comments
 (0)