6666 type : string
6767 required : false
6868 default : " ubuntu-22.04-large"
69+ deduplication_id :
70+ type : string
71+ required : false
72+ description : Unique id per workflow run. Must be set to unique value if dispatched multiple times for a single workflow.
73+ default : " "
6974 chromatic_enable :
7075 description : ' Enable Chromatic Tests'
7176 required : false
9297 PYPI_USERNAME : " datavisyn"
9398 PYTHON_VERSION : " 3.10"
9499 WORKFLOW_BRANCH : " main"
100+ POSTGRES_HOSTNAME : postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
95101
96102permissions :
97103 contents : write
@@ -112,13 +118,13 @@ jobs:
112118 runs-on : ${{ inputs.runs_on }}
113119 steps :
114120 - name : Checkout source repository
115- uses : actions/checkout@v3
121+ uses : actions/checkout@v4
116122 with :
117123 ref : ${{ inputs.branch }}
118124 token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
119125 fetch-depth : ${{ inputs.chromatic_enable && '0' || '1' }}
120126 - name : Checkout github-workflows
121- uses : actions/checkout@v3
127+ uses : actions/checkout@v4
122128 with :
123129 repository : datavisyn/github-workflows
124130 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -130,6 +136,7 @@ jobs:
130136 npm_registry : ${{ env.NPM_REGISTRY }}
131137 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
132138 run_webpack : ${{ inputs.node_run_webpack }}
139+ enable_cache : ${{ inputs.runs_on != 'self-hosted' }}
133140 - name : Run Chromatic
134141 if : ${{ inputs.chromatic_enable }}
135142@@ -145,12 +152,12 @@ jobs:
145152 runs-on : ${{ inputs.runs_on }}
146153 steps :
147154 - name : Checkout source repository
148- uses : actions/checkout@v3
155+ uses : actions/checkout@v4
149156 with :
150157 ref : ${{ inputs.branch }}
151158 token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
152159 - name : Checkout github-workflows
153- uses : actions/checkout@v3
160+ uses : actions/checkout@v4
154161 with :
155162 repository : datavisyn/github-workflows
156163 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -160,6 +167,7 @@ jobs:
160167 with :
161168 python_version : ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }}
162169 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
170+ enable_cache : ${{ inputs.runs_on != 'self-hosted' }}
163171
164172 # If cypress is used, build node and python sequentially as it is avoiding the duplicate install overhead
165173 build-node-python-cypress :
@@ -185,17 +193,34 @@ jobs:
185193 --health-interval 10s
186194 --health-timeout 5s
187195 --health-retries 5
196+ --name postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
188197 ports :
189- - 5432:5432
198+ # will assign a random free host port
199+ - 5432/tcp
190200
191201 steps :
202+ - name : Set self-hosted env variable to github env
203+ run : echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
204+ - name : Set github token, hostname, port and docker network for self-hosted runner
205+ if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
206+ run : |
207+ {
208+ echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
209+ echo "POSTGRES_PORT=5432"
210+ } >> "$GITHUB_ENV"
211+ docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} "postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
212+ - name : Set postgres connection details to hosted runner
213+ if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
214+ run : |
215+ echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
216+ echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
192217 - name : Checkout source repository
193- uses : actions/checkout@v3
218+ uses : actions/checkout@v4
194219 with :
195220 ref : ${{ inputs.branch }}
196221 token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
197222 - name : Checkout github-workflows
198- uses : actions/checkout@v3
223+ uses : actions/checkout@v4
199224 with :
200225 repository : datavisyn/github-workflows
201226 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -207,11 +232,13 @@ jobs:
207232 npm_registry : ${{ env.NPM_REGISTRY }}
208233 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
209234 run_webpack : false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
235+ enable_cache : ${{ inputs.cypress_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
210236 - name : Build python
211237 uses : ./tmp/github-workflows/.github/actions/build-python
212238 with :
213239 python_version : ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }}
214240 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
241+ enable_cache : ${{ inputs.cypress_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
215242 - name : Decrypt .env.enc and <app>/.env.enc
216243 run : |
217244 yarn run env:decrypt -pass env:ENV_PASSWORD || true
@@ -233,8 +260,10 @@ jobs:
233260 yarn start dev_server_only=true
234261 make start
235262 wait-on : " http://localhost:8080, http://localhost:9000/health"
236- env : ${{ secrets.CYPRESS_ENV }}
237263 spec : ${{ inputs.cypress_spec_param }}
264+ env :
265+ POSTGRES_HOSTNAME : ${{ env.POSTGRES_HOSTNAME }}
266+ POSTGRES_PORT : ${{ env.POSTGRES_PORT }}
238267 # rspack currently does not support Cypress component tests
239268 # - name: Run cypress component tests
240269 # uses: cypress-io/github-action@v6
@@ -247,7 +276,7 @@ jobs:
247276 # # TODO: Do component tests need the frontend/backend?
248277 # env: ${{ secrets.CYPRESS_ENV }}
249278 - name : Upload cypress screenshots
250- uses : actions/upload-artifact@v4
279+ uses : actions/upload-artifact@v3
251280 if : failure()
252281 with :
253282 name : cypress-screenshots
@@ -283,17 +312,34 @@ jobs:
283312 --health-interval 10s
284313 --health-timeout 5s
285314 --health-retries 5
315+ --name postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
286316 ports :
287- - 5432:5432
317+ # will assign a random free host port
318+ - 5432/tcp
288319
289320 steps :
321+ - name : Set system env variable to github env
322+ run : echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
323+ - name : Set github token, hostname, port and docker network for self-hosted runner
324+ if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
325+ run : |
326+ {
327+ echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
328+ echo "POSTGRES_PORT=5432"
329+ } >> "$GITHUB_ENV"
330+ docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
331+ - name : Set postgres connection details to hosted runner
332+ if : env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
333+ run : |
334+ echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
335+ echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
290336 - name : Checkout source repository
291- uses : actions/checkout@v3
337+ uses : actions/checkout@v4
292338 with :
293339 ref : ${{ inputs.branch }}
294340 token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
295341 - name : Checkout github-workflows
296- uses : actions/checkout@v3
342+ uses : actions/checkout@v4
297343 with :
298344 repository : datavisyn/github-workflows
299345 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -305,11 +351,13 @@ jobs:
305351 npm_registry : ${{ env.NPM_REGISTRY }}
306352 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
307353 run_webpack : false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
354+ enable_cache : ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
308355 - name : Build python
309356 uses : ./tmp/github-workflows/.github/actions/build-python
310357 with :
311358 python_version : ${{ secrets.PYTHON_VERSION || env.PYTHON_VERSION }}
312359 github_ro_token : ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
360+ enable_cache : ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
313361 - name : Decrypt .env.enc and <app>/.env.enc
314362 run : |
315363 yarn run env:decrypt -pass env:ENV_PASSWORD || true
0 commit comments