Skip to content

Commit

Permalink
Parameterize current Alpine build
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Jul 10, 2024
1 parent 63016f2 commit 5870996
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
operating_system:
- alpine
pg_version:
- "9.5"
- "9.6"
Expand Down Expand Up @@ -40,6 +42,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system }}"
push: true
platforms: linux/amd64,linux/arm64
build-args: |
Expand All @@ -57,7 +60,7 @@ jobs:
env:
# but still use our public caches in any case
# they might be outdated, in which case a full rebuild will be triggered
TARGET_TAG: ${{ github.ref == 'refs/heads/main' && 'alpine' || 'dev-alpine' }}
TARGET_TAG: ${{ github.ref == 'refs/heads/main' && matrix.operating_system.flavor || 'dev-' + matrix.operating_system.flavor }}
CACHE_FROM: |
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6
Expand All @@ -68,13 +71,16 @@ jobs:
type=registry,ref=pgautoupgrade/pgautoupgrade:build-14
type=registry,ref=pgautoupgrade/pgautoupgrade:build-15
type=registry,ref=pgautoupgrade/pgautoupgrade:build-16
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}
# we cannot access TARGET_TAG from env
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

strategy:
matrix:
operating_system:
- flavor: "alpine"
version: "3.19"
pg_target:
- "12"
- "13"
Expand All @@ -99,10 +105,10 @@ jobs:
- name: Build image
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
load: true
tags: |
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
cache-to: type=inline
Expand All @@ -116,15 +122,17 @@ jobs:
make test
env:
PGTARGET: ${{ matrix.pg_target }}
OS_FLAVOR: ${{ matrix.operating_system.flavor }}

- name: Push image
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
platforms: linux/amd64,linux/arm64
tags: |
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}"
"pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
push: true
Expand All @@ -135,6 +143,7 @@ jobs:
if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main' && matrix.pg_target == '16'
uses: docker/build-push-action@v5
with:
file: "Dockerfile.${{ matrix.operating_system.flavor }}"
platforms: linux/amd64,linux/arm64
tags: |
"pgautoupgrade/pgautoupgrade:latest"
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test_down() {
test_run() {
VERSION=$1
TARGET=$2
FLAVOR=$3

# Delete any existing test PostgreSQL data
if [ -d postgres-data ]; then
Expand All @@ -25,7 +26,7 @@ test_run() {
docker compose -f "docker-compose-pg${VERSION}.yml" run --rm server create_db

# Start Redash normally, using an "autoupdate" version of PostgreSQL
TARGET_TAG="${TARGET}-alpine" docker compose -f docker-compose-pgauto.yml up --wait -d
TARGET_TAG="${TARGET}-${FLAVOR}" docker compose -f docker-compose-pgauto.yml up --wait -d

# Verify the PostgreSQL data files are now the target version
PGVER=$(sudo cat postgres-data/PG_VERSION)
Expand Down Expand Up @@ -64,7 +65,7 @@ cd test || exit 1
for version in "${PG_VERSIONS[@]}"; do
# Only test if the version is less than the latest version
if [[ $(echo "$version < $PGTARGET" | bc) -eq 1 ]]; then
test_run "$version" "$PGTARGET"
test_run "$version" "$PGTARGET" "$OS_FLAVOR"
fi
done

Expand Down

0 comments on commit 5870996

Please sign in to comment.