forked from centreon/centreon-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (123 loc) · 4.82 KB
/
Copy pathplugins-robot-tests.yml
File metadata and controls
139 lines (123 loc) · 4.82 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
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
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Login to Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.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@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}
- name: Load image
run: |
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@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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
matrix:
index: ${{ fromJson(inputs.indexes) }}
name: "Tests ${{ matrix.index }} on ${{ inputs.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Get the cached docker image for tests
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.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"
- name: Upload logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-plugins-log-${{ inputs.distrib }}-${{ inputs.arch }}-${{ matrix.index }}
path: |
logs/runner-${{ matrix.index }}
reports/runner-${{ matrix.index }}
retention-days: 1