Skip to content

Commit d362210

Browse files
author
Bernhard B
committed
Merge branch 'develop'
2 parents 9826541 + 32a3a1e commit d362210

File tree

4 files changed

+90
-42
lines changed

4 files changed

+90
-42
lines changed

env/docker/Dockerfile.buildbase2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ FROM bbernhard/imagemonkey-buildbase:latest
22

33
RUN echo "deb http://deb.debian.org/debian stretch main" >> /etc/apt/sources.list
44

5+
RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
6+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
7+
58
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
postgresql-client-9.6 \
9+
postgresql-client-13 \
710
# until this pull request (https://github.com/h2non/bimg/pull/266) is merged and https://github.com/h2non/bimg/issues/269 is resolved, use the fork
811
&& curl -s https://raw.githubusercontent.com/bbernhard/bimg/master/preinstall.sh | bash - \
912
&& rm -rf /var/lib/apt/lists/*

env/docker/Dockerfile.postgres

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
FROM postgres:9.6.18
2-
3-
ARG TEMPORAL_TABLE_VERSION=1.2.0
4-
ARG POSTGIS_VERSION=2.5
5-
ENV MONKEY_DB_PASSWORD=
6-
7-
RUN apt-get update && apt-get install -y --no-install-recommends \
8-
ca-certificates build-essential postgresql-9.6-postgis-${POSTGIS_VERSION} postgresql-9.6-postgis-${POSTGIS_VERSION}-scripts postgresql-contrib-9.6 postgresql-server-dev-9.6 curl
9-
10-
RUN cd /tmp && curl -o /tmp/v${TEMPORAL_TABLE_VERSION}.tar.gz -L https://github.com/arkhipov/temporal_tables/archive/v${TEMPORAL_TABLE_VERSION}.tar.gz \
11-
&& mkdir -p /tmp/temporal_table \
12-
&& mv /tmp/v${TEMPORAL_TABLE_VERSION}.tar.gz /tmp/temporal_table/v${TEMPORAL_TABLE_VERSION}.tar.gz \
13-
&& cd /tmp/temporal_table && tar xvf v${TEMPORAL_TABLE_VERSION}.tar.gz \
14-
&& cd /tmp/temporal_table/temporal_tables-${TEMPORAL_TABLE_VERSION} \
15-
&& make \
16-
&& make install \
17-
&& rm -rf /tmp_temporal_table
18-
19-
RUN mkdir -p /docker-entrypoint-initdb.d/
20-
COPY env/docker/postgres_init.sh /docker-entrypoint-initdb.d/postgres_init.sh
21-
COPY env/postgres/schema.sql /tmp/imagemonkeydb/schema.sql
22-
COPY env/postgres/defaults.sql /tmp/imagemonkeydb/defaults.sql
23-
COPY env/postgres/indexes.sql /tmp/imagemonkeydb/indexes.sql
24-
COPY env/postgres/stored_procs /tmp/imagemonkeydb/postgres_stored_procs
25-
COPY env/postgres/functions /tmp/imagemonkeydb/postgres_functions
26-
27-
RUN chown -R postgres:postgres /tmp/imagemonkeydb \
28-
&& chmod -R u+rx /tmp/imagemonkeydb
1+
FROM postgres:13
2+
3+
ARG TEMPORAL_TABLE_VERSION=1.2.0
4+
ARG POSTGIS_VERSION=2.5
5+
ENV MONKEY_DB_PASSWORD=
6+
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
ca-certificates build-essential postgresql-13-postgis-${POSTGIS_VERSION} postgresql-13-postgis-${POSTGIS_VERSION}-scripts postgresql-contrib-13 postgresql-server-dev-13 git
9+
10+
#RUN cd /tmp && curl -o /tmp/v${TEMPORAL_TABLE_VERSION}.tar.gz -L https://github.com/arkhipov/temporal_tables/archive/v${TEMPORAL_TABLE_VERSION}.tar.gz \
11+
# && mkdir -p /tmp/temporal_table \
12+
# && mv /tmp/v${TEMPORAL_TABLE_VERSION}.tar.gz /tmp/temporal_table/v${TEMPORAL_TABLE_VERSION}.tar.gz \
13+
# && cd /tmp/temporal_table && tar xvf v${TEMPORAL_TABLE_VERSION}.tar.gz \
14+
# && cd /tmp/temporal_table/temporal_tables-${TEMPORAL_TABLE_VERSION} \
15+
# && make \
16+
# && make install \
17+
# && rm -rf /tmp_temporal_table
18+
19+
RUN cd /tmp && git clone https://github.com/bbernhard/temporal_tables.git \
20+
&& cd /tmp/temporal_tables \
21+
&& git checkout pg13 \
22+
&& make \
23+
&& make install \
24+
&& rm -rf /tmp/temporal_tables
25+
26+
27+
RUN mkdir -p /docker-entrypoint-initdb.d/
28+
COPY env/docker/postgres_init.sh /docker-entrypoint-initdb.d/postgres_init.sh
29+
COPY env/postgres/schema.sql /tmp/imagemonkeydb/schema.sql
30+
COPY env/postgres/defaults.sql /tmp/imagemonkeydb/defaults.sql
31+
COPY env/postgres/indexes.sql /tmp/imagemonkeydb/indexes.sql
32+
COPY env/postgres/stored_procs /tmp/imagemonkeydb/postgres_stored_procs
33+
COPY env/postgres/functions /tmp/imagemonkeydb/postgres_functions
34+
35+
RUN chown -R postgres:postgres /tmp/imagemonkeydb \
36+
&& chmod -R u+rx /tmp/imagemonkeydb

env/docker/Dockerfile.testing

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ COPY env/postgres /tmp/env/postgres
3838
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION}-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
3939
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
4040
&& apt-get update \
41-
&& apt-get install -y --no-install-recommends python3 postgresql-client-9.6 python3-pip wget unzip \
41+
&& apt-get install -y --no-install-recommends python3 postgresql-client-13 python3-pip wget unzip \
4242
&& pip3 install selenium requests \
4343
&& wget https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip --directory-prefix=/tmp/ \
4444
&& cd /tmp \

src/commons/ci_impl.go

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"gopkg.in/resty.v1"
88
"strconv"
9+
"time"
910
)
1011

1112
type GithubActionsApi struct {
@@ -23,6 +24,8 @@ type WorkflowRun struct {
2324
HtmlUrl string `json:"html_url"`
2425
Status string `json:"status"`
2526
Conclusion string `json:"conclusion"`
27+
HeadBranch string `json:"head_branch"`
28+
Event string `json:"event"`
2629
}
2730

2831
type WorkflowsResult struct {
@@ -46,13 +49,11 @@ func (p *GithubActionsApi) SetToken(token string) {
4649
p.token = token
4750
}
4851

49-
func (p *GithubActionsApi) GetBuildInfo(branchName string) (CiBuildInfo, error) {
50-
var githubActionsBuildInfo CiBuildInfo
52+
func (p *GithubActionsApi) getBuilds(branchName string) (WorkflowRunsResult, error) {
53+
var res WorkflowRunsResult
5154

5255
url := "https://api.github.com/repos/" + p.repoOwner + "/" + p.repo + "/actions/runs"
5356

54-
var res WorkflowRunsResult
55-
5657
resp, err := resty.R().
5758
SetHeader("Content-Type", "application/json").
5859
SetHeader("Accept", "application/json").
@@ -63,21 +64,31 @@ func (p *GithubActionsApi) GetBuildInfo(branchName string) (CiBuildInfo, error)
6364
SetResult(&res).
6465
Get(url)
6566
if err != nil {
66-
return githubActionsBuildInfo, err
67+
return res, err
6768
}
6869

6970
if !((resp.StatusCode() >= 200) && (resp.StatusCode() <= 209)) {
70-
return githubActionsBuildInfo, errors.New(resp.String())
71+
return res, errors.New(resp.String())
7172
}
73+
return res,nil
74+
}
7275

73-
if res.TotalCount == 0 {
76+
func (p *GithubActionsApi) GetBuildInfo(branchName string) (CiBuildInfo, error) {
77+
var githubActionsBuildInfo CiBuildInfo
78+
79+
builds, err := p.getBuilds(branchName)
80+
if err != nil {
81+
return githubActionsBuildInfo, err
82+
}
83+
84+
if builds.TotalCount == 0 {
7485
return githubActionsBuildInfo, errors.New("No workflow run found")
7586
}
7687

77-
githubActionsBuildInfo.JobUrl = res.WorkflowRuns[0].HtmlUrl
88+
githubActionsBuildInfo.JobUrl = builds.WorkflowRuns[0].HtmlUrl
7889

79-
status := res.WorkflowRuns[0].Status
80-
conclusion := res.WorkflowRuns[0].Conclusion
90+
status := builds.WorkflowRuns[0].Status
91+
conclusion := builds.WorkflowRuns[0].Conclusion
8192

8293
if status == "queued" {
8394
githubActionsBuildInfo.LastBuild.State = "created"
@@ -92,7 +103,7 @@ func (p *GithubActionsApi) GetBuildInfo(branchName string) (CiBuildInfo, error)
92103
} else {
93104
githubActionsBuildInfo.LastBuild.State = "failed"
94105
}
95-
githubActionsBuildInfo.LastBuild.Id = res.WorkflowRuns[0].Id
106+
githubActionsBuildInfo.LastBuild.Id = builds.WorkflowRuns[0].Id
96107
return githubActionsBuildInfo, nil
97108
}
98109

@@ -132,6 +143,13 @@ func (p *GithubActionsApi) StartBuild(branchName string) error {
132143
return err
133144
}
134145

146+
buildsBefore, err := p.getBuilds(branchName)
147+
if err != nil {
148+
return err
149+
}
150+
151+
numBuildsBefore := buildsBefore.TotalCount
152+
135153
var req GithubActionsRequest
136154
req.Ref = branchName
137155

@@ -152,5 +170,24 @@ func (p *GithubActionsApi) StartBuild(branchName string) error {
152170
return errors.New(resp.String())
153171
}
154172

155-
return nil
173+
//there seems to be no way (yet) to get the build number of the job we manually start.
174+
//so in order to determine the build number, we look at the build that was created at last.
175+
//that's not bulletproof, but it should work well enough.
176+
for i := 0; i < 5; i++ { //it might take a bit until the build number is available
177+
buildsAfter, err := p.getBuilds(branchName)
178+
if err != nil {
179+
time.Sleep(1*time.Second)
180+
continue
181+
}
182+
numBuildsAfter := buildsAfter.TotalCount
183+
if numBuildsAfter == numBuildsBefore + 1 {
184+
if buildsAfter.WorkflowRuns[0].HeadBranch == branchName && buildsAfter.WorkflowRuns[0].Event == "workflow_dispatch" {
185+
return nil
186+
}
187+
}
188+
189+
time.Sleep(1*time.Second)
190+
}
191+
192+
return errors.New("Couldn't get build info after 5 attempts")
156193
}

0 commit comments

Comments
 (0)