Run Cypress tests in parallel to optimize performance (#2433)

This commit is contained in:
Jon Koops 2022-04-11 16:18:24 +02:00 committed by GitHub
parent 7418bca8f4
commit 03927cda3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 17 deletions

View file

@ -5,8 +5,10 @@ on:
pull_request: pull_request:
branches: [main] branches: [main]
jobs: jobs:
cypress-run: setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
server-path: ${{ steps.extract-server.outputs.path }}
env: env:
ADMIN_UI_PATH: admin-ui ADMIN_UI_PATH: admin-ui
KEYCLOAK_SERVER_PATH: keycloak-server KEYCLOAK_SERVER_PATH: keycloak-server
@ -41,21 +43,33 @@ jobs:
- name: Build Keycloak Server - name: Build Keycloak Server
working-directory: ${{ env.KEYCLOAK_SERVER_PATH }} working-directory: ${{ env.KEYCLOAK_SERVER_PATH }}
run: mvn clean install --no-snapshot-updates --batch-mode --errors -DskipTests -DskipAccount2 -Pdistribution,admin-preview run: mvn clean install --no-snapshot-updates --batch-mode --errors -DskipTests -DskipCommon -DskipAccount2 -Pdistribution,admin-preview
- name: Configure distribution path - name: Extract Keycloak server
id: extract-server
working-directory: ${{ env.KEYCLOAK_SERVER_PATH }} working-directory: ${{ env.KEYCLOAK_SERVER_PATH }}
run: | run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
tar -xvf quarkus/dist/target/keycloak-$VERSION.tar.gz -C quarkus/dist/target/ mkdir ../server
echo "KEYCLOAK_SERVER_BIN=keycloak-server/quarkus/dist/target/keycloak-$VERSION/bin" >> $GITHUB_ENV tar -xvf quarkus/dist/target/keycloak-$VERSION.tar.gz -C ../server
echo "::set-output name=path::server/keycloak-$VERSION"
- name: Start Keycloak Server - name: Cache Keycloak server
working-directory: ${{ env.KEYCLOAK_SERVER_BIN }} uses: actions/cache@v3
run: ./kc.sh start-dev --features=admin2,admin-fine-grained-authz,declarative-user-profile &> ~/server.log & with:
env: path: ${{ steps.extract-server.outputs.path }}
KEYCLOAK_ADMIN: admin key: ${{ github.sha }}
KEYCLOAK_ADMIN_PASSWORD: admin
test:
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5]
steps:
- name: Check out Admin UI
uses: actions/checkout@v3
- name: Set up Node - name: Set up Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
@ -63,29 +77,68 @@ jobs:
node-version: 16 node-version: 16
check-latest: true check-latest: true
cache: npm cache: npm
cache-dependency-path: ${{ env.ADMIN_UI_PATH }}/package-lock.json
- name: Cache Node modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: |
~/.cache/Cypress
node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies - name: Install dependencies
working-directory: ${{ env.ADMIN_UI_PATH }} if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci run: npm ci
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
check-latest: true
cache: maven
- name: Restore Keycloak server
uses: actions/cache@v3
with:
path: ${{ needs.setup.outputs.server-path }}
key: ${{ github.sha }}
- name: Start Keycloak Server
working-directory: ${{ needs.setup.outputs.server-path }}/bin
run: ./kc.sh start-dev --features=admin2,admin-fine-grained-authz,declarative-user-profile &> ~/server.log &
env:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
- name: Run Cypress - name: Run Cypress
working-directory: ${{ env.ADMIN_UI_PATH }} uses: cypress-io/github-action@v2
run: CYPRESS_BASE_URL=http://localhost:8080/admin/ CYPRESS_KEYCLOAK_SERVER=http://localhost:8080 npm run start:cypress-tests with:
install: false
record: true
parallel: true
browser: chrome
wait-on: http://localhost:8080
env:
CYPRESS_BASE_URL: http://localhost:8080/admin/
CYPRESS_KEYCLOAK_SERVER: http://localhost:8080
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add Cypress videos artifacts - name: Add Cypress videos artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: failure() if: failure()
with: with:
name: cypress-videos name: cypress-videos
path: ${{ env.ADMIN_UI_PATH }}/assets/videos path: assets/videos
- name: Add Cypress screenshots artifacts - name: Add Cypress screenshots artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: failure() if: failure()
with: with:
name: cypress-screenshots name: cypress-screenshots
path: ${{ env.ADMIN_UI_PATH }}/assets/screenshots path: assets/screenshots
- name: Upload server logs - name: Upload server logs
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3

View file

@ -1,4 +1,5 @@
{ {
"projectId": "j4yhox",
"screenshotsFolder": "assets/screenshots", "screenshotsFolder": "assets/screenshots",
"videosFolder": "assets/videos", "videosFolder": "assets/videos",
"baseUrl": "http://localhost:8080", "baseUrl": "http://localhost:8080",