File tree 4 files changed +74
-19
lines changed
4 files changed +74
-19
lines changed Original file line number Diff line number Diff line change 1
- dist : xenial
2
-
3
- sudo : required
1
+ os : linux
4
2
5
3
language : python
6
4
@@ -19,19 +17,42 @@ addons:
19
17
packages :
20
18
- docker-ce
21
19
20
+ cache :
21
+ directories :
22
+ - $HOME/.cache/pip
23
+ - $HOME/.cache/pre-commit
24
+
22
25
branches :
23
26
only :
24
27
- master
25
28
29
+ stages :
30
+ - name : lint
31
+ - name : test
32
+
26
33
env :
27
- matrix :
34
+ global :
35
+ - LATEST_RELEASE=11-alpine
36
+ - DOCKER_REPO=tecnativa/postgres-autoconf
37
+ jobs :
28
38
- DOCKER_TAG=9.6-alpine
29
39
- DOCKER_TAG=10-alpine
30
40
- DOCKER_TAG=11-alpine
31
- - DOCKER_TAG=alpine
41
+
42
+ jobs :
43
+ include :
44
+ stage : lint
45
+ script :
46
+ - pre-commit run --all --show-diff-on-failure
32
47
33
48
install :
34
49
- pip install -r tests/ci-requirements.txt
35
50
36
51
script :
37
52
- ./tests/test.py -v
53
+
54
+ deploy :
55
+ provider : script
56
+ script : ./hooks/push
57
+ on :
58
+ branch : master
Original file line number Diff line number Diff line change 1
- #! /usr/bin/env bash
2
- set -ex
1
+ #!/usr/bin/env python3
2
+ from plumbum import FG , local
3
+ from plumbum .cmd import date , docker
3
4
4
5
# Check environment variables are present
5
- test -n " $DOCKER_TAG "
6
+ DOCKER_TAG = local .env ["DOCKER_TAG" ]
7
+ COMMIT = local .env .get ("GIT_SHA1" , local .env .get ("TRAVIS_COMMIT" ))
8
+ DATE = date ("--rfc-3339" , "ns" )
6
9
7
- # Prepare build args
8
- commit=" ${GIT_SHA1:- $TRAVIS_COMMIT } "
9
-
10
- # To be configured via Docker Hub UI, all labels from postgres image targeting
11
- # this master branch
12
- time docker image build \
13
- --build-arg VCS_REF=" $commit " \
14
- --build-arg BUILD_DATE=" $( date --rfc-3339 ns) " \
15
- --build-arg BASE_TAG=" $DOCKER_TAG " \
16
- --tag " tecnativa/postgres-autoconf:$DOCKER_TAG " \
17
- .
10
+ # Build image
11
+ docker [
12
+ "image" ,
13
+ "build" ,
14
+ "--build-arg" ,
15
+ "VCS_REF={}" .format (COMMIT ),
16
+ "--build-arg" ,
17
+ "BUILD_DATE={}" .format (DATE ),
18
+ "--build-arg" ,
19
+ "BASE_TAG={}" .format (DOCKER_TAG ),
20
+ "--tag" ,
21
+ "tecnativa/postgres-autoconf:{}" .format (DOCKER_TAG ),
22
+ "." ,
23
+ ] & FG
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ from plumbum import FG , local
3
+ from plumbum .cmd import docker
4
+
5
+ REPO = local .env ["DOCKER_REPO" ]
6
+ VERSION = local .env ["DOCKER_TAG" ]
7
+
8
+ # Log all locally available images; will help to pin images
9
+ docker ["image" , "ls" , "--digests" , REPO ] & FG
10
+
11
+ # Login in Docker Hub
12
+ docker (
13
+ "login" ,
14
+ "--username" ,
15
+ local .env ["DOCKER_HUB_USERNAME" ],
16
+ "--password" ,
17
+ local .env ["DOCKER_HUB_TOKEN" ],
18
+ )
19
+
20
+ # Push built images
21
+ versioned_image = "%s:%s" % (REPO , VERSION )
22
+ docker ["image" , "push" , versioned_image ] & FG
23
+ if VERSION == local .env .get ("LATEST_RELEASE" ):
24
+ latest_version = "alpine" if VERSION .endswith ("-alpine" ) else "latest"
25
+ latest_image = "%s:%s" % (REPO , latest_version )
26
+ docker ["image" , "tag" , versioned_image , latest_image ] & FG
27
+ docker ["image" , "push" , latest_image ] & FG
Original file line number Diff line number Diff line change 1
1
plumbum
2
+ pre-commit
You can’t perform that action at this time.
0 commit comments