Skip to content

Commit 6b358b7

Browse files
committed
[IMP] add a github workflow that generates test databases used in CI
1 parent 3fa44ce commit 6b358b7

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Generate test databases - cron and manually
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version'
8+
required: true
9+
type: choice
10+
options:
11+
- all
12+
- 16.0
13+
- 17.0
14+
- 18.0
15+
schedule:
16+
# every first of month
17+
- cron: "0 4 1 * *"
18+
19+
jobs:
20+
generate-testdb18:
21+
name: Generate test database 18.0
22+
if: (github.repository == 'OCA/OpenUpgrade' && github.event_name == 'schedule') || inputs.version == '18.0' || inputs.version == 'all'
23+
uses: ./.github/workflows/generate-testdb.yml
24+
with:
25+
version: "18.0"
26+
exclude_modules: "['payment_alipay', 'payment_ogone', 'payment_payulatam', 'payment_payumoney']"
27+
generate-testdb17:
28+
name: Generate test database 17.0
29+
if: (github.repository == 'OCA/OpenUpgrade' && github.event_name == 'schedule') || inputs.version == '17.0' || inputs.version == 'all'
30+
uses: ./.github/workflows/generate-testdb.yml
31+
with:
32+
version: "17.0"
33+
exclude_modules: "['payment_alipay', 'payment_ogone', 'payment_payulatam', 'payment_payumoney']"
34+
generate-testdb16:
35+
name: Generate test database 16.0
36+
if: (github.repository == 'OCA/OpenUpgrade' && github.event_name == 'schedule') || inputs.version == '16.0' || inputs.version == 'all'
37+
uses: ./.github/workflows/generate-testdb.yml
38+
with:
39+
version: "16.0"
40+
exclude_modules: "['payment_alipay', 'payment_ogone', 'payment_payulatam', 'payment_payumoney']"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Generate test database
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
python_version:
10+
default: "3.10"
11+
type: string
12+
postgres_version:
13+
default: "14"
14+
type: string
15+
exclude_modules:
16+
default: "[]"
17+
type: string
18+
release_tag:
19+
default: "databases"
20+
type: string
21+
jobs:
22+
generate-testdb:
23+
name: Generate test database ${{ inputs.version }}
24+
runs-on: ubuntu-22.04
25+
container: ghcr.io/oca/oca-ci/py${{ inputs.python_version }}-ocb${{ inputs.version }}:latest
26+
env:
27+
PGHOST: "postgres"
28+
PGPASSWORD: "odoo"
29+
PGUSER: "odoo"
30+
VERSION: "${{ inputs.version }}"
31+
DBNAME: "openupgrade"
32+
services:
33+
postgres:
34+
image: postgres:${{ inputs.postgres_version }}
35+
env:
36+
POSTGRES_USER: odoo
37+
POSTGRES_PASSWORD: odoo
38+
ports:
39+
- 5432:5432
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
- name: Install extra dependencies
44+
run: |
45+
# this is for l10n_eg_edi_eta which crashes without it
46+
pip install asn1crypto
47+
# this is for cloud_storage_google
48+
pip install google-auth
49+
# this is for account_peppol
50+
pip install phonenumbers
51+
# for pushing release
52+
apt install gh -y
53+
- name: Install all modules and an extra language
54+
run: |
55+
odoo -d $DBNAME -i base --stop-after-init
56+
odoo shell -d $DBNAME <<EOF
57+
# be sure attachments go into the database
58+
env['ir.config_parameter'].set_param('ir_attachment.location', 'db')
59+
env['ir.attachment'].force_storage()
60+
env['ir.module.module'].search([
61+
('name', 'not in', ${{ inputs.exclude_modules }}),
62+
('name', 'not ilike', 'test_%'),
63+
('name', 'not ilike', 'hw_%'),
64+
]).button_immediate_install()
65+
env.cr.commit()
66+
EOF
67+
odoo -d $DBNAME --load-language=fr_FR --stop-after-init
68+
- name: Dump database
69+
run: |
70+
pg_dump $DBNAME -Fc -f $VERSION.psql
71+
- name: Upload database dump to release
72+
env:
73+
GH_TOKEN: ${{ github.token }}
74+
run: |
75+
git config --global --add safe.directory $(pwd)
76+
gh release upload ${{ inputs.release_tag }} $VERSION.psql --clobber

0 commit comments

Comments
 (0)