forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (95 loc) · 4.54 KB
/
reusable-earthly-image-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
name: Earthly Image Tests
on:
workflow_call:
inputs:
BUILT_EARTHLY_PATH:
required: true
type: string
BINARY:
required: true
type: string
SUDO:
type: string
required: false
RUNS_ON:
required: true
type: string
SKIP_JOB:
required: false
type: boolean
default: false
jobs:
earthly-image-tests:
if: ${{!inputs.SKIP_JOB}}
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@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/stage2-setup
with:
DOCKERHUB_MIRROR_USERNAME: "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}"
DOCKERHUB_MIRROR_PASSWORD: "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"
DOCKERHUB_PASSWORD: "${{ secrets.DOCKERHUB_TOKEN }}"
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
BUILT_EARTHLY_PATH: "${{ inputs.BUILT_EARTHLY_PATH }}"
BINARY: "${{ inputs.BINARY }}"
SUDO: "${{ inputs.SUDO }}"
USE_SATELLITE: "${{ inputs.USE_SATELLITE }}"
SATELLITE_NAME: "${{ inputs.SATELLITE_NAME }}"
- 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"
run: FRONTEND=${{inputs.BINARY}} EARTHLY_IMAGE=earthly/earthly:image-test DOCKERHUB_MIRROR_USERNAME="${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" DOCKERHUB_MIRROR_PASSWORD="${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}" DOCKERHUB_USERNAME="${{ secrets.DOCKERHUB_USERNAME }}" DOCKERHUB_PASSWORD="${{ secrets.DOCKERHUB_TOKEN }}" ./scripts/tests/earthly-image.sh
- name: Buildkit logs (runs on failure)
run: ${{inputs.SUDO}} ${{inputs.BINARY}} logs earthly-buildkitd
if: ${{ failure() && ! inputs.USE_SATELLITE }}
earthly-image-sat-tests:
if: ${{!inputs.SKIP_JOB}}
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@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/stage2-setup
with:
DOCKERHUB_MIRROR_USERNAME: "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}"
DOCKERHUB_MIRROR_PASSWORD: "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"
DOCKERHUB_PASSWORD: "${{ secrets.DOCKERHUB_TOKEN }}"
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
BUILT_EARTHLY_PATH: "${{ inputs.BUILT_EARTHLY_PATH }}"
BINARY: "${{ inputs.BINARY }}"
SUDO: "${{ inputs.SUDO }}"
USE_SATELLITE: "${{ inputs.USE_SATELLITE }}"
SATELLITE_NAME: "${{ inputs.SATELLITE_NAME }}"
- 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 sat tests"
run: FRONTEND=${{inputs.BINARY}} EARTHLY_IMAGE=earthly/earthly:image-test DOCKERHUB_MIRROR_USERNAME="${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" DOCKERHUB_MIRROR_PASSWORD="${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}" DOCKERHUB_USERNAME="${{ secrets.DOCKERHUB_USERNAME }}" DOCKERHUB_PASSWORD="${{ secrets.DOCKERHUB_TOKEN }}" ./scripts/tests/earthly-image-sat.sh
- name: Buildkit logs (runs on failure)
run: ${{inputs.SUDO}} ${{inputs.BINARY}} logs earthly-buildkitd || true
if: ${{ failure() && ! inputs.USE_SATELLITE }}