-
Notifications
You must be signed in to change notification settings - Fork 21
94 lines (85 loc) · 3.25 KB
/
build-test-vm.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
outputs:
vm-postgres-16-bullseye:
description: 'image name for postgres:16-bullseye, VM-ified'
value: ${{ jobs.tags.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:
tags:
outputs:
vm-postgres-16-bullseye: ${{ steps.show-tags.outputs.vm-postgres-16-bullseye }}
daemon: ${{ steps.show-tags.outputs.daemon }}
runs-on: ubuntu-latest
steps:
- id: show-tags
run: |
echo "vm-postgres-16-bullseye=${{ env.IMG_POSTGRES_16_BULLSEYE }}:${{ inputs.tag }}" | tee -a $GITHUB_OUTPUT
echo "daemon=${{ env.IMG_DAEMON }}:${{ inputs.tag }}" | tee -a $GITHUB_OUTPUT
build:
# nb: use format(..) to catch both inputs.skip = true AND inputs.skip = 'true'.
if: ${{ format('{0}', inputs.skip) != 'true' }}
needs: tags
runs-on: [ self-hosted, gen3, large ]
env:
IMG_DAEMON: ${{ needs.tags.outputs.daemon }}
steps:
- 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
- run: make docker-build-daemon
- run: make bin/vm-builder
- name: upload vm-builder
if: ${{ format('{0}', inputs.upload-vm-builder) == 'true' }}
uses: actions/upload-artifact@v4
with:
name: vm-builder
path: bin/vm-builder
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 ${{ needs.tags.outputs.vm-postgres-16-bullseye }}
run: |
./bin/vm-builder -src postgres:16-bullseye -spec tests/e2e/image-spec.yaml -dst ${{ needs.tags.outputs.vm-postgres-16-bullseye }} -daemon-image ${{ needs.tags.outputs.daemon }} -target-arch linux/${TARGET_ARCH}
- name: docker push ${{ needs.tags.outputs.vm-postgres-16-bullseye }}
run: |
docker push ${{ needs.tags.outputs.vm-postgres-16-bullseye }}