Skip to content

wip: fix rebase conflicts #27

wip: fix rebase conflicts

wip: fix rebase conflicts #27

name: build-test-vm
on:
workflow_dispatch: # adds ability to run this manually
inputs:
tag:
description: 'Tag to use for the Docker images'
type: string
required: true
workflow_call:
inputs:
skip:
description: 'Changes this action to perform a no-op'
type: boolean
required: false
tag:
description: 'Tag to use for the Docker images'
type: string
required: true
upload-vm-builder:
description: 'If true, upload vm-builder in an artifact'
type: boolean
required: false
default: false
arch:
description: 'Architecture to build for'
type: string
required: false
default: 'amd64'
matrix-step-name:
required: false
type: string
matrix-key:
required: false
type: string
outputs:
vm-postgres-16-bullseye:
description: 'image name for postgres:16-bullseye, VM-ified'
value: ${{ jobs.build.outputs.vm-postgres-16-bullseye }}
env:
IMG_POSTGRES_16_BULLSEYE: "neondatabase/vm-postgres-16-bullseye"
# using image built in the same workflow
IMG_DAEMON: "neondatabase/neonvm-daemon"
TARGET_ARCH: "amd64"
defaults:
run:
shell: bash -euo pipefail {0}
jobs:
build:
# nb: use format(..) to catch both inputs.skip = true AND inputs.skip = 'true'.
if: ${{ format('{0}', inputs.skip) != 'true' }}
runs-on: [ self-hosted, gen3, large ]
outputs:
vm-postgres-16-bullseye: ${{ steps.tags.outputs.vm-postgres-16-bullseye }}
daemon: ${{ steps.tags.outputs.daemon }}
steps:
# tags converted to be a step and moved here to be in the same strategy contextt
- id: tags
run: |
echo "vm-postgres-16-bullseye=${{ env.IMG_POSTGRES_16_BULLSEYE }}-${{inputs.arch}}:${{ inputs.tag }}" | tee -a $GITHUB_OUTPUT
echo "daemon=${{ env.IMG_DAEMON }}-${{inputs.arch}}:${{ inputs.tag }}" | tee -a $GITHUB_OUTPUT
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# Disable cache on self-hosted runners to avoid /usr/bin/tar errors, see https://github.com/actions/setup-go/issues/403
cache: false
# Sometimes setup-go gets stuck. Without this, it'll keep going until the job gets killed
timeout-minutes: 10
- name: Build daemon image
- run: make docker-build-daemon
# - name: Build daemon image
# uses: docker/build-push-action@v6
# env:
# GO_BASE_IMG: ${{ format('localhost:5000/neondatabase/autoscaling-go-base-{0}:dev', inputs.arch) }}
# with:
# context: .
# push: false
# platforms: linux/${{ inputs.arch }}
# file: neonvm-daemon/Dockerfile
# cache-from: type=registry,ref=cache.neon.build/neonvm-daemon:cache
# cache-to: ${{ github.ref_name == 'main' && 'type=registry,ref=cache.neon.build/neonvm-daemon:cache,mode=max' || '' }}
# tags: ${{ steps.tags.outputs.daemon }}
# build-args: |
# GO_BASE_IMG=${{ env.GO_BASE_IMG }}
- run: make bin/vm-builder
env:
IMG_DAEMON: ${{ steps.tags.outputs.daemon }}
- name: upload vm-builder
if: ${{ format('{0}', inputs.upload-vm-builder) == 'true' }}
uses: actions/upload-artifact@v4
with:
name: vm-builder
path: ${{format('bin/vm-builder-{0}', inputs.arch)}}
if-no-files-found: error
retention-days: 2
- name: set custom docker config directory
uses: neondatabase/dev-actions/set-docker-config-dir@6094485bf440001c94a94a3f9e221e81ff6b6193
- name: login to docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.NEON_DOCKERHUB_USERNAME }}
password: ${{ secrets.NEON_DOCKERHUB_PASSWORD }}
- name: build ${{ steps.tags.outputs.vm-postgres-16-bullseye }}
run: |
./bin/vm-builder -src postgres:16-bullseye -spec tests/e2e/image-spec.yaml -dst ${{ steps.tags.outputs.vm-postgres-16-bullseye }} -daemon-image ${{ steps.tags.outputs.daemon }} -target-arch linux/${{ inputs.arch }}
- name: docker push ${{ steps.tags.outputs.vm-postgres-16-bullseye }}
run: |
docker push ${{ steps.tags.outputs.vm-postgres-16-bullseye }}
save-matrix-results:
runs-on: ubuntu-latest
needs: [build]
steps:
## Write for matrix outputs workaround
- uses: cloudposse/github-action-matrix-outputs-write@v1
id: out
with:
matrix-step-name: ${{ inputs.matrix-step-name }}
matrix-key: ${{ inputs.matrix-key }}
outputs: |-
vm-postgres-16-bullseye: ${{ needs.build.outputs.vm-postgres-16-bullseye }}
daemon: ${{ needs.build.outputs.daemon }}
outputs:
vm-postgres-16-bullseye: ${{ steps.out.outputs.vm-postgres-16-bullseye }}
daemon: ${{ steps.out.outputs.daemon }}