14
14
# description: Base image variant
15
15
# required: true
16
16
# default: slim
17
- push :
17
+ workflow_dispatch :
18
18
pull_request :
19
19
branches :
20
20
- develop
21
21
jobs :
22
- build-image :
23
- runs-on : ubuntu-latest
24
- env :
25
- latest-ref : refs/heads/develop
26
- defaultRepo : kartoza
27
- strategy :
28
- matrix :
29
- postgresMajorVersion :
30
- - 13
31
- postgisMajorVersion :
32
- - 3
33
- postgisMinorRelease :
34
- - 1
35
- include :
36
- - distro : debian
37
- imageVersion : bullseye
38
- imageVariant : slim
39
- steps :
40
- - uses : actions/checkout@v2
41
- - name : Set up QEMU
42
- uses : docker/setup-qemu-action@v1
43
- - name : Set up Docker Buildx
44
- uses : docker/setup-buildx-action@v1
45
- - name : Get build cache
46
- uses : actions/cache@v2
47
- with :
48
- path : /tmp/.buildx-cache
49
- # Build inputs are:
50
- # - Dockerfile recipe
51
- # - docker-compose.build.yml
52
- # - build args (.example.env)
53
- # - base_build directory
54
- # - scripts directory
55
- key : buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts', 'scenario_tests/utils/requirements.txt') }}-${{ github.sha }}
56
- restore-keys : |
57
- buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts', 'scenario_tests/utils/requirements.txt') }}-
58
-
59
- - name : Build all stages
60
- id : docker_build_base
61
- uses : docker/build-push-action@v2
62
- with :
63
- context : .
64
- file : Dockerfile
65
- push : false
66
- load : true
67
- tags : ${{ secrets.DOCKERHUB_REPO || env.defaultRepo }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
68
- build-args : |
69
- DISTRO=${{ matrix.distro }}
70
- IMAGE_VERSION=${{ matrix.imageVersion }}
71
- IMAGE_VARIANT=${{ matrix.imageVariant }}
72
- LANGS=en_US.UTF-8,id_ID.UTF-8
73
- GENERATE_ALL_LOCALE=0
74
- POSTGRES_MAJOR_VERSION=${{ matrix.postgresMajorVersion }}
75
- POSTGIS_MAJOR_VERSION=${{ matrix.postgisMajorVersion }}
76
- POSTGIS_MINOR_VERSION=${{ matrix.postgresMinorVersion }}
77
- cache-from : type=local,src=/tmp/.buildx-cache
78
- cache-to : type=local,mode=max,dest=/tmp/.buildx-cache
79
-
80
22
run-scenario-tests :
81
23
runs-on : ubuntu-latest
82
- needs : [ build-image ]
83
24
strategy :
84
25
matrix :
85
26
postgresMajorVersion :
@@ -104,20 +45,6 @@ jobs:
104
45
uses : docker/setup-qemu-action@v1
105
46
- name : Set up Docker Buildx
106
47
uses : docker/setup-buildx-action@v1
107
- - name : Get build cache
108
- uses : actions/cache@v2
109
- with :
110
- path : /tmp/.buildx-cache
111
- # Build inputs are:
112
- # - Dockerfile recipe
113
- # - docker-compose.build.yml
114
- # - build args (.example.env)
115
- # - base_build directory
116
- # - scripts directory
117
- key : buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts', 'scenario_tests/utils/requirements.txt') }}-${{ github.sha }}
118
- restore-keys : |
119
- buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts', 'scenario_tests/utils/requirements.txt') }}-
120
-
121
48
- name : Build image for testing
122
49
id : docker_build_testing_image
123
50
uses : docker/build-push-action@v2
@@ -136,22 +63,25 @@ jobs:
136
63
POSTGRES_MAJOR_VERSION=${{ matrix.postgresMajorVersion }}
137
64
POSTGIS_MAJOR_VERSION=${{ matrix.postgisMajorVersion }}
138
65
POSTGIS_MINOR_VERSION=${{ matrix.postgresMinorVersion }}
139
- cache-from : type=local,src=/tmp/.buildx-cache
66
+ cache-from : |
67
+ type=gha,scope=test
68
+ type=gha,scope=prod
69
+ type=gha,scope=base
70
+ cache-to : type=gha,scope=test
140
71
target : postgis-test
141
72
142
- - name : Run scenario test
73
+ - name : Run scenario test ${{ matrix.scenario }}
74
+ working-directory : scenario_tests/${{ matrix.scenario }}
143
75
env :
144
76
COMPOSE_INTERACTIVE_NO_CLI : 1
145
77
PRINT_TEST_LOGS : 1
146
78
run : |
147
- pushd scenario_tests/${{ matrix.scenario }}
148
- ./test.sh
149
- popd
79
+ bash ./test.sh
150
80
151
81
push-internal-pr-images :
152
82
if : github.event_name == 'pull_request' && github.event.pull_request.base.repo.url == github.event.pull_request.head.repo.url
153
83
runs-on : ubuntu-latest
154
- needs : [ build-image ]
84
+ needs : [ run-scenario-tests ]
155
85
strategy :
156
86
matrix :
157
87
postgresMajorVersion :
@@ -165,37 +95,25 @@ jobs:
165
95
imageVersion : bullseye
166
96
imageVariant : slim
167
97
steps :
98
+ - uses : actions/checkout@v2
99
+ - name : Set up QEMU
100
+ uses : docker/setup-qemu-action@v1
101
+ - name : Set up Docker Buildx
102
+ uses : docker/setup-buildx-action@v1
168
103
- name : Login to DockerHub
169
104
uses : docker/login-action@v1
170
105
with :
171
106
username : ${{ secrets.DOCKERHUB_USERNAME }}
172
107
password : ${{ secrets.DOCKERHUB_PASSWORD }}
173
-
174
108
- name : Docker meta
175
109
id : docker_meta
176
- uses : crazy-max/ghaction-docker-meta@v1
110
+ uses : docker/metadata-action@v3
177
111
with :
178
112
images : ${{ secrets.DOCKERHUB_REPO}}/postgis
179
- tag-latest : false
180
-
181
- - uses : actions/checkout@v2
182
- - name : Set up QEMU
183
- uses : docker/setup-qemu-action@v1
184
- - name : Set up Docker Buildx
185
- uses : docker/setup-buildx-action@v1
186
- - name : Get build cache
187
- uses : actions/cache@v2
188
- with :
189
- path : /tmp/.buildx-cache
190
- # Build inputs are:
191
- # - Dockerfile recipe
192
- # - docker-compose.build.yml
193
- # - build args (.example.env)
194
- # - base_build directory
195
- # - scripts directory
196
- key : buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts') }}-${{ github.sha }}
197
- restore-keys : |
198
- buildx-${{ hashFiles('Dockerfile', 'docker-compose.build.yml', '.example.env', 'base_build', 'scripts') }}-
113
+ tags : |
114
+ type=semver,pattern=\d-\d.\d
115
+ type=ref,event=branch
116
+ type=ref,event=pr
199
117
200
118
- name : Build image for testing
201
119
id : docker_build_testing_image
@@ -204,7 +122,8 @@ jobs:
204
122
context : .
205
123
file : Dockerfile
206
124
push : true
207
- tags : ${{ steps.docker_meta.outputs.tags }}-${{ matrix.postgresMajorVersion }}-${{ matrix.postgisMajorVersion }}.${{ matrix.postgisMinorRelease }}
125
+ tags : |
126
+ ${{ steps.docker_meta.outputs.tags }}-${{ matrix.postgresMajorVersion }}-${{ matrix.postgisMajorVersion }}.${{ matrix.postgisMinorRelease }}
208
127
build-args : |
209
128
DISTRO=${{ matrix.distro }}
210
129
IMAGE_VERSION=${{ matrix.imageVersion }}
@@ -214,5 +133,9 @@ jobs:
214
133
POSTGRES_MAJOR_VERSION=${{ matrix.postgresMajorVersion }}
215
134
POSTGIS_MAJOR_VERSION=${{ matrix.postgisMajorVersion }}
216
135
POSTGIS_MINOR_VERSION=${{ matrix.postgresMinorVersion }}
217
- cache-from : type=local,src=/tmp/.buildx-cache
136
+ cache-from : |
137
+ type=gha,scope=test
138
+ type=gha,scope=prod
139
+ type=gha,scope=base
140
+ cache-to : type=gha,scope=test
218
141
target : postgis-test
0 commit comments