forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (103 loc) · 4.14 KB
/
reusable-test-local.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
name: Runs test local
on:
workflow_call:
inputs:
BUILT_EARTHLY_PATH:
required: true
type: string
BUILD_EARTHLY_TARGET:
required: true
type: string
BUILD_EARTHLY_ARGS:
required: false
type: string
default: "--use-inline-cache"
RUN_EARTHLY_TEST_ARGS:
required: false
type: string
default: "--use-inline-cache --save-inline-cache --no-output"
BINARY:
required: true
type: string
BINARY_COMPOSE:
required: true
type: string
SUDO:
type: string
required: false
RUNS_ON:
required: true
type: string
USE_SATELLITE:
required: false
type: boolean
default: false
SATELLITE_NAME:
required: false
type: string
EARTHLY_ORG:
required: false
type: string
jobs:
test-local:
name: test-local ${{inputs.BINARY}}
runs-on: ${{inputs.RUNS_ON}}
env:
FORCE_COLOR: 1
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
EARTHLY_INSTALL_ID: "earthly-githubactions"
EARTHLY_ORG: "${{inputs.EARTHLY_ORG}}"
DOCKERHUB_MIRROR_USERNAME: "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}"
DOCKERHUB_MIRROR_PASSWORD: "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
# Used in our github action as the token - TODO: look to change it into an input
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: earthly/actions-setup@main
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- 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: Install Podman Compose
run: sudo pip3 install podman-compose
if: inputs.binary == 'podman'
- name: Podman debug info
run: podman version && podman info && podman info --debug
if: inputs.binary == 'podman'
- name: Configure Satellites (Earthly Only)
run: earthly sat ls && earthly satellite select ${{inputs.SATELLITE_NAME}}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && inputs.USE_SATELLITE
- 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) ${{inputs.BUILD_EARTHLY_ARGS}} ${{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: Execute test-local
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 2
command: "${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} ${{inputs.RUN_EARTHLY_TEST_ARGS}} ./tests/local+test-local --FRONTEND=${{inputs.BINARY}}"
- name: Execute test-local --push
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 2
command: "${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} ${{inputs.RUN_EARTHLY_TEST_ARGS}} --push ./tests/local+test-local --FRONTEND=${{inputs.BINARY}}"
- name: Run general local tests (TODO this is re-testing the +test-local target)
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 2
command: "${{inputs.SUDO}} ${{inputs.BUILT_EARTHLY_PATH}} ${{inputs.RUN_EARTHLY_TEST_ARGS}} ./tests/local+all --FRONTEND=${{inputs.BINARY}} --FRONTEND_COMPOSE=${{inputs.BINARY_COMPOSE}}"
- name: Buildkit logs (runs on failure)
run: ${{inputs.SUDO}} ${{inputs.BINARY}} logs earthly-buildkitd 2>&1
if: ${{ failure() }}