Skip to content

Commit 6a2999e

Browse files
authored
Merge pull request #241 from QGEP/poa_fix_precommit
Create .pre-commit-config.yaml
2 parents 124e252 + 8531396 commit 6a2999e

File tree

135 files changed

+2994
-2316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+2994
-2316
lines changed

.deploy/create-dumps.py

Lines changed: 122 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
"""
54
***************************************************************************
@@ -18,16 +17,14 @@
1817
***************************************************************************
1918
"""
2019

21-
__author__ = 'Denis Rouzaud'
22-
__date__ = 'April 2018'
23-
__copyright__ = '(C) 2018,Denis Rouzaud'
20+
__author__ = "Denis Rouzaud"
21+
__date__ = "April 2018"
22+
__copyright__ = "(C) 2018,Denis Rouzaud"
2423
# This will get replaced with a git SHA1 when you do a git archive
25-
__revision__ = '$Format:%H$'
24+
__revision__ = "$Format:%H$"
2625

2726

28-
import http.client
2927
import os
30-
import json
3128
import subprocess
3229

3330

@@ -56,7 +53,9 @@ def files_description(version):
5653
5754
* If you plan to **use QGEP for production**, it is more likely you will be using the plain SQL `qgep_{version}_structure_with_value_lists.sql`.
5855
* If you want to **give a try at QGEP**, you will likely restore the `qgep_{version}_structure_and_demo_data.backup` backup file.
59-
""".format(version=version)
56+
""".format(
57+
version=version
58+
)
6059

6160

6261
def create_dumps():
@@ -76,43 +75,54 @@ def create_plain_structure_only():
7675
Create a plain SQL dump of data structure of all schemas and the content of pum_sys.inf
7776
:return: the file name of the dump
7877
"""
79-
print('::group::plain SQL structure only')
78+
print("::group::plain SQL structure only")
8079

8180
# structure
82-
dump_s = 'qgep_{version}_structure.sql'.format(
83-
version=os.environ['CI_TAG'])
84-
85-
print('Creating dump {}'.format(dump_s))
86-
dump_file_s = 'artifacts/{dump}'.format(dump=dump_s)
87-
_cmd(['pg_dump',
88-
'--format', 'plain',
89-
'--schema-only',
90-
'--file', dump_file_s,
91-
'--exclude-schema', 'public',
92-
'--no-owner',
93-
'qgep_prod']
94-
)
81+
dump_s = "qgep_{version}_structure.sql".format(version=os.environ["CI_TAG"])
82+
83+
print(f"Creating dump {dump_s}")
84+
dump_file_s = f"artifacts/{dump_s}"
85+
_cmd(
86+
[
87+
"pg_dump",
88+
"--format",
89+
"plain",
90+
"--schema-only",
91+
"--file",
92+
dump_file_s,
93+
"--exclude-schema",
94+
"public",
95+
"--no-owner",
96+
"qgep_prod",
97+
]
98+
)
9599

96100
# dump all from qgep_sys except logged_actions
97-
dump_i = 'qgep_{version}_pum_info.sql'.format(
98-
version=os.environ['CI_TAG'])
99-
print('Creating dump {}'.format(dump_i))
100-
dump_file_i = 'artifacts/{dump}'.format(dump=dump_i)
101-
_cmd(['pg_dump',
102-
'--format', 'plain',
103-
'--data-only',
104-
'--file', dump_file_i,
105-
'--schema', 'qgep_sys',
106-
'--exclude-table', 'qgep_sys.logged_actions',
107-
'qgep_prod']
108-
)
109-
print('Concatenating the 2 dumps')
101+
dump_i = "qgep_{version}_pum_info.sql".format(version=os.environ["CI_TAG"])
102+
print(f"Creating dump {dump_i}")
103+
dump_file_i = f"artifacts/{dump_i}"
104+
_cmd(
105+
[
106+
"pg_dump",
107+
"--format",
108+
"plain",
109+
"--data-only",
110+
"--file",
111+
dump_file_i,
112+
"--schema",
113+
"qgep_sys",
114+
"--exclude-table",
115+
"qgep_sys.logged_actions",
116+
"qgep_prod",
117+
]
118+
)
119+
print("Concatenating the 2 dumps")
110120
with open(dump_file_i) as f:
111121
dump_data = f.read()
112122
with open(dump_file_s, "a") as f:
113123
f.write(dump_data)
114124

115-
print('::endgroup::')
125+
print("::endgroup::")
116126

117127
return dump_file_s
118128

@@ -123,35 +133,40 @@ def create_plain_value_list(structure_dump_file):
123133
with value list content
124134
:return: the file name of the dump
125135
"""
126-
print('::group::value lists dump')
127-
128-
dump = 'qgep_{version}_structure_with_value_lists.sql'.format(
129-
version=os.environ['CI_TAG'])
130-
131-
print('Creating dump {}'.format(dump))
132-
dump_file = 'artifacts/{dump}'.format(dump=dump)
133-
134-
_cmd(['pg_dump',
135-
'--format', 'plain',
136-
'--blobs',
137-
'--data-only',
138-
'--file', dump_file,
139-
'--schema', 'qgep_vl',
140-
'qgep_prod']
141-
)
142-
143-
print('Concatenating the 2 dumps')
136+
print("::group::value lists dump")
137+
138+
dump = "qgep_{version}_structure_with_value_lists.sql".format(version=os.environ["CI_TAG"])
139+
140+
print(f"Creating dump {dump}")
141+
dump_file = f"artifacts/{dump}"
142+
143+
_cmd(
144+
[
145+
"pg_dump",
146+
"--format",
147+
"plain",
148+
"--blobs",
149+
"--data-only",
150+
"--file",
151+
dump_file,
152+
"--schema",
153+
"qgep_vl",
154+
"qgep_prod",
155+
]
156+
)
157+
158+
print("Concatenating the 2 dumps")
144159
with open(dump_file) as f:
145160
dump_data = f.read()
146161
with open(structure_dump_file) as f:
147162
structure_dump_data = f.read()
148-
with open(dump_file, 'w') as f:
163+
with open(dump_file, "w") as f:
149164
f.write(structure_dump_data)
150-
f.write('\n\n\n-- Value lists dump --\n\n')
165+
f.write("\n\n\n-- Value lists dump --\n\n")
151166
f.write(dump_data)
152167

153-
print('::endgroup::')
154-
168+
print("::endgroup::")
169+
155170
return dump_file
156171

157172

@@ -161,22 +176,29 @@ def create_backup_data():
161176
:return: the file name
162177
"""
163178
# Create data-only dumps (with sample data)
164-
dump = 'qgep_{version}_demo_data.backup'.format(
165-
version = os.environ['CI_TAG'])
166-
print('::group::{}'.format(dump))
167-
print('Creating dump {}'.format(dump))
168-
dump_file = 'artifacts/{dump}'.format(dump=dump)
169-
_cmd(['pg_dump',
170-
'--format', 'custom',
171-
'--blobs',
172-
'--data-only',
173-
'--compress', '5',
174-
'--file', dump_file,
175-
'--table', 'qgep_od.*',
176-
'--table', 'qgep_sys.logged_actions',
177-
'qgep_prod']
178-
)
179-
print('::endgroup::')
179+
dump = "qgep_{version}_demo_data.backup".format(version=os.environ["CI_TAG"])
180+
print(f"::group::{dump}")
181+
print(f"Creating dump {dump}")
182+
dump_file = f"artifacts/{dump}"
183+
_cmd(
184+
[
185+
"pg_dump",
186+
"--format",
187+
"custom",
188+
"--blobs",
189+
"--data-only",
190+
"--compress",
191+
"5",
192+
"--file",
193+
dump_file,
194+
"--table",
195+
"qgep_od.*",
196+
"--table",
197+
"qgep_sys.logged_actions",
198+
"qgep_prod",
199+
]
200+
)
201+
print("::endgroup::")
180202
return dump_file
181203

182204

@@ -186,20 +208,26 @@ def create_backup_complete():
186208
:return: the file name
187209
"""
188210
# Create data + structure dumps (with sample data)
189-
dump = 'qgep_{version}_structure_and_demo_data.backup'.format(
190-
version = os.environ['CI_TAG'])
191-
print('::group::{}'.format(dump))
192-
print('Creating dump {}'.format(dump))
193-
dump_file = 'artifacts/{dump}'.format(dump=dump)
194-
_cmd(['pg_dump',
195-
'--format', 'custom',
196-
'--blobs',
197-
'--compress', '5',
198-
'--file', dump_file,
199-
'-N', 'public',
200-
'qgep_prod']
201-
)
202-
print('::endgroup::')
211+
dump = "qgep_{version}_structure_and_demo_data.backup".format(version=os.environ["CI_TAG"])
212+
print(f"::group::{dump}")
213+
print(f"Creating dump {dump}")
214+
dump_file = f"artifacts/{dump}"
215+
_cmd(
216+
[
217+
"pg_dump",
218+
"--format",
219+
"custom",
220+
"--blobs",
221+
"--compress",
222+
"5",
223+
"--file",
224+
dump_file,
225+
"-N",
226+
"public",
227+
"qgep_prod",
228+
]
229+
)
230+
print("::endgroup::")
203231

204232
return dump_file
205233

@@ -208,15 +236,16 @@ def main():
208236
"""
209237
Creates dumps to be attached to releases.
210238
"""
211-
if 'CI_TAG' not in os.environ or not os.environ['CI_TAG']:
212-
print('No git tag: not deploying anything')
239+
if "CI_TAG" not in os.environ or not os.environ["CI_TAG"]:
240+
print("No git tag: not deploying anything")
213241
return
214242
else:
215-
print('Creating release from tag {}'.format(os.environ['CI_TAG']))
243+
print("Creating release from tag {}".format(os.environ["CI_TAG"]))
216244

217-
os.mkdir('artifacts')
245+
os.mkdir("artifacts")
218246
files = create_dumps()
219-
print('Dumps created: {}'.format(', '.join(files)))
247+
print("Dumps created: {}".format(", ".join(files)))
248+
220249

221250
if __name__ == "__main__":
222251
main()

.docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Reinitialization
2424
```bash
2525
# later on, to reinitialize all databases
2626
docker exec qgep init_qgep.sh
27-
# optionally, you can specify which database to reinitialize like this
27+
# optionally, you can specify which database to reinitialize like this
2828
# docker exec qgep init_qgep.sh structure
2929
```
3030

.docker/init_qgep.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if [ "$1" == "release" ]; then
4040
echo 'you must provide the release version as second argument'
4141
exit 1
4242
fi
43-
43+
4444
echo '----------------------------------------'
4545
echo "Installing demo data from release"
4646

.github/workflows/docker-test-and-push.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ jobs:
2222
matrix:
2323
# postgres-postgis version, see available tags https://hub.docker.com/r/postgis/postgis/tags
2424
pgis:
25-
# WARNING: if changing this, make sure tu update `pgis_stable` below
26-
- 13-3.2
27-
- 14-3.2
25+
# WARNING: if changing this, make sure tu update `pgis_stable` below
26+
- 13-3.4
27+
- 14-3.4
2828
#- 15-3.3 # Postgis 3.3 requires QGEP datamodel adaptations
2929
# See https://github.com/QGEP/QGEP/issues/825
3030
fail-fast: false
3131

3232
env:
3333
# which pgis version to use for :tag images and to generate the dumps attached to the release (must be in the matrix above)
34-
pgis_stable: "14-3.2"
34+
pgis_stable: "14-3.4"
3535

3636
steps:
37-
- uses: actions/checkout@v3
37+
- uses: actions/checkout@v4
3838

3939
- name: "assert version is up to date"
4040
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ nosetests.xml
55
.DS_Store
66
.idea
77
temp/
8-

0 commit comments

Comments
 (0)