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 4e73841
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
46 changes: 26 additions & 20 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,14 +42,15 @@ 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: |
"PGTARGET=16"
target: "build-${{ matrix.pg_version }}"
tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}"
tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.operating_system }}"
cache-to: type=inline
cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}
cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.operating_system }}

target-images:
runs-on: ubuntu-latest
Expand All @@ -57,24 +60,24 @@ 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' }}
CACHE_FROM: |
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6
type=registry,ref=pgautoupgrade/pgautoupgrade:build-10
type=registry,ref=pgautoupgrade/pgautoupgrade:build-11
type=registry,ref=pgautoupgrade/pgautoupgrade:build-12
type=registry,ref=pgautoupgrade/pgautoupgrade:build-13
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
# we cannot access TARGET_TAG from env
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-10-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-11-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-12-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-13-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-14-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-15-${{ matrix.operating_system }}
type=registry,ref=pgautoupgrade/pgautoupgrade:build-16-${{ matrix.operating_system }}
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 }}
strategy:
matrix:
operating_system:
- flavor: "alpine"
version: "3.19"
pg_target:
- "12"
- "13"
Expand All @@ -99,10 +102,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 +119,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 +140,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 4e73841

Please sign in to comment.