forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (227 loc) · 12.6 KB
/
reusable-misc-tests.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Misc Tests
on:
workflow_call:
inputs:
BUILT_EARTHLY_PATH:
required: true
type: string
BUILD_EARTHLY_TARGET:
required: true
type: string
BINARY:
required: true
type: string
SUDO:
type: string
required: false
RUNS_ON:
required: true
type: string
jobs:
misc-tests:
runs-on: ${{inputs.RUNS_ON}}
env:
FORCE_COLOR: 1
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
EARTHLY_INSTALL_ID: "earthly-githubactions"
# Used in our github action as the token - TODO: look to change it into an input
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: earthly/actions-setup@main
- name: Set up Docker QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
if: inputs.BINARY == 'docker'
- uses: actions/setup-go@v1
with:
go-version: 1.17
- name: remove Docker
run: ${{inputs.SUDO}} apt-get purge docker-engine docker docker.io docker-ce docker-ce-cli ; ${{inputs.SUDO}} rm -rf /usr/bin/docker
if: inputs.binary == 'podman'
- name: Install Podman (with apt-get)
run: ${{inputs.SUDO}} apt-get update && ${{inputs.SUDO}} apt-get install -y podman
if: inputs.binary == 'podman'
- name: Podman debug info
run: podman version && podman info && podman info --debug
if: inputs.binary == 'podman'
- name: Docker mirror login (Earthly Only)
run: ${{inputs.SUDO}} ${{inputs.BINARY}} login registry-1.docker.io.mirror.corp.earthly.dev --username "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" --password "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Configure Earthly to use mirror (Earthly Only)
run: |-
earthly config global.buildkit_additional_config "'[registry.\"docker.io\"]
mirrors = [\"registry-1.docker.io.mirror.corp.earthly.dev\"]'"
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Link Earthly dir to Earthly dev dir
run: mkdir -p ~/.earthly && ln -s ~/.earthly ~/.earthly-dev
- name: Build latest earthly using released earthly
run: ${{inputs.SUDO}} $(which earthly) -P --use-inline-cache ${{inputs.BUILD_EARTHLY_TARGET}}
- name: rebuild earthly using latest earthly build
run: ${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --use-inline-cache ${{inputs.BUILD_EARTHLY_TARGET}}
- name: Set EARTHLY_VERSION_FLAG_OVERRIDES env
run: |-
set -euo pipefail
EARTHLY_VERSION_FLAG_OVERRIDES="$(tr -d '\n' < .earthly_version_flag_overrides)"
echo "EARTHLY_VERSION_FLAG_OVERRIDES=$EARTHLY_VERSION_FLAG_OVERRIDES" >> "$GITHUB_ENV"
- name: Build the earthly docker image
run: ${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} +earthly-docker --TAG=image-test
- name: "Run the earthly image tests (Earthly only)"
run: FRONTEND=${{inputs.BINARY}} EARTHLY_IMAGE=earthly/earthly:image-test DOCKERHUB_MIRROR_USERNAME="${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" DOCKERHUB_MIRROR_PASSWORD="${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}" ./scripts/tests/earthly-image.sh
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Run parallel buildkit start test. It ensures that earthly starting up buildkit does not race with itself.
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: |-
${{inputs.SUDO}} ${{inputs.BINARY}} stop earthly-buildkitd && \
for i in 1 2 3 4; do
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} github.com/earthly/hello-world+hello & \
pids[${i}]=$!
done && \
for pid in ${pids[*]}; do
wait $pid
done
- name: Execute interactive debugger test
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: ./scripts/tests/interactive-debugger/test-interactive.py --earthly ${{inputs.BUILT_EARTHLY_PATH}} --timeout 180
- name: "cloud-stored docker credential test (Earthly only)"
run: FRONTEND=${{inputs.BINARY}} earthly=${{inputs.BUILT_EARTHLY_PATH}} ./scripts/tests/cloud-docker-credentials-integration.sh
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute version test
run: "${{inputs.BUILT_EARTHLY_PATH}} --version"
- name: Execute docker2earth test
run: "./tests/docker2earth/test.sh"
- name: Execute remote-cache test (Earthly Only)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: |-
frontend=${{inputs.BINARY}} ./tests/remote-cache/test.sh \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute remote-cache test (Fork Only)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: frontend=${{inputs.BINARY}} ./tests/remote-cache/test.sh --build-arg DOCKERHUB_AUTH=false
if: github.event_name != 'push' && github.event.pull_request.head.repo.full_name != github.repository
- name: Execute registry-certs test (Earthly Only)
run: |-
frontend=${{inputs.BINARY}} ./tests/registry-certs/test.sh \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute registry-certs test (Fork Only)
run: frontend=${{inputs.BINARY}} ./tests/registry-certs/test.sh --build-arg DOCKERHUB_AUTH=false
if: github.event_name != 'push' && github.event.pull_request.head.repo.full_name != github.repository
- name: Execute wait-block test (Earthly Only)
run: |-
./tests/wait-block/test.sh \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute try-catch test (Earthly Only)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: |-
./tests/try-catch/test.sh \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute try-catch test (Fork Only)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
command: ./tests/try-catch/test.sh --build-arg DOCKERHUB_AUTH=false
if: github.event_name != 'push' && github.event.pull_request.head.repo.full_name != github.repository
- name: Execute +test using wait-block override (Earthly Only)
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 2
command: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci -P --global-wait-end \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev \
+test --GLOBAL_WAIT_END=true
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute local buildkit with mTLS test
run: ./tests/remote-buildkit/remote-buildkit-test.sh
- name: Run linux-amd64 specific tests (Earthly Only)
run: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci -P \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev \
./tests+ga-linux-amd64
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute tests requiring .git directory
run: go test ./analytics --tags=hasgitdirectory
- name: Execute earthly ${{inputs.BINARY}} command
run: (cd tests/docker && ${{inputs.SUDO}} ../../${{inputs.BUILT_EARTHLY_PATH}} docker --tag examples-test-docker:latest && diff <(docker run --rm examples-test-docker:latest) <(echo "hello dockerfile") )
- name: Execute private image test (Earthly Only)
run: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev \
./tests+private-image-test
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Execute save images test
run: frontend=${{inputs.BINARY}} ./tests/save-images/test.sh
- name: Experimental tests (Earthly Only)
run: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci -P \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev \
./tests+experimental
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
- name: Experimental tests (Fork Only)
run: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci -P \
--build-arg DOCKERHUB_AUTH=false \
./tests+experimental
if: github.event_name != 'push' && github.event.pull_request.head.repo.full_name != github.repository
- name: Test buildkit info-level logging
run: ${{inputs.SUDO}} ${{inputs.BINARY}} logs earthly-buildkitd 2>&1 | grep 'running server on'
- name: Test for uncommitted generated code
run: |-
${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} --ci -P \
--build-arg DOCKERHUB_AUTH=true \
--build-arg DOCKERHUB_USER_SECRET=+secrets/earthly-technologies/dockerhub-mirror/user \
--build-arg DOCKERHUB_TOKEN_SECRET=+secrets/earthly-technologies/dockerhub-mirror/pass \
--build-arg DOCKERHUB_MIRROR=registry-1.docker.io.mirror.corp.earthly.dev \
./ast/parser+test-not-committed
- name: Buildkit logs (runs on failure)
run: ${{inputs.SUDO}} ${{inputs.BINARY}} logs earthly-buildkitd
if: ${{ failure() }}