-
Notifications
You must be signed in to change notification settings - Fork 75
250 lines (208 loc) · 8.96 KB
/
cypress.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Cypress
on:
# allow running manually
workflow_dispatch:
pull_request:
branches: [ 'stable-*' ]
push:
branches: [ 'stable-*' ]
concurrency:
group: cypress-${{ github.ref }}
cancel-in-progress: true
jobs:
cypress:
runs-on: ubuntu-latest
env:
# base of a PR, or pushed-to branch outside PRs, or stable-4.6
BRANCH: ${{ github.base_ref || github.ref || 'refs/heads/stable-4.6' }}
strategy:
fail-fast: false
matrix:
test:
- 'collections'
- 'approval'
- 'execution_environments'
- 'namespaces'
- 'groups_and_users'
- 'repo'
- 'misc'
- 'imports'
steps:
- name: "Install galaxykit dependency"
run: |
# pip install git+https://github.com/ansible/galaxykit.git@branch_name
pip install galaxykit==0.13.0
- name: "Set env.SHORT_BRANCH, env.GALAXY_NG_COMMIT"
run: |
SHORT_BRANCH=`sed 's/^refs\/heads\///' <<< $BRANCH`
GALAXY_NG_COMMIT=`curl -s https://api.github.com/repos/ansible/galaxy_ng/branches/${SHORT_BRANCH} | jq -r .commit.sha`
# blow up without galaxy_ng commit info
[ -n "$GALAXY_NG_COMMIT" ]
echo "SHORT_BRANCH=${SHORT_BRANCH}" >> $GITHUB_ENV
echo "GALAXY_NG_COMMIT=${GALAXY_NG_COMMIT}" >> $GITHUB_ENV
- run: "mkdir pulp_galaxy_ng"
- name: "Cache container image for pulp_galaxy_ng ${{ env.SHORT_BRANCH }} ${{ env.GALAXY_NG_COMMIT }}"
id: cache-container
uses: actions/cache@v4
with:
path: pulp_galaxy_ng/image
key: ${{ runner.os }}-container-${{ env.GALAXY_NG_COMMIT }}-post2547
- name: "Checkout ansible-hub-ui (${{ github.ref }})"
uses: actions/checkout@v4
with:
path: 'ansible-hub-ui'
- name: "Build pulp-galaxy-ng"
if: steps.cache-container.outputs.cache-hit != 'true'
working-directory: 'pulp_galaxy_ng'
run: |
cp -iv ../ansible-hub-ui/.github/workflows/scripts/* .
echo '# Containerfile'
echo '\
FROM ghcr.io/pulp/pulp-ci-centos:3.21
COPY --chmod=644 ansible-sign.key /tmp/
COPY --chmod=755 collection-sign.sh /var/lib/pulp/scripts/
COPY --chmod=755 container-sign.sh /var/lib/pulp/scripts/
COPY --chmod=755 signing-setup.sh /tmp/
RUN pip3 install --upgrade \
requests \
git+https://github.com/ansible/galaxy_ng.git@${{ env.SHORT_BRANCH }}
RUN mkdir -p /etc/nginx/pulp/
RUN ln /usr/local/lib/python*/site-packages/pulp_ansible/app/webserver_snippets/nginx.conf /etc/nginx/pulp/pulp_ansible.conf
RUN ln /usr/local/lib/python*/site-packages/pulp_container/app/webserver_snippets/nginx.conf /etc/nginx/pulp/pulp_container.conf
RUN ln /usr/local/lib/python*/site-packages/galaxy_ng/app/webserver_snippets/nginx.conf /etc/nginx/pulp/galaxy_ng.conf
RUN rm -rf /usr/local/lib/python*/site-packages/galaxy_ng/app/static/
RUN ln -sv /galaxy_ng_static `ls -d /usr/local/lib/python*/site-packages/galaxy_ng/app/`static
' | tee Containerfile
buildah bud --file Containerfile --tag localhost/pulp/pulp-galaxy-ng:latest .
rm -f image # ensure older version is gone, podman save errors otherwise
podman save localhost/pulp/pulp-galaxy-ng:latest -o image
- name: "Load pulp-galaxy-ng from cache"
if: steps.cache-container.outputs.cache-hit == 'true'
working-directory: 'pulp_galaxy_ng'
run: podman load -i image
- name: "Configure and run pulp-galaxy-ng"
working-directory: 'pulp_galaxy_ng'
run: |
mkdir settings static
echo '# settings/settings.py'
echo "\
ANSIBLE_API_HOSTNAME='http://localhost:8002'
ANSIBLE_CONTENT_HOSTNAME='http://localhost:8002/api/galaxy/v3/artifacts/collections'
CONTENT_ORIGIN='http://localhost:8002'
GALAXY_API_PATH_PREFIX='/api/galaxy/'
GALAXY_AUTHENTICATION_CLASSES=['rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication']
GALAXY_DEPLOYMENT_MODE='standalone'
PULP_CONTENT_PATH_PREFIX='/api/galaxy/v3/artifacts/collections/'
RH_ENTITLEMENT_REQUIRED='insights'
TOKEN_AUTH_DISABLED=True
X_PULP_CONTENT_HOST='localhost'
GALAXY_REQUIRE_CONTENT_APPROVAL=False
GALAXY_COLLECTION_SIGNING_SERVICE='ansible-default'
GALAXY_CONTAINER_SIGNING_SERVICE='container-default'
GALAXY_FEATURE_FLAGS__container_signing=True
" | sed 's/^\s\+//' | tee settings/settings.py
podman run \
--detach \
--publish 8002:80 \
--name pulp \
--volume "$(pwd)/settings":/etc/pulp \
--volume "$(pwd)/static":/galaxy_ng_static \
--tmpfs /var/lib/pulp \
--tmpfs /var/lib/pgsql \
--tmpfs /var/lib/containers \
--device /dev/fuse \
localhost/pulp/pulp-galaxy-ng:latest
- name: "Install node 18"
uses: actions/setup-node@v4
with:
node-version: '18'
- name: "Cache ~/.npm & ~/.cache/Cypress"
uses: actions/cache@v4
with:
path: |
~/.npm
~/.cache/Cypress
key: ${{ runner.os }}-node-${{ env.SHORT_BRANCH }}-${{ hashFiles('ansible-hub-ui/**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.SHORT_BRANCH }}-
${{ runner.os }}-node-
- name: "Build standalone UI"
working-directory: 'ansible-hub-ui'
run: |
npm install
# production displays unknown translations literally, make sure it's up to date
npm run gettext:extract
npm run gettext:compile
npm run build-standalone
# save the App.*.js hash for later verification
BUILD_HASH=`ls dist/js/App*js | cut -d. -f2`
echo "BUILD_HASH=${BUILD_HASH}" >> $GITHUB_ENV
rm -rf ../pulp_galaxy_ng/static/galaxy_ng/ || true
mv -v dist/ ../pulp_galaxy_ng/static/galaxy_ng
# apply changes, runs collectstatic and serves static assets
podman exec pulp pulpcore-manager collectstatic --no-input --clear
podman exec pulp bash -c "s6-svc -r /var/run/s6-rc/servicedirs/pulpcore-api"
- name: "Reset admin password"
run: |
# podman exec pulp pip install django_extensions
podman exec pulp pulpcore-manager reset-admin-password --password admin
- name: "Enable signing service"
run: |
podman exec pulp /tmp/signing-setup.sh
- name: "Install Cypress & test dependencies"
working-directory: 'ansible-hub-ui/test'
run: |
npm install
- name: "Configure Cypress"
working-directory: 'ansible-hub-ui/test'
run: |
echo -e '{
"prefix": "/api/galaxy/",
"pulpPrefix": "/api/galaxy/pulp/api/v3/",
"username": "admin",
"password": "admin",
"settings": "../../pulp_galaxy_ng/settings/settings.py",
"restart": "podman exec pulp bash -c \"s6-svc -r /var/run/s6-rc/servicedirs/pulpcore-api\"; sleep 10",
"containers": "localhost:8002",
"galaxykit": "galaxykit --ignore-certs"
}' > cypress.env.json
- name: "Ensure index.html uses the new js"
run: |
echo 'expecting /static/galaxy_ng/js/App.'"$BUILD_HASH"'.js'
curl http://localhost:8002/static/galaxy_ng/index.html | tee /dev/stderr | grep '/static/galaxy_ng/js/App.'"$BUILD_HASH"'.js'
- name: "Ensure galaxykit can connect to the server"
run: |
galaxykit -s 'http://localhost:8002/api/galaxy/' -u admin -p admin collection list
- name: "Check initial feature flags"
run: |
curl -s http://localhost:8002/api/galaxy/_ui/v1/feature-flags/ | jq
- name: "Check component versions"
run: |
HUB_TOKEN=`curl -s -u admin:admin -d '' http://localhost:8002/api/galaxy/v3/auth/token/ | jq -r .token`
curl -s -H "Authorization: Token $HUB_TOKEN" http://localhost:8002/api/galaxy/ | jq
- name: "Check if e2e contains only dirs in matrix test array"
working-directory: 'ansible-hub-ui'
run: |
diff -Naur <(ls test/cypress/e2e) <(yq '.jobs.cypress.strategy.matrix.test[]' .github/workflows/cypress.yml | sort)
- name: "Run cypress"
working-directory: 'ansible-hub-ui/test'
env:
CONSOLE_LOG_TO_TERMINAL: true
run: |
sed -i '/specPattern:/s/\*\*/${{matrix.test}}/' cypress.config.js
echo "result of the config file:"
cat cypress.config.js
npm run cypress:chrome
- uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots_and_videos-${{matrix.test}}
path: |
ansible-hub-ui/test/cypress/screenshots
ansible-hub-ui/test/cypress/videos
- name: "Kill container, show debug info"
if: always()
run: |
podman exec pulp bash -c "pip3 list && pip3 install pipdeptree && pipdeptree"
podman logs pulp
podman kill pulp