Skip to content

Commit

Permalink
troubleshoot
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuscruz committed Nov 28, 2024
1 parent fdf1bc8 commit 3df3c29
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,38 @@ on:
- add-ci-tests

jobs:
export_variables:
runs-on: ubuntu-latest

outputs:
cr_name: ${{ steps.compute_container_registry_name.outputs.CR_NAME }}
primary_tag: ${{ steps.calculate_primary_sha.outputs.PRIMARY_SHA }}
replica_tag: ${{ steps.calculate_replica_sha.outputs.REPLICA_SHA }}

steps:
- name: Compute container registry name
id: compute_container_registry_name
run: echo "CR_NAME=$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Calculate SHA256 for postgres_primary.dockerfile
id: calculate_primary_sha
run: echo "PRIMARY_SHA=$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT

- name: Calculate SHA256 for postgres_replica.dockerfile
id: calculate_replica_sha
run: echo "REPLICA_SHA=$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT


prebuild:
needs: export_variables
runs-on: ubuntu-latest

env:
CR_NAME: ${{ needs.export_variables.outputs.cr_name }}
PRIMARY_TAG: ${{ needs.export_variables.outputs.primary_tag }}
REPLICA_TAG: ${{ needs.export_variables.outputs.replica_tag }}


steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -24,20 +53,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Calculate SHA256 for postgres_primary.dockerfile
run: echo "PRIMARY_SHA=$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_ENV

- name: Calculate SHA256 for postgres_replica.dockerfile
run: echo "REPLICA_SHA=$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_ENV

- name: Compute container registry name
run: echo "CR_NAME=$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build and tag primary Docker image
run: docker build -f postgres_primary.dockerfile -t $CR_NAME/postgres_primary:${{ env.PRIMARY_SHA }} .
run: docker build -f postgres_primary.dockerfile -t $CR_NAME/postgres_primary:${{ env.PRIMARY_TAG }} .

- name: Build and tag replica Docker image
run: docker build -f postgres_replica.dockerfile -t $CR_NAME/postgres_replica:${{ env.REPLICA_SHA }} .
run: docker build -f postgres_replica.dockerfile -t $CR_NAME/postgres_replica:${{ env.REPLICA_TAG }} .

- name: Push primary Docker image
run: docker push $CR_NAME/postgres_primary:${{ env.PRIMARY_SHA }}
Expand All @@ -46,17 +66,20 @@ jobs:
run: docker push $CR_NAME/postgres_replica:${{ env.REPLICA_SHA }}

rspec:
needs: prebuild
needs: [export_variables, prebuild]
runs-on: ubuntu-latest

env:


strategy:
matrix:
ruby: [3.1.6, 3.2.5, 3.3.5]
rails: ['~> 7.0.0', '7.1.0', '8.0.0']
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.rails }}
services:
postgres_primary:
image: $CR_NAME/postgres_primary:${{ env.PRIMARY_SHA }}
image: $CR_NAME/postgres_primary:${{ env.PRIMARY_TAG }}
ports:
- 5432:5432
env:
Expand All @@ -67,7 +90,7 @@ jobs:
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"

postgres_replica:
image: $CR_NAME/postgres_replica:${{ env.REPLICA_SHA }}
image: $CR_NAME/postgres_replica:${{ env.REPLICA_TAG }}
ports:
- 5433:5432
env:
Expand Down

0 comments on commit 3df3c29

Please sign in to comment.