Skip to content

Commit d433891

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

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
schedule:
15+
# every first of month
16+
- cron: "0 4 1 * *"
17+
18+
jobs:
19+
generate-testdb17:
20+
name: Generate test database 17.0
21+
if: (github.repository == 'OCA/OpenUpgrade' && github.event_name == 'schedule') || inputs.version == '17.0' || inputs.version == 'all'
22+
uses: ./.github/workflows/generate-testdb.yml
23+
with:
24+
version: "17.0"
25+
exclude_modules: "['payment_alipay', 'payment_ogone', 'payment_payulatam', 'payment_payumoney']"
26+
generate-testdb16:
27+
name: Generate test database 16.0
28+
if: (github.repository == 'OCA/OpenUpgrade' && github.event_name == 'schedule') || inputs.version == '16.0' || inputs.version == 'all'
29+
uses: ./.github/workflows/generate-testdb.yml
30+
with:
31+
version: "16.0"
32+
exclude_modules: "['payment_alipay', 'payment_ogone', 'payment_payulatam', 'payment_payumoney']"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
# for pushing release
48+
apt install gh -y
49+
- name: Install all modules and an extra language
50+
run: |
51+
odoo -d $DBNAME -i base --stop-after-init
52+
odoo shell -d $DBNAME <<EOF
53+
# be sure attachments go into the database
54+
env['ir.config_parameter'].set_param('ir_attachment.location', 'db')
55+
env['ir.attachment'].force_storage()
56+
env['ir.module.module'].search([
57+
('name', 'not in', ${{ inputs.exclude_modules }}),
58+
('name', 'not ilike', 'test_%'),
59+
('name', 'not ilike', 'hw_%'),
60+
]).button_immediate_install()
61+
env.cr.commit()
62+
EOF
63+
odoo -d $DBNAME --load-language=fr_FR --stop-after-init
64+
- name: Dump database
65+
run: |
66+
pg_dump $DBNAME -Fc -f $VERSION.psql
67+
- name: Upload database dump to release
68+
env:
69+
GH_TOKEN: ${{ github.token }}
70+
run: |
71+
git config --global --add safe.directory $(pwd)
72+
gh release upload ${{ inputs.release_tag }} $VERSION.psql --clobber

0 commit comments

Comments
 (0)