This repository was archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
180 lines (167 loc) · 7.72 KB
/
docker.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: docker
on:
pull_request:
paths-ignore:
push:
branches:
- develop
- master
tags:
- "*"
jobs:
docker:
runs-on: ubuntu-latest
outputs:
branch_name: ${{steps.metadata.outputs.branch_name}}
image_branch_name: ${{steps.metadata.outputs.image_branch_name}}
strategy:
fail-fast: false
matrix:
pgversion:
- 15
- 14
- 13
- 12
tsversion:
- 2.9.1
base:
- ha
- alpine
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Gather metadata
id: metadata
run: |
tsmajor=$(echo ${{ matrix.tsversion }} | cut -d. -f1)
tsmajmin=$(echo ${{ matrix.tsversion }} | cut -d. -f1,2)
branch_name=$(echo ${{github.head_ref || github.ref_name}})
image_branch_name=$(echo ${branch_name} | sed 's#/#-#')
build_type_suffix=$(echo "-${{matrix.base}}" | sed 's/-ha//')
echo "tsmajor=${tsmajor}" >> ${GITHUB_OUTPUT}
echo "tsmajmin=${tsmajmin}" >> ${GITHUB_OUTPUT}
echo "branch_name=${branch_name}" >> ${GITHUB_OUTPUT}
echo "image_branch_name=${image_branch_name}" >> ${GITHUB_OUTPUT}
echo "build_type_suffix=${build_type_suffix}" >> ${GITHUB_OUTPUT}
- name: Build and push
uses: docker/build-push-action@v3
env:
DOCKER_PUSH_REQUIRED: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == 'timescale' }} # Don't run docker push when this is a PR from a fork
with:
build-args: |
PG_VERSION=${{ matrix.pgversion }}
TIMESCALEDB_VERSION_FULL=${{ matrix.tsversion }}
TIMESCALEDB_VERSION_MAJOR=${{ steps.metadata.outputs.tsmajor }}
TIMESCALEDB_VERSION_MAJMIN=${{ steps.metadata.outputs.tsmajmin }}
secrets: |
"AWS_ACCESS_KEY_ID=${{ secrets.PROMSCALE_EXTENSION_SCCACHE_AWS_ACCESS_KEY_ID }}"
"AWS_SECRET_ACCESS_KEY=${{ secrets.PROMSCALE_EXTENSION_SCCACHE_AWS_SECRET_ACCESS_KEY }}"
context: .
file: ${{matrix.base}}.Dockerfile
push: ${{ env.DOCKER_PUSH_REQUIRED == 'true' }}
load: ${{ env.DOCKER_PUSH_REQUIRED != 'true' }}
tags: |
ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{steps.metadata.outputs.tsmajor}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{steps.metadata.outputs.tsmajmin}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
labels: |
org.opencontainers.image.source=
org.opencontainers.image.revision=
org.opencontainers.image.created=
# Note: it's necessary to use a different cache scope to achieve caching for both Ubuntu and Alpine images
cache-from: type=gha,scope=${{matrix.base}}-${{matrix.pgversion}}-${{matrix.tsversion}}
cache-to: type=gha,mode=max,scope=${{matrix.base}}-${{matrix.pgversion}}-${{matrix.tsversion}}
- name: Run SQL tests
run: cargo test -p sql-tests
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
USE_DOCKER: true
- name: Run end-to-end tests
run: cargo test -p e2e
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
RUST_LOG: info
- name: Check SQL Documentation
if: ${{ matrix.pgversion == 14 && matrix.base == 'ha' }}
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
USE_DOCKER: true
run: |
make gendoc
git diff --exit-code
- name: Login to Dockerhub
uses: docker/login-action@v2
# A dash indicates prerelease in SemVer
if: ${{ startsWith(github.ref, 'refs/tags') && !contains(github.ref, '-') && matrix.base == 'alpine' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish alpine images to Docker Hub
uses: akhilerm/[email protected]
# A dash indicates prerelease in SemVer
if: ${{ startsWith(github.ref, 'refs/tags') && !contains(github.ref, '-') && matrix.base == 'alpine' }}
with:
src: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
dst: |
timescaledev/promscale-extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}
timescaledev/promscale-extension:latest-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}
timescaledev/promscale-extension:latest-ts${{steps.metadata.outputs.tsmajor}}-pg${{matrix.pgversion}}
pick-connector-branch:
name: picking connector's repo branch
runs-on: ubuntu-latest
needs:
- docker
outputs:
branch: ${{ steps.curl.outputs.branch }}
steps:
- name: curl check matching branch
id: curl
run: |
branch_name=${{ needs.docker.outputs.branch_name }}
res=$(curl \
-sw'%{http_code}\n' \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/timescale/promscale/branches/${branch_name} | tail -1)
if [[ "$res" = "200" ]]; then
echo "branch=${branch_name}" >> ${GITHUB_OUTPUT}
elif [[ "$res" == "404" ]]; then
echo "branch=master" >> ${GITHUB_OUTPUT}
else
echo "Unexpected HTTP response: $res"
exit 1
fi;
call-connector-e2e:
name: call connector e2e test
needs:
- docker
- pick-connector-branch
if: needs.docker.result == 'success'
uses: timescale/promscale/.github/workflows/go-e2e.yml@master
with:
# If there is a branch with the same name in the connector repo we use that one
# to run e2e tests. Otherwise we run them on master.
docker_image_prefix: ${{ needs.docker.outputs.image_branch_name }}-ts2
ref: ${{ needs.pick-connector-branch.outputs.branch }}
# This allows us to set a single job which must pass in GitHub's branch protection rules,
# otherwise we have to keep updating them as we add or remove postgres versions etc.
docker-result:
name: docker result
if: always()
needs:
- docker
- call-connector-e2e
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
if: needs.docker.result == 'success' && needs.call-connector-e2e.result == 'success'
run: exit 0
- name: Mark the job as a failure
if: needs.docker.result != 'success' || needs.call-connector-e2e.result != 'success'
run: exit 1