-
Notifications
You must be signed in to change notification settings - Fork 12
222 lines (222 loc) · 10.3 KB
/
archivematica-acceptance-tests.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: "Archivematica Acceptance Tests"
on:
workflow_dispatch:
inputs:
am_version:
description: "Archivematica ref (branch, tag or SHA to checkout)"
default: "qa/1.x"
required: true
type: "string"
ss_version:
description: "Archivematica Storage Service ref (branch, tag or SHA to checkout)"
default: "qa/0.x"
required: true
type: "string"
at_version:
description: "Archivematica Acceptance Test ref (branch, tag or SHA to checkout)"
default: "qa/1.x"
required: true
type: "string"
schedule:
- cron: "0 3 * * *"
jobs:
test:
name: "${{ matrix.feature }} / ${{ matrix.docker_image.label }}"
runs-on: "ubuntu-latest"
env:
am_version: "${{ inputs.am_version || 'qa/1.x' }}"
ss_version: "${{ inputs.ss_version || 'qa/0.x' }}"
at_version: "${{ inputs.at_version || 'qa/1.x' }}"
python_version: "3.10"
strategy:
fail-fast: false
matrix:
docker_image:
- name: "rockylinux"
tag: "9"
label: "rocky9"
- name: "rockylinux"
tag: "8"
label: "rocky8"
- name: "almalinux"
tag: "9"
label: "alma9"
- name: "oraclelinux"
tag: "9"
label: "oracle9"
- name: "ubuntu"
tag: "22.04"
label: "jammy"
- name: "ubuntu"
tag: "20.04"
label: "focal"
feature:
- "aip-encryption-mirror"
- "aip-encryption"
- "checksum"
- "create-aip"
- "description-rights"
- "extract-package"
- "ingest-mkv-conformance"
- "ingest-policy-check"
- "metadata-xml"
- "reingest-aip"
- "transfer-microservices"
- "transfer-mkv-conformance"
- "transfer-policy-check"
- "uuids-for-directories"
- "virus"
browser:
- "Chrome"
steps:
- name: "Check out code"
uses: "actions/checkout@v4"
- name: "Check out AMAUATs code"
uses: "actions/checkout@v4"
with:
repository: "artefactual-labs/archivematica-acceptance-tests"
ref: "${{ env.at_version }}"
path: "${{ github.workspace }}/AMAUATs"
- name: "Upgrade crun (supports Ubuntu's systemd in the Dockerfile)"
run: |
wget https://github.com/containers/crun/releases/download/1.15/crun-1.15-linux-amd64
sudo install crun-1.15-linux-amd64 /usr/bin/crun
rm crun-1.15-linux-amd64
- name: "Install Python"
uses: "actions/setup-python@v5"
with:
python-version: "${{ env.python_version }}"
cache: "pip"
cache-dependency-path: |
tests/archivematica-acceptance-tests/requirements.txt
- name: "Cache the virtual environment"
id: "venv-cache"
uses: "actions/cache@v4"
with:
path: |
tests/archivematica-acceptance-tests/.venv/
key: "os-${{ runner.os }}-python_version-${{ env.python_version }}-hash-${{ hashFiles('tests/archivematica-acceptance-tests/requirements.txt') }}"
- name: "Set up the virtual environment"
if: "steps.venv-cache.outputs.cache-hit == false"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
- name: "Add virtual environment to PATH"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run:
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: "Generate an SSH key and copy it next to the Dockerfile"
run: |
mkdir $HOME/.ssh
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -N ""
cp $HOME/.ssh/id_rsa.pub ${{ github.workspace }}/tests/archivematica-acceptance-tests/ssh_pub_key
- name: "Add port to SSH client configuration"
run: |
echo -e "Host localhost\n Port 2222" > $HOME/.ssh/config
- name: "Start the Compose environment"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
DOCKER_IMAGE_NAME: "${{ matrix.docker_image.name }}"
DOCKER_IMAGE_TAG: "${{ matrix.docker_image.tag }}"
run: |
podman-compose up --detach
- name: "Install Ansible requirements"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
ansible-galaxy install -f -p roles/ -r requirements.yml
- name: "Adjust parsing of root's initial MySQL password in RedHat distros"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
sed -i "s_cat /var/log/mysqld.log | sed -n '_journalctl --no-pager | sed -n '0,/.*temporary password is generated for root@localhost: /_g" roles/artefactual.percona/tasks/secure.yml
- name: "Install Archivematica"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_REMOTE_PORT: 2222
run: |
ansible-playbook -i localhost, playbook.yml \
-u ubuntu \
-e "archivematica_src_am_version=${{ env.am_version }} archivematica_src_ss_version=${{ env.ss_version }}" \
-v
- name: "Disable machine learning in Elasticsearch"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'echo "xpack.ml.enabled: false" | tee -a /etc/elasticsearch/elasticsearch.yml'
podman-compose exec --user root archivematica service elasticsearch restart
podman-compose exec --user root archivematica service archivematica-dashboard restart
- name: "Prepare the container for running the AMAUATs"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica usermod -a -G archivematica ubuntu
podman-compose exec --user root archivematica ln -s /home/ubuntu /home/archivematica
- name: "Call an Archivematica API endpoint"
run: |
curl \
--header "Authorization: ApiKey admin:this_is_the_am_api_key" \
http://localhost:8000/api/processing-configuration/
- name: "Call a Storage Service API endpoint"
run: |
curl \
--header "Authorization: ApiKey admin:this_is_the_ss_api_key" \
http://localhost:8001/api/v2/pipeline/
- name: "Set up AMAUATs"
working-directory: "${{ github.workspace }}/AMAUATs"
run: |
python3 -m venv .venv
.venv/bin/python3 -m pip install -r requirements.txt
- name: "Run AMAUATs"
id: "amauat-run"
working-directory: "${{ github.workspace }}/AMAUATs"
env:
HEADLESS: 1
run: |
.venv/bin/behave -i ${{ matrix.feature }}.feature \
-v \
--no-capture \
--no-capture-stderr \
--no-logcapture \
--no-skipped \
-D am_version=1.9 \
-D driver_name=${{ matrix.browser }} \
-D am_username=admin \
-D am_password=archivematica \
-D am_url=http://localhost:8000/ \
-D am_api_key="this_is_the_am_api_key" \
-D ss_username=admin \
-D ss_password=archivematica \
-D ss_api_key="this_is_the_ss_api_key" \
-D ss_url=http://localhost:8001/ \
-D home=ubuntu \
-D server_user=ubuntu \
-D transfer_source_path=/home/ubuntu/archivematica-sampledata/TestTransfers/acceptance-tests \
-D ssh_identity_file=$HOME/.ssh/id_rsa
- name: "Save common logs on failure"
if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica mkdir -p /tmp/logs/journalctl
podman-compose exec --user root archivematica bash -c 'journalctl -u archivematica-mcp-client --no-pager > /tmp/logs/journalctl/archivematica-mcp-client'
- name: "Save logs on failure"
if: "${{ matrix.docker_image.name == 'ubuntu' && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'cp -r /var/log/{archivematica,mysql,elasticsearch,gearman-job-server,clamav,nginx} /tmp/logs'
- name: "Save logs on failure"
if: "${{ matrix.docker_image.name != 'ubuntu' && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman-compose exec --user root archivematica bash -c 'journalctl -u mysqld --no-pager > /tmp/logs/journalctl/mysql'
podman-compose exec --user root archivematica bash -c 'journalctl -u clamd@scan --no-pager > /tmp/logs/journalctl/clamd'
podman-compose exec --user root archivematica bash -c 'cp -r /var/log/{archivematica,mysqld.log,elasticsearch,nginx} /tmp/logs'
- name: "Copy logs from VM"
if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
podman cp archivematica-acceptance-test_archivematica_1:/tmp/logs/ .
- name: "Upload logs on failure"
if: "${{ (failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled') }}"
uses: "actions/upload-artifact@v4"
with:
name: "logs-${{ matrix.docker_image.label }}-${{ matrix.feature }}"
path: "${{ github.workspace }}/tests/archivematica-acceptance-tests/logs"