Skip to content

Commit 0db87dd

Browse files
committed
unify docker and local e2e jobs
1 parent a459327 commit 0db87dd

File tree

1 file changed

+76
-56
lines changed

1 file changed

+76
-56
lines changed

.github/workflows/reusable__e2e-testing.yml

+76-56
Original file line numberDiff line numberDiff line change
@@ -48,90 +48,110 @@ jobs:
4848
fi
4949
echo "file_list=$FILES" >> $GITHUB_OUTPUT
5050
51-
# Job to run tests in parallel based on the discovered files
52-
e2e-docker:
51+
# # Job to run tests in parallel based on the discovered files
52+
# e2e-docker:
53+
# needs: get-e2e-files
54+
# if: needs.get-e2e-files.outputs.file_list != '[]' && inputs.DOCKER_IMAGE_TAG != ''
55+
# runs-on: ubuntu-latest # Or ubuntu-24.04
56+
# strategy:
57+
# fail-fast: false # Continue running other tests even if one fails
58+
# matrix:
59+
# file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }}
60+
# env:
61+
# IMAGE_FILE_NAME: okr-docker-image.tar
62+
#
63+
# steps:
64+
# - run: echo "${{ github.run_id }}"
65+
# - name: Checkout Target Repo Code (for Cypress config/plugins)
66+
# uses: actions/checkout@v4
67+
#
68+
# - name: Download Docker image artifact
69+
# uses: actions/download-artifact@v4
70+
# with:
71+
# name: okr-image
72+
# path: ${{ runner.temp }}
73+
#
74+
# - name: Load image into Docker
75+
# run: docker load --input ${{ runner.temp }}/okr-docker-image.tar
76+
#
77+
# # --- E2E Test Execution Steps (Adjust as needed) ---
78+
# - name: Set up Docker Compose / Start Services (if needed)
79+
# run: cd docker && docker compose up -d keycloak-pitc
80+
#
81+
# - name: Run Application Container
82+
# run: |
83+
# docker run --network=host \
84+
# -e SPRING_PROFILES_ACTIVE=integration-test \
85+
# ${{inputs.DOCKER_IMAGE_TAG }} &
86+
#
87+
# - name: Set up node for Cypress
88+
# uses: actions/setup-node@v4
89+
# with:
90+
# node-version: ${{vars.NODE_VERSION}}
91+
#
92+
# - name: Cypress run e2e tests
93+
# uses: cypress-io/github-action@v6
94+
# with:
95+
# build: npm i -D cypress
96+
# working-directory: frontend
97+
# install: false
98+
# wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544'
99+
# wait-on-timeout: 120
100+
# browser: chrome
101+
# headed: false
102+
# config: baseUrl=http://pitc.okr.localhost:8080
103+
# spec: cypress/e2e/${{ matrix.file }}
104+
#
105+
# - uses: actions/upload-artifact@v4
106+
# if: always()
107+
# with:
108+
# name: cypress-screenshots for ${{ matrix.file }}
109+
# path: frontend/cypress/screenshots
110+
111+
e2e:
53112
needs: get-e2e-files
54-
if: needs.get-e2e-files.outputs.file_list != '[]' && inputs.DOCKER_IMAGE_TAG != ''
113+
if: needs.get-e2e-files.outputs.file_list != '[]' && inputs.COMMIT_HASH != ''
55114
runs-on: ubuntu-latest # Or ubuntu-24.04
56115
strategy:
57116
fail-fast: false # Continue running other tests even if one fails
58117
matrix:
59118
file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }}
60119
env:
61120
IMAGE_FILE_NAME: okr-docker-image.tar
121+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
122+
COMMIT_REF: ${{ inputs.COMMIT_HASH || (github.head_ref || github.ref_name) }}
62123

63124
steps:
64-
- run: echo "${{ github.run_id }}"
65125
- name: Checkout Target Repo Code (for Cypress config/plugins)
66126
uses: actions/checkout@v4
127+
with:
128+
ref: ${{ env.COMMIT_REF }}
129+
130+
- name: Set up Docker Compose / Start Services (if needed)
131+
run: cd docker && docker compose up -d keycloak-pitc
67132

68133
- name: Download Docker image artifact
134+
if: inputs.DOCKER_IMAGE_TAG != ''
69135
uses: actions/download-artifact@v4
70136
with:
71137
name: okr-image
72138
path: ${{ runner.temp }}
73139

74140
- name: Load image into Docker
141+
if: inputs.DOCKER_IMAGE_TAG != ''
75142
run: docker load --input ${{ runner.temp }}/okr-docker-image.tar
76143

77-
# --- E2E Test Execution Steps (Adjust as needed) ---
78-
- name: Set up Docker Compose / Start Services (if needed)
79-
run: cd docker && docker compose up -d keycloak-pitc
80-
81-
- name: Run Application Container
144+
- name: Run Application Container from image
145+
if: inputs.DOCKER_IMAGE_TAG != ''
82146
run: |
83147
docker run --network=host \
84148
-e SPRING_PROFILES_ACTIVE=integration-test \
85149
${{inputs.DOCKER_IMAGE_TAG }} &
86-
87-
- name: Set up node for Cypress
88-
uses: actions/setup-node@v4
89-
with:
90-
node-version: ${{vars.NODE_VERSION}}
91-
92-
- name: Cypress run e2e tests
93-
uses: cypress-io/github-action@v6
94-
with:
95-
build: npm i -D cypress
96-
working-directory: frontend
97-
install: false
98-
wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544'
99-
wait-on-timeout: 120
100-
browser: chrome
101-
headed: false
102-
config: baseUrl=http://pitc.okr.localhost:8080
103-
spec: cypress/e2e/${{ matrix.file }}
104-
105-
- uses: actions/upload-artifact@v4
106-
if: always()
107-
with:
108-
name: cypress-screenshots for ${{ matrix.file }}
109-
path: frontend/cypress/screenshots
110-
111-
e2e-local:
112-
needs: get-e2e-files
113-
if: needs.get-e2e-files.outputs.file_list != '[]' && inputs.COMMIT_HASH != ''
114-
runs-on: ubuntu-latest # Or ubuntu-24.04
115-
strategy:
116-
fail-fast: false # Continue running other tests even if one fails
117-
matrix:
118-
file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }}
119-
env:
120-
IMAGE_FILE_NAME: okr-docker-image.tar
121-
122-
steps:
123-
- name: Checkout Target Repo Code (for Cypress config/plugins)
124-
uses: actions/checkout@v4
125-
with:
126-
ref: ${{ inputs.COMMIT_HASH }}
127-
128-
- name: Set up Docker Compose / Start Services (if needed)
129-
run: cd docker && docker compose up -d keycloak-pitc
130-
131-
- name: Run application
150+
151+
- name: Run application from local code
152+
if: inputs.COMMIT_HASH != ''
132153
run: cd ./backend && mvn spring-boot:run -Dspring-boot.run.profiles=integration-test &
133154

134-
135155
- name: Set up node for Cypress
136156
uses: actions/setup-node@v4
137157
with:

0 commit comments

Comments
 (0)