-
Notifications
You must be signed in to change notification settings - Fork 303
163 lines (159 loc) · 5.97 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: ci
on:
pull_request:
push:
branches:
- master
schedule:
# See https://crontab.guru/weekly
- cron: 0 0 * * 0
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Set PY
run:
echo "PY=$(python -c 'import hashlib,
sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
>> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/[email protected]
test:
runs-on: ubuntu-22.04
needs: pre-commit
strategy:
fail-fast: false
matrix:
# Test modern Odoo versions with latest Postgres version
odoo_version: ["17.0"]
pg_version: ["15"]
python_version: ["3.10"]
include:
# Older odoo versions don't support latest postgres and Python versions
- odoo_version: "16.0"
pg_version: "14"
python_version: "3.10"
- odoo_version: "15.0"
pg_version: "14"
python_version: "3.9"
- odoo_version: "14.0"
pg_version: "14"
python_version: "3.9"
- odoo_version: "13.0"
pg_version: "14"
python_version: "3.9"
env:
# Other variables to configure tests and execution environment
DOCKER_BUILDKIT: 1
PG_VERSIONS: ${{ matrix.pg_version }}
steps:
# Prepare
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
# Install dev and test dependencies
- run: pip install poetry
- name: Patch $PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
# override pyyaml to 5.3.1 as PIP_CONSTRAINT does not work for poetry
# to get rid of AttributeError: cython_sources when installing pyyaml
- run: poetry add pyyaml==5.3.1
- run: poetry install
# Test
- run: poetry run python -m unittest -v tests
build-push:
runs-on: ubuntu-22.04
needs: test
strategy:
fail-fast: false
matrix:
# Test modern Odoo versions with latest Postgres version
odoo_version: ["17.0"]
platforms: ["linux/amd64,linux/arm64"]
include:
# Older odoo versions don't support latest postgres and Python versions
- odoo_version: "16.0"
platforms: "linux/amd64,linux/arm64"
- odoo_version: "15.0"
platforms: "linux/amd64,linux/arm64"
- odoo_version: "14.0"
platforms: "linux/amd64,linux/arm64"
- odoo_version: "13.0"
platforms: "linux/amd64"
env:
# Indicates what's the equivalent to tecnativa/doodba:latest image
LATEST_RELEASE: "17.0"
# Define the docker hub repository location and github container registry host
DOCKER_REPO: tecnativa/doodba
GHCR_HOST: ghcr.io
steps:
# Set build date as env variable to be used later
- name: Set build date
run: echo "BUILD_DATE=$(date '+%Y-%m-%dT%H:%M:%S.%N%:z')" >> $GITHUB_ENV
# Prepare
- uses: actions/checkout@v4
# Setup QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Setup buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.repository == 'tecnativa/doodba' && github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.repository == 'tecnativa/doodba' && github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.BOT_LOGIN }}
password: ${{ secrets.BOT_TOKEN }}
- name: Build base image
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.odoo_version }}.Dockerfile
platforms: ${{ matrix.platforms }}
push:
${{ github.repository == 'tecnativa/doodba' && github.ref ==
'refs/heads/master' }}
tags: |
${{ env.DOCKER_REPO }}:${{ matrix.odoo_version }}
${{ env.GHCR_HOST }}/${{ env.DOCKER_REPO }}${{ env.DOCKER_REPO_SUFFIX }}:${{ matrix.odoo_version }}
${{ matrix.odoo_version == env.LATEST_RELEASE && format('{0}:latest', env.DOCKER_REPO) || '' }}
${{ matrix.odoo_version == env.LATEST_RELEASE && format('{0}/{1}{2}:latest', env.GHCR_HOST, env.DOCKER_REPO, env.DOCKER_REPO_SUFFIX) || '' }}
target: base
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ env.BUILD_DATE }}
ODOO_VERSION=${{ matrix.odoo_version }}
- name: Build onbuild image
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.odoo_version }}.Dockerfile
platforms: ${{ matrix.platforms }}
push:
${{ github.repository == 'tecnativa/doodba' && github.ref ==
'refs/heads/master' }}
tags: |
${{ env.DOCKER_REPO }}:${{ matrix.odoo_version }}-onbuild
${{ env.GHCR_HOST }}/${{ env.DOCKER_REPO }}${{ env.DOCKER_REPO_SUFFIX }}:${{ matrix.odoo_version }}-onbuild
${{ matrix.odoo_version == env.LATEST_RELEASE && format('{0}:latest-onbuild', env.DOCKER_REPO) || '' }}
${{ matrix.odoo_version == env.LATEST_RELEASE && format('{0}/{1}{2}:latest-onbuild', env.GHCR_HOST, env.DOCKER_REPO, env.DOCKER_REPO_SUFFIX) || '' }}
target: onbuild
build-args: |
VCS_REF=${{ github.sha }}
BUILD_DATE=${{ env.BUILD_DATE }}
ODOO_VERSION=${{ matrix.odoo_version }}