-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
183 lines (183 loc) · 5.92 KB
/
action.yml
File metadata and controls
183 lines (183 loc) · 5.92 KB
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
name: "Tests Runner"
description: GitHub Action for run tests, Sysdig way'
inputs:
artifact_name:
default: "image"
description: Name of the artifact to be downloaded and imported
required: false
bats_version:
default: "1.12.0"
description: "BATS version"
required: false
envsubst_needed:
default: "false"
description: Indicate if envsubst is needed (only on MacOs)
required: false
gar_password:
default: ""
description: GAR Password
required: false
gar_registry:
default: "us-docker.pkg.dev"
description: GAR Registry
required: false
gar_username:
default: "_json_key"
description: GAR Username
required: false
github_token:
description: GITHUB_TOKEN secret
required: true
image_original_tag:
description: Original tag of the image to be imported
required: false
import_image_artifact:
default: "false"
description: "Boolean if the image artifact should be imported (default: false)"
required: false
local_image_name:
default: "testimage:local"
description: Name of the image to be imported
required: false
kind_cluster_name:
default: kind
description: KinD cluster name
required: false
kind_config_path:
default: tests/kind-config.yaml
description: KinD config path
required: false
kind_kubectl_version:
default: v1.33.4
description: kubectl version to use with KinD - this version cannot be updated until the utility cluster has been updated - DEVOPS-14991
required: false
kind_log_level:
description: KinD verbosity to set
required: false
default: "0"
kind_needed:
default: "true"
description: "Boolean if a Kubernetes In Docker cluster is needed for tests (default: true)"
required: false
kind_version:
default: "v0.30.0"
description: KinD version - this version cannot be updated until the utility cluster has been updated - DEVOPS-14991
required: false
kind_wait:
default: 60s
description: KinD wait time for provisioning
required: false
quay_password:
default: ""
description: quay Password
required: false
quay_username:
default: ""
description: quay Username
required: false
taskfile_name:
default: "test"
description: Name of the taskfile task to be executed
required: false
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v6.0.0
with:
python-version: '3.13'
- name: Install Bats and bats libs
uses: bats-core/bats-action@3.0.1
with:
assert-path: "${{ github.workspace }}/.bats/bats-assert"
bats-version: ${{ inputs.bats_version }}
detik-path: "${{ github.workspace }}/.bats/bats-detik"
file-path: "${{ github.workspace }}/.bats/bats-file"
support-path: "${{ github.workspace }}/.bats/bats-support"
- name: Setup envsubst
if: ${{ inputs.envsubst_needed == 'true' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y gettext-base
- name: Setup Taskfile
uses: arduino/setup-task@v2
- name: Setup Helm
uses: azure/setup-helm@v4.3.1
with:
version: 'v3.18.6'
- name: Setup KinD
if: ${{ inputs.kind_needed == 'true' }}
uses: helm/kind-action@v1.13.0
with:
cluster_name: ${{ inputs.kind_cluster_name }}
config: ${{ inputs.kind_config_path }}
kubectl_version: ${{ inputs.kind_kubectl_version }}
verbosity: ${{ inputs.kind_log_level }}
version: ${{ inputs.kind_version }}
wait: ${{ inputs.kind_wait }}
- name: Login to Quay
uses: docker/login-action@v3.6.0
if: ${{inputs.quay_username != '' && inputs.quay_password != '' }}
with:
password: ${{ inputs.quay_password }}
registry: quay.io
username: ${{ inputs.quay_username }}
- name: Login to GAR
uses: docker/login-action@v3.6.0
if: ${{inputs.gar_username != '' && inputs.gar_password != '' }}
with:
password: ${{ inputs.gar_password }}
registry: ${{ inputs.gar_registry }}
username: ${{ inputs.gar_username }}
- name: Download image artifact
uses: actions/download-artifact@v6.0.0
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"
GAR_PASSWORD: ${{ inputs.gar_password }}
GAR_REGISTRY: ${{ inputs.gar_registry }}
GAR_USERNAME: ${{ inputs.gar_username }}
GITHUB_REF_NAME: ${{ github.ref }}
GITHUB_RUN_ID: ${{ github.run_id }}
QUAY_PASSWORD: ${{ inputs.quay_password }}
QUAY_USERNAME: ${{ inputs.quay_username }}
TASKFILE_NAME: ${{ inputs.taskfile_name }}
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