Skip to content

Commit 7b0c71e

Browse files
Jairo Llopisyajo
authored andcommitted
Dump Travis and use GH actons
@Tecnativa TT22772
1 parent 7adadca commit 7b0c71e

File tree

5 files changed

+237
-68
lines changed

5 files changed

+237
-68
lines changed

.github/workflows/ci.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
schedule:
9+
# See https://crontab.guru/weekly
10+
- cron: 0 0 * * 0
11+
12+
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-python@v1
18+
- name: Set PY
19+
run:
20+
echo "::set-env name=PY::$(python -c 'import hashlib,
21+
sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
22+
- uses: actions/cache@v1
23+
with:
24+
path: ~/.cache/pre-commit
25+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
26+
- uses: pre-commit/[email protected]
27+
28+
build-test-push:
29+
runs-on: ubuntu-latest
30+
needs: pre-commit
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
# Test modern Odoo versions with latest Postgres version
35+
pg_version:
36+
- "13"
37+
- "12"
38+
- "11"
39+
- "10"
40+
- "9.6"
41+
env:
42+
# Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
43+
LATEST_RELEASE: "14.0"
44+
# Variables found by default in Docker Hub builder
45+
DOCKER_REPO: tecnativa/postgres-autoconf
46+
DOCKER_TAG: ${{ matrix.pg_version }}-alpine
47+
GIT_SHA1: ${{ github.sha }}
48+
steps:
49+
# Prepare
50+
- uses: actions/checkout@v2
51+
- uses: actions/setup-python@v1
52+
- run: pip install -r tests/ci-requirements.txt
53+
# Build images
54+
- run: ./hooks/build
55+
# Test
56+
- run: ./tests/test.py -v
57+
# Push
58+
- name: push to docker hub
59+
if: github.repository == 'Tecnativa/postgres-autoconf' && github.ref == 'refs/heads/master'
60+
env:
61+
REGISTRY_HOST: docker.io
62+
DOCKER_HUB_TOKEN: ${{ secrets.DOCKERHUB_PASSWORD }}
63+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
64+
run: ./hooks/push
65+
- name: push to github registry
66+
if: github.repository == 'Tecnativa/postgres-autoconf' && github.ref == 'refs/heads/master'
67+
env:
68+
DOCKER_REPO_SUFFIX: /postgres-autoconf
69+
REGISTRY_HOST: docker.pkg.github.com
70+
DOCKER_HUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
DOCKER_HUB_USERNAME: ${{ github.actor }}
72+
run: ./hooks/push

.gitignore

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,156 @@
11
tests/*.pem
22
tests/*.srl
3+
4+
5+
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,python
6+
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,python
7+
8+
### Python ###
9+
# Byte-compiled / optimized / DLL files
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
14+
# C extensions
15+
*.so
16+
17+
# Distribution / packaging
18+
.Python
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
wheels/
31+
pip-wheel-metadata/
32+
share/python-wheels/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
MANIFEST
37+
38+
# PyInstaller
39+
# Usually these files are written by a python script from a template
40+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
41+
*.manifest
42+
*.spec
43+
44+
# Installer logs
45+
pip-log.txt
46+
pip-delete-this-directory.txt
47+
48+
# Unit test / coverage reports
49+
htmlcov/
50+
.tox/
51+
.nox/
52+
.coverage
53+
.coverage.*
54+
.cache
55+
nosetests.xml
56+
coverage.xml
57+
*.cover
58+
*.py,cover
59+
.hypothesis/
60+
.pytest_cache/
61+
pytestdebug.log
62+
63+
# Translations
64+
*.mo
65+
*.pot
66+
67+
# Django stuff:
68+
*.log
69+
local_settings.py
70+
db.sqlite3
71+
db.sqlite3-journal
72+
73+
# Flask stuff:
74+
instance/
75+
.webassets-cache
76+
77+
# Scrapy stuff:
78+
.scrapy
79+
80+
# Sphinx documentation
81+
docs/_build/
82+
doc/_build/
83+
84+
# PyBuilder
85+
target/
86+
87+
# Jupyter Notebook
88+
.ipynb_checkpoints
89+
90+
# IPython
91+
profile_default/
92+
ipython_config.py
93+
94+
# pyenv
95+
.python-version
96+
97+
# pipenv
98+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
99+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
100+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
101+
# install all needed dependencies.
102+
#Pipfile.lock
103+
104+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
105+
__pypackages__/
106+
107+
# Celery stuff
108+
celerybeat-schedule
109+
celerybeat.pid
110+
111+
# SageMath parsed files
112+
*.sage.py
113+
114+
# Environments
115+
.env
116+
.venv
117+
env/
118+
venv/
119+
ENV/
120+
env.bak/
121+
venv.bak/
122+
123+
# Spyder project settings
124+
.spyderproject
125+
.spyproject
126+
127+
# Rope project settings
128+
.ropeproject
129+
130+
# mkdocs documentation
131+
/site
132+
133+
# mypy
134+
.mypy_cache/
135+
.dmypy.json
136+
dmypy.json
137+
138+
# Pyre type checker
139+
.pyre/
140+
141+
# pytype static type analyzer
142+
.pytype/
143+
144+
### VisualStudioCode ###
145+
.vscode/*
146+
!.vscode/settings.json
147+
!.vscode/tasks.json
148+
!.vscode/launch.json
149+
!.vscode/extensions.json
150+
*.code-workspace
151+
152+
### VisualStudioCode Patch ###
153+
# Ignore all local history of files
154+
.history
155+
156+
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python

.travis.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

hooks/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from plumbum.cmd import date, docker
44

55
# Check environment variables are present
66
DOCKER_TAG = local.env["DOCKER_TAG"]
7-
COMMIT = local.env.get("GIT_SHA1", local.env.get("TRAVIS_COMMIT"))
7+
COMMIT = local.env.get("GIT_SHA1")
88
DATE = date("--rfc-3339", "ns")
99

1010
# Build image

hooks/push

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from plumbum import FG, local
33
from plumbum.cmd import docker
44

5+
REGISTRY = local.env.get("REGISTRY_HOST", "docker.io")
56
REPO = local.env["DOCKER_REPO"]
7+
SUFFIX = local.env.get("DOCKER_REPO_SUFFIX", "")
68
VERSION = local.env["DOCKER_TAG"]
79

810
# Log all locally available images; will help to pin images
@@ -15,13 +17,16 @@ docker(
1517
local.env["DOCKER_HUB_USERNAME"],
1618
"--password",
1719
local.env["DOCKER_HUB_TOKEN"],
20+
REGISTRY,
1821
)
1922

2023
# Push built images
21-
versioned_image = "%s:%s" % (REPO, VERSION)
22-
docker["image", "push", versioned_image] & FG
24+
local_image = "%s:%s" % (REPO, VERSION)
25+
public_image = "%s/%s%s" % (REGISTRY, local_image, SUFFIX)
26+
docker["image", "tag", local_image, public_image]
27+
docker["image", "push", public_image] & FG
2328
if VERSION == local.env.get("LATEST_RELEASE"):
2429
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
30+
public_image = "%s/%s%s:%s" % (REGISTRY, REPO, SUFFIX, latest_version)
31+
docker["image", "tag", local_image, public_image] & FG
32+
docker["image", "push", public_image] & FG

0 commit comments

Comments
 (0)