-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion to implement GitHub Actions #19
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: Build and push | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
base-images: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
pg_version: | ||
- "9.5" | ||
- "9.6" | ||
- "10" | ||
- "11" | ||
- "12" | ||
- "13" | ||
- "14" | ||
- "15" | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
"PGTARGET=16" | ||
target: "build-${{ matrix.pg_version }}" | ||
tags: "simpliandy/pgautoupgrade:build-${{ matrix.pg_version }}" | ||
cache-to: type=inline | ||
cache-from: type=registry,ref=simpliandy/pgautoupgrade:build-${{ matrix.pg_version }} | ||
|
||
target-images: | ||
runs-on: ubuntu-latest | ||
needs: base-images | ||
env: | ||
CACHE_FROM: | | ||
type=registry,ref=simpliandy/pgautoupgrade:build-9.5 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-9.6 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-10 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-11 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-12 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-13 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-14 | ||
type=registry,ref=simpliandy/pgautoupgrade:build-15 | ||
type=registry,ref=simpliandy/pgautoupgrade:${{ matrix.pg_target }}-alpine3.18 | ||
|
||
strategy: | ||
matrix: | ||
pg_target: | ||
- "13" | ||
- "14" | ||
- "15" | ||
- "16" | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
load: true | ||
tags: "simpliandy/pgautoupgrade:${{ matrix.pg_target }}-alpine3.18" | ||
build-args: | | ||
"PGTARGET=${{ matrix.pg_target }}" | ||
cache-to: type=inline | ||
cache-from: "${{ env.CACHE_FROM }}" | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Test image | ||
run: | | ||
make test | ||
env: | ||
PGTARGET: ${{ matrix.pg_target }} | ||
|
||
- name: Push image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
tags: "simpliandy/pgautoupgrade:${{ matrix.pg_target }}-alpine3.18" | ||
push: true | ||
cache-to: type=inline | ||
cache-from: "${{ env.CACHE_FROM }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
FAILURE=0 | ||
|
||
# Array of PostgreSQL versions for testing | ||
PG_VERSIONS=(9.5 9.6 10 11 12 13 14 15) | ||
|
||
# Stop any existing containers from previous test runs | ||
test_down() { | ||
docker-compose -f test/docker-compose-pgauto.yml down | ||
|
@@ -21,15 +24,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 | ||
if [ "${TARGET}" = "16" ]; then | ||
docker-compose -f docker-compose-pgauto.yml up -d | ||
elif [ "${TARGET}" = "15" ]; then | ||
TARGET_TAG=15-dev docker-compose -f docker-compose-pgauto.yml up -d | ||
elif [ "${TARGET}" = "14" ]; then | ||
TARGET_TAG=14-dev docker-compose -f docker-compose-pgauto.yml up -d | ||
elif [ "${TARGET}" = "13" ]; then | ||
TARGET_TAG=13-dev docker-compose -f docker-compose-pgauto.yml up -d | ||
fi | ||
TARGET_TAG="${TARGET}-alpine3.18" docker-compose -f docker-compose-pgauto.yml up -d | ||
|
||
# Verify the PostgreSQL data files are now the target version | ||
PGVER=$(sudo cat postgres-data/PG_VERSION) | ||
|
@@ -64,47 +59,21 @@ fi | |
# Change into the test directory | ||
cd test || exit 1 | ||
|
||
# Testing upgrading from each major PG version directly to PG 13 | ||
test_run 9.5 13 | ||
test_run 9.6 13 | ||
test_run 10 13 | ||
test_run 11 13 | ||
test_run 12 13 | ||
|
||
# Testing upgrading from each major PG version directly to PG 14 | ||
test_run 9.5 14 | ||
test_run 9.6 14 | ||
test_run 10 14 | ||
test_run 11 14 | ||
test_run 12 14 | ||
test_run 13 14 | ||
|
||
# Testing upgrading from each major PG version directly to PG 15 | ||
test_run 9.5 15 | ||
test_run 9.6 15 | ||
test_run 10 15 | ||
test_run 11 15 | ||
test_run 12 15 | ||
test_run 13 15 | ||
test_run 14 15 | ||
|
||
# Testing upgrading from each major PG version directly to PG 16 | ||
test_run 9.5 16 | ||
test_run 9.6 16 | ||
test_run 10 16 | ||
test_run 11 16 | ||
test_run 12 16 | ||
test_run 13 16 | ||
test_run 14 16 | ||
test_run 15 16 | ||
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" | ||
fi | ||
done | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's a better approach rather than my copy-and-edit one so far. 😄 |
||
|
||
# Check for failure | ||
if [ "${FAILURE}" -ne 0 ]; then | ||
echo | ||
echo "FAILURE: Automatic upgrade of PostgreSQL failed in one of the tests. Please investigate." | ||
echo | ||
exit 1 | ||
echo | ||
echo "FAILURE: Automatic upgrade of PostgreSQL failed in one of the tests. Please investigate." | ||
echo | ||
exit 1 | ||
else | ||
echo | ||
echo "SUCCESS: Automatic upgrade testing of PostgreSQL to PG 13, 14, 15, and 16 passed without issue." | ||
echo | ||
echo | ||
echo "SUCCESS: Automatic upgrade testing of PostgreSQL to all versions up to $LATEST_VERSION passed without issue." | ||
echo | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears the Postgres base container supports all of the following architectures: linux/amd64, linux/arm32v5, linux/arm32v6, linux/arm32v7, linux/arm64v8, linux/i386, linux/mips64le, linux/ppc64le, and linux/s390x... so why not go buck wild and support them all? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we might as well give it a shot and see how it goes.
@andyundso You up for that? (maybe later, after you're happy with the other bits? 😄)