Skip to content

Commit

Permalink
Dump Travis and use GH actons
Browse files Browse the repository at this point in the history
@Tecnativa TT22772
  • Loading branch information
Jairo Llopis authored and yajo committed Sep 30, 2020
1 parent 7adadca commit 7b0c71e
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 68 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: ci

on:
pull_request:
push:
branches:
- master
schedule:
# See https://crontab.guru/weekly
- cron: 0 0 * * 0

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Set PY
run:
echo "::set-env name=PY::$(python -c 'import hashlib,
sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/[email protected]

build-test-push:
runs-on: ubuntu-latest
needs: pre-commit
strategy:
fail-fast: false
matrix:
# Test modern Odoo versions with latest Postgres version
pg_version:
- "13"
- "12"
- "11"
- "10"
- "9.6"
env:
# Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
LATEST_RELEASE: "14.0"
# Variables found by default in Docker Hub builder
DOCKER_REPO: tecnativa/postgres-autoconf
DOCKER_TAG: ${{ matrix.pg_version }}-alpine
GIT_SHA1: ${{ github.sha }}
steps:
# Prepare
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install -r tests/ci-requirements.txt
# Build images
- run: ./hooks/build
# Test
- run: ./tests/test.py -v
# Push
- name: push to docker hub
if: github.repository == 'Tecnativa/postgres-autoconf' && github.ref == 'refs/heads/master'
env:
REGISTRY_HOST: docker.io
DOCKER_HUB_TOKEN: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: ./hooks/push
- name: push to github registry
if: github.repository == 'Tecnativa/postgres-autoconf' && github.ref == 'refs/heads/master'
env:
DOCKER_REPO_SUFFIX: /postgres-autoconf
REGISTRY_HOST: docker.pkg.github.com
DOCKER_HUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_USERNAME: ${{ github.actor }}
run: ./hooks/push
154 changes: 154 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,156 @@
tests/*.pem
tests/*.srl


# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,python
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python
62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from plumbum.cmd import date, docker

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

# Build image
Expand Down
15 changes: 10 additions & 5 deletions hooks/push
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from plumbum import FG, local
from plumbum.cmd import docker

REGISTRY = local.env.get("REGISTRY_HOST", "docker.io")
REPO = local.env["DOCKER_REPO"]
SUFFIX = local.env.get("DOCKER_REPO_SUFFIX", "")
VERSION = local.env["DOCKER_TAG"]

# Log all locally available images; will help to pin images
Expand All @@ -15,13 +17,16 @@ docker(
local.env["DOCKER_HUB_USERNAME"],
"--password",
local.env["DOCKER_HUB_TOKEN"],
REGISTRY,
)

# Push built images
versioned_image = "%s:%s" % (REPO, VERSION)
docker["image", "push", versioned_image] & FG
local_image = "%s:%s" % (REPO, VERSION)
public_image = "%s/%s%s" % (REGISTRY, local_image, SUFFIX)
docker["image", "tag", local_image, public_image]
docker["image", "push", public_image] & FG
if VERSION == local.env.get("LATEST_RELEASE"):
latest_version = "alpine" if VERSION.endswith("-alpine") else "latest"
latest_image = "%s:%s" % (REPO, latest_version)
docker["image", "tag", versioned_image, latest_image] & FG
docker["image", "push", latest_image] & FG
public_image = "%s/%s%s:%s" % (REGISTRY, REPO, SUFFIX, latest_version)
docker["image", "tag", local_image, public_image] & FG
docker["image", "push", public_image] & FG

0 comments on commit 7b0c71e

Please sign in to comment.