Skip to content

Commit

Permalink
Tests (#147)
Browse files Browse the repository at this point in the history
* workflows/cypress: enable tests

* cypress/e2e: remove tests

* Add minimal smoke test

* lang fixup

* reorder to wait on Connection abort
  • Loading branch information
himdel authored Dec 31, 2024
1 parent c0e03bf commit f22a195
Show file tree
Hide file tree
Showing 56 changed files with 284 additions and 4,586 deletions.
140 changes: 140 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Cypress

on:
# allow running manually
workflow_dispatch:
pull_request:
branches: ['main']
# weekly on main
schedule:
- cron: '14 4 * * 6'

concurrency:
group: cypress-${{ github.ref }}
cancel-in-progress: true

jobs:
cypress:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- name: 'Checkout pulp-ui (${{ github.ref }})'
uses: actions/checkout@v4

- name: 'backend setup'
run: |
mkdir -p settings/certs pulp_storage pgsql containers
echo "CONTENT_ORIGIN='http://$(hostname):8080'" >> settings/settings.py
echo "ANSIBLE_API_HOSTNAME='http://$(hostname):8080'" >> settings/settings.py
echo "ANSIBLE_CONTENT_HOSTNAME='http://$(hostname):8080/pulp/content'" >> settings/settings.py
- name: 'backend run'
run: |
podman run --publish 8080:80 --name pulp --replace --detach \
--volume "$(pwd)/settings":/etc/pulp \
--volume "$(pwd)/pulp_storage":/var/lib/pulp \
--volume "$(pwd)/pgsql":/var/lib/pgsql \
--volume "$(pwd)/containers":/var/lib/containers \
docker.io/pulp/pulp
- name: 'Install node 20'
uses: actions/setup-node@v4
with:
node-version: '20'

- name: 'Install python 3.13'
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: 'Cache ~/.npm & ~/.cache/Cypress'
uses: actions/cache@v4
with:
path: |
~/.npm
~/.cache/Cypress
key: npm-${{ hashFiles('package-lock.json') }}

- name: 'npm install'
run: 'npm install'

- name: 'gettext extract & compile'
run: |
# production displays unknown translations literally, make sure it's up to date
npm run gettext:extract
npm run gettext:compile
- name: 'Build UI'
run: |
npm run build
# 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
- name: 'Serve UI'
run: |
mkdir -p www/static/
mv dist www/static/pulp_ui
cd www
echo '{}' > package.json
npm install local-web-server
node_modules/.bin/ws \
--port 8002 \
--directory . \
--spa static/pulp_ui/index.html \
--rewrite '/api/(.*) -> http://localhost:8080/api/$1' \
--rewrite '/assets/(.*) -> http://localhost:8080/assets/$1' \
--rewrite '/auth/(.*) -> http://localhost:8080/auth/$1' \
--rewrite '/extensions/(.*) -> http://localhost:8080/extensions/$1' \
--rewrite '/pulp/(.*) -> http://localhost:8080/pulp/$1' \
--rewrite '/static/rest_framework/(.*) -> http://localhost:8080/static/rest_framework/$1' \
--rewrite '/v2/(.*) -> http://localhost:8080/v2/$1' \
--rewrite '/pulp-ui-config.json -> /static/pulp_ui/pulp-ui-config.json' &
- name: 'Ensure index.html uses the new js'
run: |
echo 'expecting /static/pulp_ui/js/App.'"$BUILD_HASH"'.js'
curl http://localhost:8002/static/pulp_ui/index.html | tee /dev/stderr | grep '/static/pulp_ui/js/App.'"$BUILD_HASH"'.js'
- name: 'Check status endpoint'
run: |
curl -s -f http://localhost:8080/pulp/api/v3/status/ | jq
- name: 'Change admin password'
run: |
podman exec -it pulp pulpcore-manager reset-admin-password --password admin
- name: 'Configure pulp-cli'
run: |
pip install pulp-cli[pygments]
pulp config create --username admin --base-url http://localhost:8080 --password admin
- name: 'Check login works'
run: |
curl -s -f --retry 8 --retry-all-errors --user admin:admin http://localhost:8080/pulp/api/v3/repositories/python/python/ | jq
- name: 'Check pulp-cli works'
run: |
pulp user list
- name: 'Run cypress'
run: |
npm run cypress:chrome
- uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots_and_videos
path: |
cypress/screenshots
cypress/videos
- name: 'Kill container, show logs'
if: always()
run: |
podman logs pulp
podman kill pulp
1 change: 1 addition & 0 deletions config/start.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = webpackBase({
DEV_PROXY: {
'/api/': proxyTarget,
'/assets/': proxyTarget,
'/auth/': proxyTarget,
'/extensions/': proxyTarget,
'/pulp/': proxyTarget,
'/static/rest_framework/': proxyTarget,
Expand Down
18 changes: 5 additions & 13 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
// https://on.cypress.io/configuration
const { defineConfig } = require('cypress');

module.exports = defineConfig({
viewportWidth: 1280,
viewportHeight: 800,
e2e: {
setupNodeEvents(on, _config) {
if (process.env.CONSOLE_LOG_TO_TERMINAL) {
return require('./cypress/plugins/console-logger').install(on);
}
},
baseUrl: 'http://localhost:8002',
// overridden in cypress.yml
specPattern: 'cypress/e2e/**/*.js',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
// overridden in cypress.yml
screenshotsFolder: 'cypress/screenshots',
// only record videos when running github action in debug mode
video: !!process.env.RUNNER_DEBUG,
video: !!process.env.RUNNER_DEBUG, // only record videos when running github action in debug mode
viewportHeight: 1080,
viewportWidth: 1920,
});
4 changes: 2 additions & 2 deletions cypress.env.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"apiPrefix": "/pulp/api/v3/",
"uiPrefix": "/ui/",
"API_BASE_PATH": "/pulp/api/v3/",
"UI_BASE_PATH": "/ui/",
"username": "admin",
"password": "admin"
}
155 changes: 0 additions & 155 deletions cypress/e2e/approval-modal/approval-multiple-repos-list.js

This file was deleted.

Loading

0 comments on commit f22a195

Please sign in to comment.