Skip to content

Commit

Permalink
reenable e2e test (#1161)
Browse files Browse the repository at this point in the history
* rename e2e on staging deploy action

* add e2e for deploy action
  • Loading branch information
kcinay055679 authored Nov 15, 2024
1 parent f382e36 commit a3c598a
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/demo-deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
68 changes: 65 additions & 3 deletions .github/workflows/deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
120 changes: 63 additions & 57 deletions .github/workflows/staging-deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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/[email protected]
# 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()
Expand All @@ -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

Expand Down

0 comments on commit a3c598a

Please sign in to comment.