-
Notifications
You must be signed in to change notification settings - Fork 12
222 lines (222 loc) · 10.1 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"
jobs:
test:
name: "${{ matrix.feature }} / ${{ matrix.docker_image.label }}"
runs-on: "ubuntu-latest"
env:
am_version: "${{ inputs.am_version }}"
ss_version: "${{ inputs.ss_version }}"
at_version: "${{ inputs.at_version }}"
python_version: "3.9"
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: "ubuntu"
tag: "22.04"
label: "jammy"
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: "Upgrade crun (supports Ubuntu's systemd in the Dockerfile)"
run: |
wget https://github.com/containers/crun/releases/download/1.14.4/crun-1.14.4-linux-amd64
sudo install crun-1.14.4-linux-amd64 /usr/bin/crun
rm crun-1.14.4-linux-amd64
- 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: "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: "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 Archivematica"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_REMOTE_PORT: 2222
run: |
ansible-galaxy install -f -p roles/ -r requirements.yml
ansible-playbook -i localhost, playbook.yml \
-u ubuntu \
-e "archivematica_src_am_version=${{ env.am_version }} archivematica_src_ss_version=${{ env.ss_version }}" \
-vvv
- name: "Save logs"
if: "${{ failure() }}"
working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
run: |
mkdir /tmp/logs
podman-compose exec --user root archivematica cp -r /var/log /tmp/logs
podman-compose exec --user root archivematica cp -r /etc /tmp/logs
podman-compose exec --user root archivematica cp -r /usr/lib/systemd /tmp/logs
podman-compose exec --user root archivematica journalctl --no-pager > /tmp/logs/journalctl.log
podman-compose exec --user root archivematica chown -R ubuntu:ubuntu /tmp/logs
podman cp archivematica-acceptance-test_archivematica_1:/tmp/logs/ /tmp/logs
sudo chown -R $USER /tmp/logs
tar -czf /tmp/logs.tar.gz /tmp/logs
- name: "Upload logs on failure"
if: "${{ failure() }}"
uses: "actions/upload-artifact@v4"
with:
name: "logs-${{ matrix.docker_image.label }}-${{ matrix.feature }}"
path: "/tmp/logs.tar.gz"
- 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: |
# mkdir /tmp/logs
# vagrant ssh -c 'mkdir -p /tmp/logs/journalctl'
# vagrant ssh -c 'sudo journalctl -u archivematica-mcp-client --no-pager > /tmp/logs/journalctl/archivematica-mcp-client'
# - name: "Save logs on failure"
# if: "${{ startsWith(matrix.vagrant_box.id, 'ubuntu/') && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
# working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
# run: |
# vagrant ssh -c 'sudo cp -r /var/log/{archivematica,mysql,elasticsearch,gearman-job-server,clamav,nginx} /tmp/logs'
# - name: "Save logs on failure"
# if: "${{ (startsWith(matrix.vagrant_box.id, 'rockylinux/') || startsWith(matrix.vagrant_box.id, 'almalinux/')) && ((failure() && steps.amauat-run.outcome == 'failure') || (cancelled() && steps.amauat-run.outcome == 'cancelled')) }}"
# working-directory: "${{ github.workspace }}/tests/archivematica-acceptance-tests"
# run: |
# vagrant ssh -c 'sudo journalctl -u clamd@scan --no-pager > /tmp/logs/journalctl/clamd'
# vagrant ssh -c 'sudo 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: |
# vagrant ssh -c 'sudo chown -R vagrant /tmp/logs'
# scp \
# -i ${{ github.workspace }}/tests/archivematica-acceptance-tests/.vagrant/machines/default/virtualbox/private_key \
# -o "StrictHostKeyChecking=no" \
# -r \
# [email protected]:/tmp/logs /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.vagrant_box.label }}-${{ matrix.feature }}"
# path: "/tmp/logs"