Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create .pre-commit-config.yaml #241

Merged
merged 24 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ae9f686
Create .pre-commit-config.yaml
ponceta Nov 15, 2024
f7ff8c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
18dea8a
Fix import syntax and syntax enhancements
ponceta Nov 15, 2024
c431f01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
e3529d7
Use wwtp (wt) columns in vw_qgep_wastewater_structure
ponceta Nov 15, 2024
09b5f09
Merge branch 'poa_fix_precommit' of https://github.com/QGEP/datamodel…
ponceta Nov 15, 2024
7a4e7fd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
c6d67a8
fix import in delta
ponceta Nov 15, 2024
8bd2dff
Merge branch 'poa_fix_precommit' of https://github.com/QGEP/datamodel…
ponceta Nov 15, 2024
1325c6e
Try absolute
ponceta Nov 15, 2024
595ea05
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
9f6a617
Extend module awareness
ponceta Nov 15, 2024
dc5be31
Merge branch 'poa_fix_precommit' of https://github.com/QGEP/datamodel…
ponceta Nov 15, 2024
3bd2e94
Get funky
ponceta Nov 15, 2024
f3931c6
Revert funky
ponceta Nov 15, 2024
0bbdbc3
Revert funky
ponceta Nov 15, 2024
ae841a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
4e808d6
Expect = None, Assert is None
ponceta Nov 15, 2024
c1600e2
Merge branch 'poa_fix_precommit' of https://github.com/QGEP/datamodel…
ponceta Nov 15, 2024
5e0d763
Update checkout version and postgis version
ponceta Nov 15, 2024
e0006ab
Update delta/pre-all.py
ponceta Nov 18, 2024
fe1f0a3
Update delta/post-all.py
ponceta Nov 18, 2024
537550e
Update view/create_views.py
ponceta Nov 18, 2024
8531396
Apply suggestions from code review
domi4484 Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 122 additions & 93 deletions .deploy/create-dumps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
***************************************************************************
Expand All @@ -18,16 +17,14 @@
***************************************************************************
"""

__author__ = 'Denis Rouzaud'
__date__ = 'April 2018'
__copyright__ = '(C) 2018,Denis Rouzaud'
__author__ = "Denis Rouzaud"
__date__ = "April 2018"
__copyright__ = "(C) 2018,Denis Rouzaud"
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
__revision__ = "$Format:%H$"


import http.client
import os
import json
import subprocess


Expand Down Expand Up @@ -56,7 +53,9 @@ def files_description(version):

* 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`.
* If you want to **give a try at QGEP**, you will likely restore the `qgep_{version}_structure_and_demo_data.backup` backup file.
""".format(version=version)
""".format(
version=version
)


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

# structure
dump_s = 'qgep_{version}_structure.sql'.format(
version=os.environ['CI_TAG'])

print('Creating dump {}'.format(dump_s))
dump_file_s = 'artifacts/{dump}'.format(dump=dump_s)
_cmd(['pg_dump',
'--format', 'plain',
'--schema-only',
'--file', dump_file_s,
'--exclude-schema', 'public',
'--no-owner',
'qgep_prod']
)
dump_s = "qgep_{version}_structure.sql".format(version=os.environ["CI_TAG"])

print(f"Creating dump {dump_s}")
dump_file_s = f"artifacts/{dump_s}"
_cmd(
[
"pg_dump",
"--format",
"plain",
"--schema-only",
"--file",
dump_file_s,
"--exclude-schema",
"public",
"--no-owner",
"qgep_prod",
]
)

# dump all from qgep_sys except logged_actions
dump_i = 'qgep_{version}_pum_info.sql'.format(
version=os.environ['CI_TAG'])
print('Creating dump {}'.format(dump_i))
dump_file_i = 'artifacts/{dump}'.format(dump=dump_i)
_cmd(['pg_dump',
'--format', 'plain',
'--data-only',
'--file', dump_file_i,
'--schema', 'qgep_sys',
'--exclude-table', 'qgep_sys.logged_actions',
'qgep_prod']
)
print('Concatenating the 2 dumps')
dump_i = "qgep_{version}_pum_info.sql".format(version=os.environ["CI_TAG"])
print(f"Creating dump {dump_i}")
dump_file_i = f"artifacts/{dump_i}"
_cmd(
[
"pg_dump",
"--format",
"plain",
"--data-only",
"--file",
dump_file_i,
"--schema",
"qgep_sys",
"--exclude-table",
"qgep_sys.logged_actions",
"qgep_prod",
]
)
print("Concatenating the 2 dumps")
with open(dump_file_i) as f:
dump_data = f.read()
with open(dump_file_s, "a") as f:
f.write(dump_data)

print('::endgroup::')
print("::endgroup::")

return dump_file_s

Expand All @@ -123,35 +133,40 @@ def create_plain_value_list(structure_dump_file):
with value list content
:return: the file name of the dump
"""
print('::group::value lists dump')

dump = 'qgep_{version}_structure_with_value_lists.sql'.format(
version=os.environ['CI_TAG'])

print('Creating dump {}'.format(dump))
dump_file = 'artifacts/{dump}'.format(dump=dump)

_cmd(['pg_dump',
'--format', 'plain',
'--blobs',
'--data-only',
'--file', dump_file,
'--schema', 'qgep_vl',
'qgep_prod']
)

print('Concatenating the 2 dumps')
print("::group::value lists dump")

dump = "qgep_{version}_structure_with_value_lists.sql".format(version=os.environ["CI_TAG"])

print(f"Creating dump {dump}")
dump_file = f"artifacts/{dump}"

_cmd(
[
"pg_dump",
"--format",
"plain",
"--blobs",
"--data-only",
"--file",
dump_file,
"--schema",
"qgep_vl",
"qgep_prod",
]
)

print("Concatenating the 2 dumps")
with open(dump_file) as f:
dump_data = f.read()
with open(structure_dump_file) as f:
structure_dump_data = f.read()
with open(dump_file, 'w') as f:
with open(dump_file, "w") as f:
f.write(structure_dump_data)
f.write('\n\n\n-- Value lists dump --\n\n')
f.write("\n\n\n-- Value lists dump --\n\n")
f.write(dump_data)

print('::endgroup::')
print("::endgroup::")

return dump_file


Expand All @@ -161,22 +176,29 @@ def create_backup_data():
:return: the file name
"""
# Create data-only dumps (with sample data)
dump = 'qgep_{version}_demo_data.backup'.format(
version = os.environ['CI_TAG'])
print('::group::{}'.format(dump))
print('Creating dump {}'.format(dump))
dump_file = 'artifacts/{dump}'.format(dump=dump)
_cmd(['pg_dump',
'--format', 'custom',
'--blobs',
'--data-only',
'--compress', '5',
'--file', dump_file,
'--table', 'qgep_od.*',
'--table', 'qgep_sys.logged_actions',
'qgep_prod']
)
print('::endgroup::')
dump = "qgep_{version}_demo_data.backup".format(version=os.environ["CI_TAG"])
print(f"::group::{dump}")
print(f"Creating dump {dump}")
dump_file = f"artifacts/{dump}"
_cmd(
[
"pg_dump",
"--format",
"custom",
"--blobs",
"--data-only",
"--compress",
"5",
"--file",
dump_file,
"--table",
"qgep_od.*",
"--table",
"qgep_sys.logged_actions",
"qgep_prod",
]
)
print("::endgroup::")
return dump_file


Expand All @@ -186,20 +208,26 @@ def create_backup_complete():
:return: the file name
"""
# Create data + structure dumps (with sample data)
dump = 'qgep_{version}_structure_and_demo_data.backup'.format(
version = os.environ['CI_TAG'])
print('::group::{}'.format(dump))
print('Creating dump {}'.format(dump))
dump_file = 'artifacts/{dump}'.format(dump=dump)
_cmd(['pg_dump',
'--format', 'custom',
'--blobs',
'--compress', '5',
'--file', dump_file,
'-N', 'public',
'qgep_prod']
)
print('::endgroup::')
dump = "qgep_{version}_structure_and_demo_data.backup".format(version=os.environ["CI_TAG"])
print(f"::group::{dump}")
print(f"Creating dump {dump}")
dump_file = f"artifacts/{dump}"
_cmd(
[
"pg_dump",
"--format",
"custom",
"--blobs",
"--compress",
"5",
"--file",
dump_file,
"-N",
"public",
"qgep_prod",
]
)
print("::endgroup::")

return dump_file

Expand All @@ -208,15 +236,16 @@ def main():
"""
Creates dumps to be attached to releases.
"""
if 'CI_TAG' not in os.environ or not os.environ['CI_TAG']:
print('No git tag: not deploying anything')
if "CI_TAG" not in os.environ or not os.environ["CI_TAG"]:
print("No git tag: not deploying anything")
return
else:
print('Creating release from tag {}'.format(os.environ['CI_TAG']))
print("Creating release from tag {}".format(os.environ["CI_TAG"]))

os.mkdir('artifacts')
os.mkdir("artifacts")
files = create_dumps()
print('Dumps created: {}'.format(', '.join(files)))
print("Dumps created: {}".format(", ".join(files)))


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion .docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Reinitialization
```bash
# later on, to reinitialize all databases
docker exec qgep init_qgep.sh
# optionally, you can specify which database to reinitialize like this
# optionally, you can specify which database to reinitialize like this
# docker exec qgep init_qgep.sh structure
```

Expand Down
2 changes: 1 addition & 1 deletion .docker/init_qgep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if [ "$1" == "release" ]; then
echo 'you must provide the release version as second argument'
exit 1
fi

echo '----------------------------------------'
echo "Installing demo data from release"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker-test-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ jobs:
matrix:
# postgres-postgis version, see available tags https://hub.docker.com/r/postgis/postgis/tags
pgis:
# WARNING: if changing this, make sure tu update `pgis_stable` below
- 13-3.2
- 14-3.2
# WARNING: if changing this, make sure tu update `pgis_stable` below
- 13-3.4
- 14-3.4
#- 15-3.3 # Postgis 3.3 requires QGEP datamodel adaptations
# See https://github.com/QGEP/QGEP/issues/825
fail-fast: false

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

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "assert version is up to date"
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ nosetests.xml
.DS_Store
.idea
temp/

Loading