Skip to content

Commit

Permalink
Enable community profile in cypress CI (#4089)
Browse files Browse the repository at this point in the history
* copy code from #3195
* fix menuMissing exact match
* ensure community is server
* rename to BACKEND_FLAVOR
* build and serve community
* fix app files check
* fix path to static files
* expect /js/App
* correct mv
Issue: AAH-2242
  • Loading branch information
jerabekjiri authored Aug 15, 2023
1 parent e0265b4 commit bb814db
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 2 deletions.
60 changes: 59 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
SHORT_BRANCH=`sed 's/^refs\/heads\///' <<< $BRANCH`
case "${{ matrix.test }}" in
community*)
BACKEND_FLAVOR=community
echo "community"
;;
insights*)
BACKEND_FLAVOR=insights
echo "insights"
Expand Down Expand Up @@ -146,6 +150,22 @@ jobs:
BUILD_HASH=`ls dist/js/App*js | cut -d. -f2`
echo "BUILD_HASH=${BUILD_HASH}" >> $GITHUB_ENV
- name: "Build community UI"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
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-community
# 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"
if: ${{ env.BACKEND_FLAVOR == 'standalone' }}
run: |
Expand All @@ -160,6 +180,21 @@ jobs:
--rewrite '/v2/(.*) -> http://localhost:5001/v2/$1' \
--rewrite '/extensions/v2/(.*) -> http://localhost:5001/extensions/v2/$1' &
- name: "Serve community UI"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
run: |
mkdir -p www/
mv ansible-hub-ui/dist/* www/
cd www
echo '{}' > package.json
npm install local-web-server
node_modules/.bin/ws --port 8002 --directory . --spa 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: "Run insights UI"
if: ${{ env.BACKEND_FLAVOR == 'insights' }}
working-directory: 'ansible-hub-ui'
Expand Down Expand Up @@ -198,12 +233,18 @@ jobs:
run: |
cp -aiv ../.github/workflows/cypress/cypress.env.json."$BACKEND_FLAVOR" cypress.env.json
- name: "Ensure index.html uses the new js"
- name: "Ensure standalone index.html uses the new js"
if: ${{ env.BACKEND_FLAVOR == 'standalone' }}
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 community index.html uses the new js"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
run: |
echo 'expecting /js/App.'"$BUILD_HASH"'.js'
curl http://localhost:8002/index.html | tee /dev/stderr | grep '/js/App.'"$BUILD_HASH"'.js'
- name: "Ensure insights is served"
if: ${{ env.BACKEND_FLAVOR == 'insights' }}
run: |
Expand All @@ -212,6 +253,11 @@ jobs:
curl http://localhost:8002/preview/ansible/automation-hub/ | tee /dev/stderr | grep '/beta/apps/chrome/js/'
sleep 30
- name: "Ensure galaxykit can connect to API (community)"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
run: |
galaxykit -s http://localhost:8002/api/ -u admin -p admin collection list
- name: "Ensure galaxykit can connect to API (standalone)"
if: ${{ env.BACKEND_FLAVOR == 'standalone' }}
run: |
Expand All @@ -225,6 +271,11 @@ jobs:
--auth-url http://localhost:8002/auth/realms/redhat-external/protocol/openid-connect/token \
collection list
- name: "Check initial feature flags (community)"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
run: |
curl -s http://localhost:5001/api/_ui/v1/feature-flags/ | jq
- name: "Check initial feature flags (standalone)"
if: ${{ env.BACKEND_FLAVOR == 'standalone' }}
run: |
Expand All @@ -235,6 +286,13 @@ jobs:
run: |
curl -s http://localhost:5001/api/automation-hub/_ui/v1/feature-flags/ | jq
- name: "Check component versions & settings (community)"
if: ${{ env.BACKEND_FLAVOR == 'community' }}
run: |
HUB_TOKEN=`curl -s -u admin:admin -d '' http://localhost:5001/api/v3/auth/token/ | jq -r .token`
curl -s -H "Authorization: Token $HUB_TOKEN" http://localhost:5001/api/ | jq
curl -s -H "Authorization: Token $HUB_TOKEN" http://localhost:5001/api/_ui/v1/settings/ | jq
- name: "Check component versions & settings (standalone)"
if: ${{ env.BACKEND_FLAVOR == 'standalone' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cypress/compose.env.community
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROFILE=galaxy_ng/base:galaxy_ng/community
11 changes: 11 additions & 0 deletions .github/workflows/cypress/cypress.env.json.community
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"apiPrefix": "/api/",
"pulpPrefix": "/api/pulp/api/v3/",
"uiPrefix": "/ui/",
"username": "admin",
"password": "admin",
"containers": "localhost:5001",
"galaxykit": "galaxykit --ignore-certs",
"insightsLogin": false,
"disableRepoSwitch" : false
}
1 change: 1 addition & 0 deletions CHANGES/2242.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabled community profile in cypress CI
13 changes: 13 additions & 0 deletions test/cypress.env.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@
"galaxykit": "galaxykit --ignore-certs --auth-url 'http://localhost:8002/auth/realms/redhat-external/protocol/openid-connect/token'",
"insightsLogin" : true
}

// Community
{
"apiPrefix": "/api/",
"pulpPrefix": "/api/pulp/api/v3/",
"uiPrefix": "/ui/",
"username": "admin",
"password": "admin",
"containers": "localhost:5001",
"galaxykit": "galaxykit --ignore-certs",
"insightsLogin": false,
"disableRepoSwitch" : false
}
4 changes: 3 additions & 1 deletion test/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Cypress.Commands.add('menuPresent', {}, (name) => {

Cypress.Commands.add('menuMissing', {}, (name) => {
const last = name.split(' > ').pop();
return cy.contains('#page-sidebar a', last).should('not.exist');
return cy.get('#page-sidebar a').each(($el) => {
expect($el.text()).not.to.equal(last);
});
});

Cypress.Commands.add('menuGo', {}, (name) => {
Expand Down

0 comments on commit bb814db

Please sign in to comment.