-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
199 lines (199 loc) · 6.38 KB
/
action.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
name: "Tests Runner"
description: GitHub Action for run tests, Sysdig way'
inputs:
github_token:
description: GITHUB_TOKEN secret
required: true
artifactory_url:
description: "Artifactory URL"
required: false
default: "docker.internal.sysdig.com"
artifactory_username:
description: Artifactory Username
default: ""
required: false
artifactory_password:
description: Artifactory Password
default: ""
required: false
gar_username:
description: GAR Username
default: "_json_key"
required: false
gar_password:
description: GAR Password
default: ""
required: false
gar_registry:
description: GAR Registry
default: "us-docker.pkg.dev"
required: false
kind_needed:
description: "Boolean if a Kubernetes In Docker cluster is needed for tests (default: false)"
required: false
default: "true"
kind_version:
description: KinD version
required: false
default: "v0.19.0"
kind_config_path:
description: KinD config path
required: false
default: tests/kind-config.yaml
kind_cluster_name:
description: KinD cluster name
required: false
default: kind
kind_wait:
description: KinD wait time for provisioning
required: false
default: 60s
kind_kubectl_version:
description: kubectl version to use with KinD
required: false
default: v1.24.15
kind_log_level:
description: KinD verbosity to set
required: false
default: "0"
bats_version:
description: "BATS version"
required: false
default: "1.10.0"
envsubst_needed:
description: Indicate if envsubst is needed (only on MacOs)
required: false
default: "false"
taskfile_name:
description: Name of the taskfile task to be executed
required: false
default: "test"
quay_username:
description: quay Username
default: ""
required: false
quay_password:
description: quay Password
default: ""
required: false
artifact_name:
description: Name of the artifact to be downloaded and imported
required: false
default: "image"
import_image_artifact:
description: "Boolean if the image artifact should be imported (default: false)"
required: false
default: "false"
local_image_name:
description: Name of the image to be imported
required: false
default: "testimage:local"
image_original_tag:
description: Original tag of the image to be imported
required: false
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.x"
- name: Install Bats and bats libs
uses: bats-core/[email protected]
with:
bats-version: ${{ inputs.bats_version }}
support-path: "${{ github.workspace }}/.bats/bats-support"
assert-path: "${{ github.workspace }}/.bats/bats-assert"
detik-path: "${{ github.workspace }}/.bats/bats-detik"
file-path: "${{ github.workspace }}/.bats/bats-file"
- name: Setup envsubst
if: ${{ inputs.envsubst_needed == 'true' }}
shell: bash
run: sudo apt update; sudo apt install -y gettext-base
- name: Setup Taskfile
uses: arduino/setup-task@v2
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Setup KinD
if: ${{ inputs.kind_needed == 'true' }}
uses: helm/[email protected]
with:
version: ${{ inputs.kind_version }}
config: ${{ inputs.kind_config_path }}
cluster_name: ${{ inputs.kind_cluster_name }}
wait: ${{ inputs.kind_wait }}
kubectl_version: ${{ inputs.kind_kubectl_version }}
verbosity: ${{ inputs.kind_log_level }}
- name: Login to Artifactory
uses: docker/login-action@v3
if: ${{inputs.artifactory_username != '' && inputs.artifactory_password != '' }}
with:
registry: ${{ inputs.artifactory_url }}
username: ${{ inputs.artifactory_username }}
password: ${{ inputs.artifactory_password }}
- name: Login to Quay
uses: docker/login-action@v3
if: ${{inputs.quay_username != '' && inputs.quay_password != '' }}
with:
registry: quay.io
username: ${{ inputs.quay_username }}
password: ${{ inputs.quay_password }}
- name: Login to GAR
uses: docker/login-action@v3
if: ${{inputs.gar_username != '' && inputs.gar_password != '' }}
with:
registry: ${{ inputs.gar_registry }}
username: ${{ inputs.gar_username }}
password: ${{ inputs.gar_password }}
- name: Download image artifact
uses: actions/[email protected]
if: ${{ inputs.import_image_artifact == 'true' }}
with:
name: ${{ inputs.artifact_name }}
path: /tmp
- name: Load image to docker
shell: bash
if: ${{ inputs.import_image_artifact == 'true' }}
run: |
docker load --input /tmp/${{ inputs.artifact_name }}.tar
- name: Retagging image
shell: bash
if: ${{ inputs.import_image_artifact == 'true' }}
run: |
original_tag=`echo "${{ inputs.image_original_tag }}" | head -n 1`
local_tag="${{ inputs.local_image_name }}"
echo "retagging docker image $original_tag $local_tag"
docker tag $original_tag $local_tag
- name: Load image to KinD
shell: bash
if: ${{ inputs.import_image_artifact == 'true' }}
run: |
local_tag="${{ inputs.local_image_name }}"
kind load docker-image $local_tag --name ${{ inputs.kind_cluster_name }}
- name: Lint and tests
shell: bash
env:
BATS_LIB_PATH: "${{ github.workspace }}/.bats"
GITHUB_REF_NAME: ${{ github.ref }}
GITHUB_RUN_ID: ${{ github.run_id }}
ARTIFACTORY_USERNAME: ${{ inputs.artifactory_username }}
ARTIFACTORY_PASSWORD: ${{ inputs.artifactory_password }}
GAR_USERNAME: ${{ inputs.gar_username }}
GAR_PASSWORD: ${{ inputs.gar_password }}
GAR_REGISTRY: ${{ inputs.gar_registry }}
TASKFILE_NAME: ${{ inputs.taskfile_name }}
QUAY_USERNAME: ${{ inputs.quay_username }}
QUAY_PASSWORD: ${{ inputs.quay_password }}
run: task ${TASKFILE_NAME}
- name: Debug failure
if: failure()
env:
BATS_LIB_PATH: "${{ github.workspace }}/.bats"
shell: bash
run: task test:logs
- name: Clean up
if: always()
env:
BATS_LIB_PATH: "${{ github.workspace }}/.bats"
shell: bash
run: task test:clean