-
Notifications
You must be signed in to change notification settings - Fork 158
178 lines (150 loc) · 5.1 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: main
on:
push:
branches:
- master
pull_request:
branches:
- '*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache: true
go-version-file: 'go.mod'
- name: Download dependencies
run: |
go mod download -x
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v e2e)
- name: Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
- name: Run linters
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.48
args: --verbose
# See: https://github.com/golangci/golangci-lint-action/issues/244
skip-pkg-cache: true
skip-build-cache: true
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
with:
severity: warning
- name: Build
run: |
go build -v -o ./bin/helm-s3 ./cmd/helm-s3
test-e2e:
name: Run end-to-end tests
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
helm:
- 2.17.0
- 3.12.3
- 3.13.1
services:
minio:
# TODO: use official minio/minio image when this issue is fixed:
# https://github.community/t/how-do-i-properly-override-a-service-entrypoint/17435
# Meanwhile, there is a workaround with custom image build with CMD set.
# See hack/minio/Dockerfile
image: hypnoglow/minio:latest
env:
MINIO_ACCESS_KEY: EXAMPLEKEY123
MINIO_SECRET_KEY: EXAMPLESECRET123456
ports:
- 9000:9000
env:
AWS_ENDPOINT: localhost:9000
AWS_ACCESS_KEY_ID: EXAMPLEKEY123
AWS_SECRET_ACCESS_KEY: EXAMPLESECRET123456
AWS_DISABLE_SSL: true
AWS_DEFAULT_REGION: us-east-1
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache: true
go-version-file: 'go.mod'
- name: Download dependencies
run: |
go mod download -x
- name: Install helm
run: |
helm_version="${{ matrix.helm }}"
curl -sSL https://get.helm.sh/helm-v${helm_version}-linux-amd64.tar.gz | tar xz
mv linux-amd64/helm $(go env GOPATH)/bin/helm
rm -rf linux-amd64
# Run `helm init` only for helm v2
if [ "${helm_version:0:1}" == "2" ]; then
helm init --client-only
fi
# Add `stable` repo only for helm v3
if [ "${helm_version:0:1}" == "3" ]; then
helm repo add stable https://charts.helm.sh/stable
fi
- name: Build and install the plugin
run: |
plugin_version="commit.${{ github.sha }}"
tmp_dir="$(mktemp -d)"
go build \
-o bin/helm-s3 \
-ldflags "-X main.version=${plugin_version}" \
./cmd/helm-s3
# Copy plugin directory to outside of the workspace.
cp -r ${{ github.workspace }} ${tmp_dir}
# Correct the plugin manifest to make installation purely local
cd ${tmp_dir}/helm-s3
sed -i "/^hooks:/,+2 d" plugin.yaml
sed -i "s/^version:.*$/version: ${plugin_version}/" plugin.yaml
helm plugin install ${tmp_dir}/helm-s3
- name: Install minio client, prepare minio server
run: |
curl -sSL https://dl.minio.io/client/mc/release/linux-amd64/mc -o $(go env GOPATH)/bin/mc
chmod +x $(go env GOPATH)/bin/mc
mc config host add helm-s3-minio http://${AWS_ENDPOINT} ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}
mc mb helm-s3-minio/test-bucket
- name: Run tests
run: |
go test -v ./tests/e2e/...
docker-images:
name: Build Docker images
needs:
- test-e2e
uses: ./.github/workflows/reusable-docker-images.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# This job's only purpose is to be used for the "Require status checks to pass
# before merging" feature.
status-check:
name: "Status check"
needs:
- build
- test-e2e
- docker-images
if: always()
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
test-install:
name: Test plugin installation
needs:
- test-e2e
uses: ./.github/workflows/reusable-test-install.yml
if: github.ref_name == 'master'