From e8265011ee1c03c6a66206f1f861444fe5192505 Mon Sep 17 00:00:00 2001 From: Adam Hendel Date: Wed, 12 Nov 2025 18:27:04 -0600 Subject: [PATCH 1/2] update ci for image builds --- .github/CODEOWNERS | 2 +- .../actions/build-and-push-to-quay/action.yml | 124 ----------- .github/workflows/pg-image-build.yml | 207 ++++++++++++++++++ .github/workflows/pg_later_ext.yml | 150 +------------ .github/workflows/pgxn-release.yml | 2 +- 5 files changed, 219 insertions(+), 266 deletions(-) delete mode 100644 .github/actions/build-and-push-to-quay/action.yml create mode 100644 .github/workflows/pg-image-build.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b546077..0f9e029 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @ChuckHend @ianstanton @ryw @sjmiller609 @nhudson +* @ChuckHend diff --git a/.github/actions/build-and-push-to-quay/action.yml b/.github/actions/build-and-push-to-quay/action.yml deleted file mode 100644 index 56a449a..0000000 --- a/.github/actions/build-and-push-to-quay/action.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: 'Build and push to Quay' -description: 'Builds a container image and pushes it to our Quay organization' -inputs: - image_name: - description: 'The name of the image, not including the registry or the tag, for example "postgres"' - required: true - registry: - description: 'The name of the image, not including the registry or the tag, for example "postgres"' - required: false - default: "quay.io/tembo" - docker_directory: - description: 'The relative path to a directory in which there is a Dockerfile' - required: false - default: '.' - quay_user: - required: true - description: "Quay 'robot user' user name" - quay_password: - required: true - description: "Quay 'robot user' access token" - publish_calver: - description: 'Should we tag with calendar versioning?' - required: false - default: false - calver_suffix: - description: 'Optional suffix to the calendar version' - required: false - default: "" - publish_latest: - description: "Should we tag with 'latest'?" - required: false - default: false - tag_cargo_version_if_present: - description: "Should we tag with the version found in Cargo.toml, if found?" - required: false - default: false - tags: - description: "Whitespace-separated tags, not including the registry, for example 'v1' or 'v1 release-1.0'. There are also some default tags provided, please see the other options of this action." - required: false - default: "" -outputs: {} -runs: - using: "composite" - steps: - - name: Install TOML parser - shell: bash - run: | - set -xe - wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 - mv stoml_linux_amd64 stoml - chmod +x stoml - sudo mv stoml /usr/local/bin/ - - name: Create whitespace-separated tags list - shell: bash - id: tags - run: | - set -e - - # input tags - TAGS='${{ inputs.tags }}' - SHORT_SHA=$(git rev-parse --short HEAD) - - cd ${{ inputs.docker_directory }} - - if [ "${{ inputs.tag_cargo_version_if_present }}" == "true" ] && test -f "Cargo.toml"; then - echo "Cargo file detected, adding to tags" - VERSION=$(stoml Cargo.toml package.version)-${SHORT_SHA} - TAGS="$TAGS $VERSION" - fi - - # Calendar version - if [ "${{ inputs.publish_calver }}" == "true" ]; then - # A date without leading zeros, for example: - # 2023.1.26 - CAL_VER=$(date '+%Y.%-m.%-d') - TAGS="$TAGS ${CAL_VER}${{ inputs.calver_suffix }}" - fi - - # latest - if [ "${{ inputs.publish_latest }}" == "true" ]; then - TAGS="$TAGS latest" - fi - - # Short Git hash - TAGS="$TAGS ${SHORT_SHA}" - - echo "TAGS=$TAGS" >> $GITHUB_OUTPUT - - name: Run pre-build hooks - shell: bash - run: | - cd ${{ inputs.docker_directory }} - if [[ -f pre-build-hook.sh ]]; then - echo "detected pre-build hook, running" - /bin/bash pre-build-hook.sh - else - echo "no pre build hook detected" - fi - - name: Build image and tag - shell: bash - run: | - set -xe - # Build the image - docker build -t ${{ inputs.image_name }} ${{ inputs.docker_directory }} - # Tag with each tag in the comma-separate list - IFS=' ' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.TAGS }}" - for tag in "${TAG_ARRAY[@]}"; do - docker tag ${{ inputs.image_name }} ${{ inputs.image_name }}:$tag - done - - name: Login to Quay - uses: docker/login-action@v2 - with: - registry: ${{ inputs.registry }} - username: ${{ inputs.quay_user }} - password: ${{ inputs.quay_password }} - - name: Push to Quay - if: inputs.image_name != 'tembo-pg-cnpg' - shell: bash - run: | - set -xe - IFS=' ' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.TAGS }}" - for tag in "${TAG_ARRAY[@]}"; do - docker tag ${{ inputs.image_name }}:$tag ${{ inputs.registry}}/${{ inputs.image_name }}:$tag - docker push ${{ inputs.registry}}/${{ inputs.image_name }}:$tag - done diff --git a/.github/workflows/pg-image-build.yml b/.github/workflows/pg-image-build.yml new file mode 100644 index 0000000..645c7a3 --- /dev/null +++ b/.github/workflows/pg-image-build.yml @@ -0,0 +1,207 @@ +name: Build Postgres with pg_later + +defaults: + run: + shell: bash + +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: ['v[0-9]+.[0-9]+.[0-9]+'] +jobs: + build_and_push_amd64: + name: Build and push AMD64 images + if: github.repository_owner == 'ChuckHend' + runs-on: + - ubuntu-latest + outputs: + short_sha: ${{ steps.versions.outputs.SHORT_SHA }} + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install stoml + shell: bash + run: | + set -xe + sudo apt-get update + sudo apt-get install -y wget + wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 &> /dev/null + mv stoml_linux_amd64 stoml + chmod +x stoml + sudo mv stoml /usr/local/bin/ + - name: Set version strings + id: versions + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "TAG_VER=$(/usr/local/bin/stoml Cargo.toml package.version)" >> $GITHUB_OUTPUT + echo "PGRX_VER=$(/usr/local/bin/stoml Cargo.toml dependencies.pgrx | tr -d '="')" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push -- Commit + # push commit build when not a release + if: github.event_name != 'release' + run: | + docker build \ + --build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \ + -f ./images/pglater-pg/Dockerfile \ + -t ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64 . + docker push ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64 + + - name: Build and push -- Release + if: github.event_name == 'release' + run: | + docker build \ + --build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \ + -f ./images/pglater-pg/Dockerfile \ + -t ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-amd64 \ + -t ghcr.io/chuckhend/pglater-pg:latest-amd64 . + docker push ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-amd64 + docker push ghcr.io/chuckhend/pglater-pg:latest-amd64 + + build_and_push_arm64: + name: Build and push ARM64 images + if: github.repository_owner == 'ChuckHend' + runs-on: + - ubicloud-standard-2-arm-ubuntu-2204 + outputs: + short_sha: ${{ steps.versions.outputs.SHORT_SHA }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Install stoml + shell: bash + run: | + set -xe + sudo apt-get update + sudo apt-get install -y wget + wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_armv7 &> /dev/null + mv stoml_linux_armv7 stoml + chmod +x stoml + sudo mv stoml /usr/local/bin/ + - name: Set version strings + id: versions + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "TAG_VER=$(/usr/local/bin/stoml Cargo.toml package.version)" >> $GITHUB_OUTPUT + echo "PGRX_VER=$(/usr/local/bin/stoml Cargo.toml dependencies.pgrx | tr -d '="')" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push -- Commit + # push commit build when not a release + if: github.event_name != 'release' + run: | + docker build \ + --build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \ + -f ./images/pglater-pg/Dockerfile \ + --platform linux/arm64 \ + -t ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-arm64 . + docker push ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-arm64 + + - name: Build and push -- Release + if: github.event_name == 'release' + run: | + docker build \ + --build-arg PGRX_VER=${{ steps.versions.outputs.PGRX_VER }} \ + -f ./images/pglater-pg/Dockerfile \ + --platform linux/arm64 \ + -t ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-arm64 \ + -t ghcr.io/chuckhend/pglater-pg:latest-arm64 . + docker push ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-arm64 + docker push ghcr.io/chuckhend/pglater-pg:latest-arm64 + + create_manifest: + name: Create and Push Manifest + runs-on: ubuntu-latest + needs: [build_and_push_arm64, build_and_push_amd64] + outputs: + short_sha: ${{ steps.versions.outputs.SHORT_SHA }} + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Install stoml + shell: bash + run: | + set -xe + sudo apt-get update + sudo apt-get install -y wget + wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 &> /dev/null + mv stoml_linux_amd64 stoml + chmod +x stoml + sudo mv stoml /usr/local/bin/ + - name: Set version strings + id: versions + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "TAG_VER=$(/usr/local/bin/stoml Cargo.toml package.version)" >> $GITHUB_OUTPUT + + - name: Create and push Docker manifest -- Commit + if: github.event_name != 'release' + run: | + docker manifest create ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }} \ + ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-arm64 \ + ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64 + + docker manifest annotate ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }} ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-arm64 --arch arm64 --os linux + docker manifest annotate ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }} ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }}-amd64 --arch amd64 --os linux + docker manifest push ghcr.io/chuckhend/pglater-pg:${{ steps.versions.outputs.SHORT_SHA }} + + - name: Create and push Docker manifest -- Release + if: github.event_name == 'release' + run: | + docker manifest create ghcr.io/chuckhend/pglater-pg:latest \ + ghcr.io/chuckhend/pglater-pg:latest-arm64 \ + ghcr.io/chuckhend/pglater-pg:latest-amd64 + + docker manifest annotate ghcr.io/chuckhend/pglater-pg:latest ghcr.io/chuckhend/pglater-pg:latest-arm64 --arch arm64 --os linux + docker manifest annotate ghcr.io/chuckhend/pglater-pg:latest ghcr.io/chuckhend/pglater-pg:latest-amd64 --arch amd64 --os linux + docker manifest push ghcr.io/chuckhend/pglater-pg:latest + + docker manifest create ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} \ + ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-arm64 \ + ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-amd64 + + docker manifest annotate ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-arm64 --arch arm64 --os linux + docker manifest annotate ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }}-amd64 --arch amd64 --os linux + docker manifest push ghcr.io/chuckhend/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} diff --git a/.github/workflows/pg_later_ext.yml b/.github/workflows/pg_later_ext.yml index 4c01b5b..a952cad 100644 --- a/.github/workflows/pg_later_ext.yml +++ b/.github/workflows/pg_later_ext.yml @@ -22,48 +22,13 @@ on: - created jobs: - dependencies: - name: Install dependencies - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v2 - - # rust needed to install trunk - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - cache-directories: /home/runner/.pgrx - - - name: Install stoml and pg-trunk - shell: bash - run: | - set -xe - wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 &> /dev/null - mv stoml_linux_amd64 stoml - chmod +x stoml - sudo mv stoml /usr/local/bin/ - cargo install pg-trunk - - name: Cache binaries - uses: actions/cache@v2 - with: - path: | - /usr/local/bin/stoml - ~/.cargo/bin/trunk - key: ${{ runner.os }}-bins-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-bins- lint: name: Run linters - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - name: Install Rust minimal nightly with clippy and rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: rustfmt, clippy + uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: prefix-key: "pg_later-extension-lint" @@ -82,14 +47,11 @@ jobs: test: name: Run tests - needs: dependencies - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: prefix-key: "pg_later-extension-test" @@ -101,15 +63,6 @@ jobs: - uses: ./.github/actions/pgx-init with: working-directory: ./ - - name: Restore cached binaries - uses: actions/cache@v2 - with: - path: | - /usr/local/bin/stoml - ~/.cargo/bin/trunk - key: ${{ runner.os }}-bins-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-bins- - name: test run: | make setup @@ -120,92 +73,9 @@ jobs: run: | set +e set -x - echo "==== pg17 logs ======" - cat ~/.pgrx/17.log - echo "==== pg17 conf ======" - tail -10 ~/.pgrx/data-17/postgresql.conf + echo "==== pg18 logs ======" + cat ~/.pgrx/18.log + echo "==== pg18 conf ======" + tail -10 ~/.pgrx/data-18/postgresql.conf echo "==== .pgrx dir ======" ls -alh ~/.pgrx - - publish: - if: github.event_name == 'release' - name: trunk publish - needs: dependencies - runs-on: ubuntu-22.04 - strategy: - matrix: - pg-version: [14, 15, 16, 17] - steps: - - uses: actions/checkout@v2 - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "pg_later-extension-test" - workspaces: | - pg_later/extension - # Additional directories to cache - cache-directories: | - /home/runner/.pgrx - - name: Restore cached binaries - uses: actions/cache@v2 - with: - path: | - /usr/local/bin/stoml - ~/.cargo/bin/trunk - key: ${{ runner.os }}-bins-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-bins- - - name: trunk build - working-directory: ./ - run: | - cargo install pg-trunk --force - ~/.cargo/bin/trunk --version - ~/.cargo/bin/trunk build --pg-version ${{ matrix.pg-version }} - - name: trunk publish - working-directory: ./ - env: - TRUNK_API_TOKEN: ${{ secrets.TRUNK_AUTH_TOKEN }} - run: ~/.cargo/bin/trunk publish - build_and_push: - if: github.event_name == 'release' - name: Build and push images - needs: - - dependencies - runs-on: ubuntu-22.04 - outputs: - short_sha: ${{ steps.versions.outputs.SHORT_SHA }} - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - name: Install stoml and pg-trunk - shell: bash - run: | - set -xe - wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 &> /dev/null - mv stoml_linux_amd64 stoml - chmod +x stoml - sudo mv stoml /usr/local/bin/ - - name: Set version strings - id: versions - run: | - echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - echo "TAG_VER=$(/usr/local/bin/stoml Trunk.toml extension.version)" >> $GITHUB_OUTPUT - echo "PGRX_VER=$(/usr/local/bin/stoml Cargo.toml dependencies.pgrx)" >> $GITHUB_OUTPUT - - name: Build and upload image - run: | - docker build --build-arg="PGRX_VER=${{ steps.versions.outputs.PGRX_VER }}" -t pglater-pg -f images/pglater-pg/Dockerfile . - docker tag pglater-pg quay.io/tembo/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} - docker tag pglater-pg quay.io/tembo/pglater-pg:latest - - name: Login to Quay - uses: docker/login-action@v2 - with: - registry: quay.io/tembo - username: ${{ secrets.QUAY_USER_TEMBO }} - password: ${{ secrets.QUAY_PASSWORD_TEMBO }} - - name: Push image - run: | - docker push quay.io/tembo/pglater-pg:v${{ steps.versions.outputs.TAG_VER }} - docker push quay.io/tembo/pglater-pg:latest diff --git a/.github/workflows/pgxn-release.yml b/.github/workflows/pgxn-release.yml index d6e59bb..3b2c7d6 100644 --- a/.github/workflows/pgxn-release.yml +++ b/.github/workflows/pgxn-release.yml @@ -10,7 +10,7 @@ jobs: container: pgxn/pgxn-tools steps: - name: Check out the repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Bundle the Release env: { GIT_BUNDLE_OPTS: --add-file META.json } run: make META.json && pgxn-bundle From 4491fec1765b41e678fadf49863116c3f617fcb1 Mon Sep 17 00:00:00 2001 From: Adam Hendel Date: Wed, 12 Nov 2025 18:29:20 -0600 Subject: [PATCH 2/2] unused action --- .../find-changed-directories/action.yml | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 .github/actions/find-changed-directories/action.yml diff --git a/.github/actions/find-changed-directories/action.yml b/.github/actions/find-changed-directories/action.yml deleted file mode 100644 index 49b5452..0000000 --- a/.github/actions/find-changed-directories/action.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: 'Find changed directories' -description: 'Finds directories containing a specific filename in the root of that directory, filtering out directories that are unchanged relative to a given branch name' -inputs: - contains_the_file: - description: 'Look for directories with this file in the root of that directory. For example, Dockerfile or Cargo.toml' - required: true - fetch_branch_to_compare: - description: 'The branch to fetch when looking to compare a ref, typically main' - default: "main" - required: true - changed_relative_to_ref: - description: 'The ref on the fetched branch to compare with to determine if this directory has changed. For example "origin/main" or a git commit hash.' - required: true - ignore_dirs: - description: A list of directories to ignore. - required: false - default: '' -outputs: - build_matrix: - description: "Input this output to your matrix build in a following job, like this 'fromJson(needs.find_directories.outputs.build_matrix)'" - value: ${{ steps.find_directories.outputs.build_matrix }} -runs: - using: "composite" - steps: - - name: Find directories with a given file name - shell: bash - id: find_directories - run: | - set -xe - git fetch origin ${{ inputs.fetch_branch_to_compare }} || true - # Get directories with a Dockerfile that have not changed - # relative to the branch we are pulling into - echo "${{inputs.ignore_dirs}}" - IFS=', ' read -r -a array <<< "${{inputs.ignore_dirs}}" - EXCLUDE_OPTS=() - for exclude_dir in "${array[@]}"; do - EXCLUDE_OPTS+=("-not" "-path" "*/$exclude_dir/*") - done - directories=$( - find . -name ${{ inputs.contains_the_file }} -not -path "*/target/*" -not -path "*/.github/*" "${EXCLUDE_OPTS[@]}" -exec dirname {} \; | while read dir; do - # This will check if the directory has changed relative to the branch we are PRing - # into, and if it's not a PR, in the case of main or release/**, then it will - # build all docker directories - if git diff --quiet HEAD ${{ inputs.changed_relative_to_ref }} -- "$dir"; then - echo "" - else - echo "$dir" - fi - done) - # Format directories into a build matrix - matrix_include=$(echo "${directories}" | awk 'NF{print $NF};' | while read dir; do dir_without_dot=$(basename ${dir}); echo "{\"path\": \"$dir\", \"name\": \"$dir_without_dot\"}"; done | jq -scM '{"include": .}') - echo "${matrix_include}" - echo "build_matrix=${matrix_include}" >> $GITHUB_OUTPUT