diff --git a/.github/workflows/demo-deploy-action.yml b/.github/workflows/demo-deploy-action.yml index c257bd6f6e..e0a1a78845 100644 --- a/.github/workflows/demo-deploy-action.yml +++ b/.github/workflows/demo-deploy-action.yml @@ -42,7 +42,7 @@ jobs: java-version: ${{vars.JAVA_VERSION}} distribution: 'adopt' - - name: Set up node 18 + - name: Set up node ${{vars.NODE_VERSION}} uses: actions/setup-node@v4 with: node-version: ${{vars.NODE_VERSION}} diff --git a/.github/workflows/deploy-action.yml b/.github/workflows/deploy-action.yml index 44dee585c9..d944478a5b 100644 --- a/.github/workflows/deploy-action.yml +++ b/.github/workflows/deploy-action.yml @@ -6,6 +6,20 @@ on: jobs: + get-e2e-files: + runs-on: ubuntu-24.04 + outputs: + file_list: ${{ steps.generate-file-list.outputs.file_list }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate file list + id: generate-file-list + run: | + FILES=$(ls frontend/cypress/e2e | jq -R . | jq -s . | jq -c) + echo $FILES + echo "file_list=$FILES" >> $GITHUB_OUTPUT extract-version: runs-on: ubuntu-latest @@ -32,10 +46,10 @@ jobs: java-version: ${{vars.JAVA_VERSION}} distribution: 'adopt' - - name: Set up node 18 + - name: Set up node ${{vars.NODE_VERSION}} uses: actions/setup-node@v4 with: - node-version: 18.17.1 + node-version: ${{vars.NODE_VERSION}} - name: Install Dependencies run: cd ./frontend && npm ci @@ -68,9 +82,57 @@ jobs: - name: print imagetags run: echo ${{ needs.extract-version.outputs.okr-docker-image}} + + e2e-docker: + runs-on: ubuntu-24.04 + needs: [build-docker-image, extract-version, get-e2e-files] + strategy: + fail-fast: false + matrix: + file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }} + steps: + - uses: actions/checkout@v4 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: okr-image + path: /tmp + + - name: Load image + run: docker load --input /tmp/okr-docker-image.tar + + - name: Run keyloak server + run: cd docker && docker compose up -d keycloak-pitc + + - name: run Springboot okr application + run: | + docker run --network=host \ + -e SPRING_PROFILES_ACTIVE=integration-test \ + ${{ needs.read-version.outputs.okr-docker-image}} & + + - name: Cypress run e2e tests + uses: cypress-io/github-action@v6 + with: + build: npm i -D cypress + working-directory: frontend + install: false + wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544' + wait-on-timeout: 120 + browser: chrome + headed: false + config: baseUrl=http://pitc.okr.localhost:8080 + spec: cypress/e2e/${{ matrix.file }} + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: cypress-screenshots for ${{ matrix.file }} + path: frontend/cypress/screenshots + okr-deploy: runs-on: ubuntu-latest - needs: [build-docker-image, extract-version] + needs: [e2e-docker, extract-version] steps: - name: Checkout project uses: actions/checkout@v4 diff --git a/.github/workflows/staging-deploy-action.yml b/.github/workflows/staging-deploy-action.yml index 07d18713e1..7a7cd73aee 100644 --- a/.github/workflows/staging-deploy-action.yml +++ b/.github/workflows/staging-deploy-action.yml @@ -7,6 +7,21 @@ on: branches: [ main ] jobs: + get-e2e-files: + runs-on: ubuntu-24.04 + outputs: + file_list: ${{ steps.generate-file-list.outputs.file_list }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate file list + id: generate-file-list + run: | + FILES=$(ls frontend/cypress/e2e | jq -R . | jq -s . | jq -c) + echo $FILES + echo "file_list=$FILES" >> $GITHUB_OUTPUT + update-version: if: github.event.pull_request.merged == true runs-on: ubuntu-24.04 @@ -47,6 +62,10 @@ jobs: build-docker-image: needs: update-version runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }} steps: - uses: actions/checkout@v4 @@ -92,62 +111,49 @@ jobs: - name: print imagetags run: echo ${{ needs.update-version.outputs.okr-docker-image}} -# e2e-docker: -# runs-on: ubuntu-24.04 -# needs: [build-docker-image,update-version] -# steps: -# - uses: actions/checkout@v4 -# -# - name: Download artifact -# uses: actions/download-artifact@v4 -# with: -# name: okr-image -# path: /tmp -# -# - name: Load image -# run: docker load --input /tmp/okr-docker-image.tar -# -# - name: show images -# run: docker image ls -a -# -# - name: Run docker image -# run: | -# docker run --network=host \ -# -e SPRING_PROFILES_ACTIVE=integration-test \ -# ${{ needs.update-version.outputs.okr-docker-image}} & -# -# - name: run keycloak docker -# run: | -# docker run \ -# -e KEYCLOAK_ADMIN=admin \ -# -e KEYCLOAK_ADMIN_PASSWORD=keycloak \ -# -v ./docker/config/realm-export.json:/opt/keycloak/data/import/realm.json \ -# -p 8544:8080 \ -# quay.io/keycloak/keycloak:23.0.1 \ -# start-dev --import-realm & -# -# - uses: abhi1693/setup-browser@v0.3.5 -# with: -# browser: chrome -# version: latest -# -# - name: Cypress run e2e tests -# uses: cypress-io/github-action@v6 -# with: -# build: npm i -D cypress -# install: false -# wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544' -# wait-on-timeout: 120 -# browser: chrome -# headed: true -# working-directory: frontend -# config: baseUrl=http://pitc.okr.localhost:8080 -# -# - uses: actions/upload-artifact@v4 -# if: always() -# with: -# name: cypress-screenshots -# path: frontend/cypress/screenshots + e2e-docker: + runs-on: ubuntu-24.04 + needs: [build-docker-image,update-version] + steps: + - uses: actions/checkout@v4 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: okr-image + path: /tmp + + - name: Load image + run: docker load --input /tmp/okr-docker-image.tar + + - name: Run keyloak server + run: cd docker && docker compose up -d keycloak-pitc + + - name: run Springboot okr application + run: | + docker run --network=host \ + -e SPRING_PROFILES_ACTIVE=integration-test \ + ${{ needs.read-version.outputs.okr-docker-image}} & + + - name: Cypress run e2e tests + uses: cypress-io/github-action@v6 + with: + build: npm i -D cypress + working-directory: frontend + install: false + wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544' + wait-on-timeout: 120 + browser: chrome + headed: false + config: baseUrl=http://pitc.okr.localhost:8080 + spec: cypress/e2e/${{ matrix.file }} + + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: cypress-screenshots ${{ matrix.file }} + path: frontend/cypress/screenshots - uses: actions/upload-artifact@v4 if: always() @@ -157,7 +163,7 @@ jobs: upload-to-quay: runs-on: ubuntu-latest - needs: [update-version, build-docker-image] #[e2e-docker, update-version] + needs: [update-version, e2e-docker] #[e2e-docker, update-version] steps: - uses: actions/checkout@v4