-
Notifications
You must be signed in to change notification settings - Fork 304
145 lines (129 loc) · 5.04 KB
/
Copy pathplugins-robot-tests.yml
File metadata and controls
145 lines (129 loc) · 5.04 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
on:
workflow_call:
inputs:
image:
description: "The docker image to use for tests"
required: true
type: string
indexes:
description: "The list of runner indexes to use for tests"
required: true
type: string
distrib:
description: "The distribution name"
required: true
type: string
arch:
description: "The distribution architecture"
type: string
default: "amd64"
get-packages:
description: "Whether to get the packages from cache or not"
type: string
default: true
package-extension:
description: "Either 'rpm' or 'deb'. Needed to determine the package manager command (dnf or apt-get)."
required: true
type: string
packages-cache-key:
description: "The packaged plugin's cache key"
required: true
type: string
plugins-json-cache-key:
description: "The cache key for plugin's json"
required: true
type: string
skip-robot-tests:
description: "Whether to run robot tests or not"
type: boolean
default: false
secrets:
registry_username:
required: true
registry_password:
required: true
jobs:
test-image-to-cache:
runs-on: ${{ contains(inputs.image, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Login to Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}
- name: Login to Proxy Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}
- name: Load image
run: |
docker image prune -af
docker pull ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}
shell: bash
- name: Save image on disk
run: |
docker save -o ./${{inputs.image}} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}
shell: bash
- name: Save image into cache
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./${{ inputs.image }}
key: ${{ inputs.image }}-${{ github.sha }}-${{ github.run_id }}
robot-test:
needs: [test-image-to-cache]
runs-on: ${{ contains(inputs.image, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
max-parallel: 15
matrix:
index: ${{ fromJson(inputs.indexes) }}
name: "Tests ${{ matrix.index }} on ${{ inputs.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get the cached docker image for tests
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./${{ inputs.image }}
key: ${{ inputs.image }}-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Get the cached plugins
if: ${{ inputs.get-packages == 'True' }}
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./*.${{ inputs.package-extension }}
key: ${{ inputs.packages-cache-key }}
fail-on-cache-miss: true
- name: Get the cached plugins.json
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ./plugins.json
key: ${{ inputs.plugins-json-cache-key }}
fail-on-cache-miss: true
- name: Load image
run: docker load --input ./${{ inputs.image }}
- name: Install, test and remove plugin
shell: bash
run: |
mkdir -p reports
mkdir -p logs
docker run --rm \
-v $(pwd):/test_plugins \
--workdir /test_plugins \
${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }} \
bash -c "if [ -f /.venv/bin/activate ]; then source /.venv/bin/activate; fi; \
python3 .github/scripts/test-plugins.py --extension=${{ inputs.package-extension }} --runner-id=${{ matrix.index }} --logs-dir=./logs --reports-dir=./reports --skip-robot-tests=${{ inputs.skip-robot-tests }}"
- name: Upload logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: test-plugins-log-${{ inputs.distrib }}-${{ inputs.arch }}-${{ matrix.index }}
path: |
logs/runner-${{ matrix.index }}
reports/runner-${{ matrix.index }}
retention-days: 1