Skip to content

Commit

Permalink
feat: add redis service to playwright workflow (#110)
Browse files Browse the repository at this point in the history
Co-authored-by: Holger Stitz <holger.stitz@datavisyn.io>
  • Loading branch information
dvviktordelev and thinkh authored Nov 14, 2024
1 parent 46cc7aa commit 6077d00
Showing 1 changed file with 53 additions and 11 deletions.
64 changes: 53 additions & 11 deletions .github/workflows/build-node-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,43 @@ jobs:
ports:
# will assign a random free host port
- 5432/tcp

redis:
image: redis:6
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
ports:
- 6379/tcp

steps:
- name: Set self-hosted env variable to github env
run: echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
- name: Set github token, hostname, port and docker network for self-hosted runner
- name: Set up custom postgres and redis hostname, port and docker network for self-hosted runner
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
run: |
env:
REDIS_HOSTNAME: redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
REDIS_PORT: 6379
run: |
{
echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
echo "POSTGRES_PORT=5432"
echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
echo "REDIS_PORT=6379"
} >> "$GITHUB_ENV"
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} "postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
- name: Set postgres connection details to hosted runner
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }}
- name: Set service connection details to hosted runner
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
run: |
echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
{
echo "POSTGRES_HOSTNAME=localhost"
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}"
echo "REDIS_HOSTNAME=localhost"
echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}"
} >> "$GITHUB_ENV"
- name: Checkout source repository
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -334,23 +354,45 @@ jobs:
ports:
# will assign a random free host port
- 5432/tcp

redis:
image: redis:6
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
ports:
- 6379/tcp

steps:
- name: Set system env variable to github env
run: echo "GH_ACTIONS_SELF_HOSTED_NETWORK_NAME=${GH_ACTIONS_SELF_HOSTED_NETWORK_NAME}" >> "$GITHUB_ENV"
- name: Set github token, hostname, port and docker network for self-hosted runner
- name: Set up custom postgres and redis hostname, port and docker network for self-hosted runner
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME != ''
env:
REDIS_HOSTNAME: redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}
REDIS_PORT: 6379
run: |
{
echo "POSTGRES_HOSTNAME=postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
echo "POSTGRES_PORT=5432"
echo "REDIS_HOSTNAME=redis_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}"
echo "REDIS_PORT=6379"
} >> "$GITHUB_ENV"
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.POSTGRES_HOSTNAME }}
- name: Set postgres connection details to hosted runner
docker network connect ${{ env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME }} ${{ env.REDIS_HOSTNAME }}
- name: Set service connection details to hosted runner
if: env.GH_ACTIONS_SELF_HOSTED_NETWORK_NAME == ''
run: |
echo "POSTGRES_HOSTNAME=localhost" >> "$GITHUB_ENV"
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}" >> "$GITHUB_ENV"
{
echo "POSTGRES_HOSTNAME=localhost"
echo "POSTGRES_PORT=${{ job.services.postgres.ports['5432'] }}"
echo "REDIS_HOSTNAME=localhost"
echo "REDIS_PORT=${{ job.services.redis.ports['6379'] }}"
} >> "$GITHUB_ENV"
- name: Checkout source repository
uses: actions/checkout@v4
with:
Expand Down

0 comments on commit 6077d00

Please sign in to comment.