Cypress #3733
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: | |
push: | |
branches: [main, release/**] | |
pull_request: | |
branches: [main, release/**] | |
schedule: | |
- cron: '0 4 * * *' | |
workflow_dispatch: | |
inputs: | |
keycloakRepo: | |
description: The location of the Keycloak repo (e.g. keycloak/keycloak). | |
required: false | |
keycloakBranch: | |
description: The branch to check out for the Keycloak repo (e.g. main). | |
required: false | |
concurrency: | |
# Only cancel jobs for new commits on PRs, and always do a complete run on other branches (e.g. `main`). | |
# See: https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value | |
group: cypress-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build-keycloak: | |
if: ${{ github.event_name != 'schedule' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
path: admin-ui-repo | |
- name: Check out Keycloak Server | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ inputs.keycloakRepo || 'keycloak/keycloak' }} | |
ref: ${{ inputs.keycloakBranch || (contains(github.ref, 'release/') && github.ref || 'main') }} | |
path: keycloak-repo | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 11 | |
check-latest: true | |
cache: maven | |
- name: Build Admin UI | |
working-directory: admin-ui-repo | |
run: mvn clean install --batch-mode --file keycloak-theme/pom.xml | |
- name: Build Keycloak Server | |
working-directory: keycloak-repo | |
run: | | |
mvn clean install --no-snapshot-updates --batch-mode --errors -DskipTests -DskipCommon -DskipAccount2 -Pdistribution | |
mv quarkus/dist/target/keycloak-999.0.0-SNAPSHOT.tar.gz ../keycloak-999.0.0-SNAPSHOT.tar.gz | |
- name: Upload Keycloak server | |
uses: actions/upload-artifact@v4 | |
with: | |
name: keycloak | |
path: keycloak-999.0.0-SNAPSHOT.tar.gz | |
install-nightly: | |
if: ${{ github.event_name == 'schedule' }} | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Download Keycloak | |
id: extract-server | |
run: | | |
gh release -R keycloak/keycloak download nightly -p keycloak-999.0.0-SNAPSHOT.tar.gz | |
- name: Upload Keycloak server | |
uses: actions/upload-artifact@v4 | |
with: | |
name: keycloak | |
path: keycloak-999.0.0-SNAPSHOT.tar.gz | |
test: | |
needs: [build-keycloak, install-nightly] | |
if: always() && ( needs.build-keycloak.result == 'success' || needs.install-nightly.result == 'success' ) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
container: [1, 2, 3, 4, 5] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
check-latest: true | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Compile Admin Client | |
run: npm run build --workspace=@keycloak/keycloak-admin-client | |
- name: Restore Keycloak server | |
uses: actions/download-artifact@v3 | |
with: | |
name: keycloak | |
- name: Start LDAP server | |
run: npm run cy:ldap-server & | |
working-directory: apps/admin-ui | |
- name: Start Keycloak Server | |
run: | | |
tar xfvz keycloak-999.0.0-SNAPSHOT.tar.gz | |
keycloak-999.0.0-SNAPSHOT/bin/kc.sh start-dev --features=admin2,admin-fine-grained-authz,declarative-user-profile &> ~/server.log & | |
env: | |
KEYCLOAK_ADMIN: admin | |
KEYCLOAK_ADMIN_PASSWORD: admin | |
- name: Install Google Chrome | |
uses: abhi1693/setup-browser@v0.3.5 | |
with: | |
browser: chrome | |
version: latest | |
- name: Run Cypress | |
uses: cypress-io/github-action@v6 | |
continue-on-error: true | |
with: | |
install: false | |
record: true | |
parallel: true | |
browser: chrome | |
wait-on: http://localhost:8080 | |
working-directory: apps/admin-ui | |
env: | |
CYPRESS_BASE_URL: http://localhost:8080/admin/ | |
CYPRESS_KEYCLOAK_SERVER: http://localhost:8080 | |
CYPRESS_RECORD_KEY: b8f1d15e-eab8-4ee7-8e44-c6d7cd8fc0eb | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload server logs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: server-log-${{ matrix.container }} | |
path: ~/server.log |