[PR #3880/18dfe82d backport][stable-4.7] Expose download counts #11057
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cypress | |
on: | |
# allow running manually | |
workflow_dispatch: | |
pull_request: | |
branches: [ 'master', 'stable-*', 'feature/*' ] | |
push: | |
branches: [ 'master', 'stable-*', 'feature/*' ] | |
# daily on master | |
schedule: | |
- cron: '30 5 * * *' | |
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 master | |
BRANCH: ${{ github.base_ref || github.ref || 'refs/heads/master' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
test: | |
- 'screenshots' | |
- 'approval' | |
- 'approval_modal' | |
- 'collections' | |
- 'ee_controller' | |
- 'execution_environments' | |
- 'groups_and_users' | |
- 'imports' | |
- 'misc' | |
- 'namespaces' | |
- 'repo' | |
steps: | |
- name: "Install galaxykit dependency" | |
run: | | |
# pip install git+https://github.com/ansible/galaxykit.git@branch_name | |
pip install galaxykit | |
- name: "Set env.SHORT_BRANCH" | |
run: | | |
SHORT_BRANCH=`sed 's/^refs\/heads\///' <<< $BRANCH` | |
echo "SHORT_BRANCH=${SHORT_BRANCH}" >> $GITHUB_ENV | |
echo "COMPOSE_INTERACTIVE_NO_CLI=1" >> $GITHUB_ENV | |
- name: "Set variables for screenshots" | |
if: matrix.test == 'screenshots' | |
run: | | |
UI_COMMIT_MASTER=`curl -s https://api.github.com/repos/ansible/ansible-hub-ui/branches/${SHORT_BRANCH} | jq -r .commit.sha` | |
echo "UI_COMMIT_MASTER=${UI_COMMIT_MASTER}" >> $GITHUB_ENV | |
COMPARE_SCREENSHOTS=${{ github.event_name == 'pull_request' }} | |
echo 'compare screenshots:' | |
echo $COMPARE_SCREENSHOTS | |
echo "COMPARE_SCREENSHOTS=${COMPARE_SCREENSHOTS}" >> $GITHUB_ENV | |
- name: "Checkout ansible-hub-ui (${{ github.ref }})" | |
uses: actions/checkout@v3 | |
with: | |
path: 'ansible-hub-ui' | |
- name: "Checkout galaxy_ng (${{ env.SHORT_BRANCH }})" | |
uses: actions/checkout@v3 | |
with: | |
repository: 'ansible/galaxy_ng' | |
ref: '${{ env.SHORT_BRANCH }}' | |
path: 'galaxy_ng' | |
- name: "Checkout oci_env (main)" | |
uses: actions/checkout@v3 | |
with: | |
repository: 'pulp/oci_env' | |
path: 'oci_env' | |
- name: "Configure oci_env" | |
working-directory: 'oci_env' | |
run: | | |
pip install --editable ./client/ | |
# merge common, profile-specific and test matrix specific config | |
cat ../ansible-hub-ui/.github/workflows/cypress/compose.env.common \ | |
../ansible-hub-ui/.github/workflows/cypress/compose.env.standalone \ | |
../ansible-hub-ui/test/cypress/e2e/"${{ matrix.test }}"/compose.env \ | |
| sed 's/^\s\+//' | tee compose.env || [ -s compose.env ] | |
- name: "oci-env compose build" | |
working-directory: 'oci_env' | |
run: 'oci-env compose build' | |
- name: "oci-env compose up" | |
working-directory: 'oci_env' | |
run: 'oci-env compose up &' | |
- name: "Install node 16" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: "Cache ~/.npm & ~/.cache/Cypress" | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
~/.cache/Cypress | |
key: npm-${{ env.SHORT_BRANCH }}-${{ hashFiles('ansible-hub-ui/**/package-lock.json') }} | |
restore-keys: | | |
npm-${{ env.SHORT_BRANCH }}- | |
npm- | |
- 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 | |
- name: "Serve standalone UI" | |
run: | | |
mkdir -p www/static/ | |
mv ansible-hub-ui/dist www/static/galaxy_ng | |
cd www | |
echo '{}' > package.json | |
npm install local-web-server | |
node_modules/.bin/ws --port 8002 --directory . --spa static/galaxy_ng/index.html \ | |
--rewrite '/api/(.*) -> http://localhost:5001/api/$1' \ | |
--rewrite '/pulp/api/(.*) -> http://localhost:5001/pulp/api/$1' \ | |
--rewrite '/v2/(.*) -> http://localhost:5001/v2/$1' \ | |
--rewrite '/extensions/v2/(.*) -> http://localhost:5001/extensions/v2/$1' & | |
- name: "Install Cypress & test dependencies" | |
working-directory: 'ansible-hub-ui/test' | |
run: | | |
npm install | |
- name: "Install Imagemagick" | |
if: matrix.test == 'screenshots' | |
run: | | |
sudo apt install imagemagick | |
- name: "Configure Cypress" | |
working-directory: 'ansible-hub-ui/test' | |
run: | | |
cp -aiv ../.github/workflows/cypress/cypress.env.json.standalone 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 API (standalone)" | |
run: | | |
galaxykit -s http://localhost:8002/api/galaxy/ -u admin -p admin collection list | |
- name: "Check initial feature flags (standalone)" | |
run: | | |
curl -s http://localhost:5001/api/galaxy/_ui/v1/feature-flags/ | jq | |
- name: "Check component versions & settings (standalone)" | |
run: | | |
HUB_TOKEN=`curl -s -u admin:admin -d '' http://localhost:5001/api/galaxy/v3/auth/token/ | jq -r .token` | |
curl -s -H "Authorization: Token $HUB_TOKEN" http://localhost:5001/api/galaxy/ | jq | |
curl -s -H "Authorization: Token $HUB_TOKEN" http://localhost:5001/api/galaxy/_ui/v1/settings/ | 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: "Cache master screenshots" | |
if: matrix.test == 'screenshots' | |
uses: actions/cache@v3 | |
with: | |
path: ansible-hub-ui/test/screenshots.js/ | |
key: screenshots-${{env.SHORT_BRANCH}}-${{ env.UI_COMMIT_MASTER }} | |
restore-keys: | | |
screenshots-${{env.SHORT_BRANCH}}- | |
- name: "List cached screenshots" | |
if: ${{ matrix.test == 'screenshots' && env.COMPARE_SCREENSHOTS == 'true' }} | |
run: | | |
ls ansible-hub-ui/test/screenshots.js/ | |
- 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 | |
grep specPattern cypress.config.js | |
npm run cypress:chrome | |
- name: "List new screenshots" | |
if: matrix.test == 'screenshots' | |
continue-on-error: true | |
run: | | |
ls ansible-hub-ui/test/cypress/screenshots/screenshots.js/ | |
- name: "Compare screenshots" | |
if: ${{ matrix.test == 'screenshots' && env.COMPARE_SCREENSHOTS == 'true' }} | |
working-directory: 'ansible-hub-ui/test' | |
run: | | |
changed=false | |
for orig in screenshots.js/*; do | |
echo $orig | |
new=cypress/screenshots/"$orig" | |
diff=cypress/screenshots/diff--"$(basename "$orig")" | |
num=$(compare -metric RMSE "$orig" "$new" "$diff" 2>&1 | awk '{ print $1 }') | |
echo $num | |
num=${num%.*} | |
if [ "$num" -gt 10 ]; then | |
echo "screenshot $orig changed: $num" 1>&2 | |
changed=true | |
fi | |
done | |
if [ "$changed" = true ]; then | |
echo "Process failed because change occured" | |
exit 1 | |
fi | |
- name: "Move Cache master screenshots" | |
if: ${{ matrix.test == 'screenshots' && env.COMPARE_SCREENSHOTS == 'false' }} | |
working-directory: 'ansible-hub-ui/test' | |
run: | | |
rm -rf screenshots.js/ | |
mv cypress/screenshots/screenshots.js/ ./ | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: screenshots_and_videos | |
path: | | |
ansible-hub-ui/test/cypress/screenshots | |
ansible-hub-ui/test/cypress/videos | |
- name: "Kill container, show debug info" | |
if: always() | |
working-directory: 'oci_env' | |
run: | | |
oci-env exec bash -c "pip3 list && pip3 install pipdeptree && pipdeptree" | |
oci-env compose logs | |
oci-env compose kill |