Skip to content

Commit 1db4d52

Browse files
committed
A bit of renovation
1 parent 88d119a commit 1db4d52

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,15 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
steps:
1212
- uses: actions/[email protected]
13-
- name: Set up Python 3.7
13+
- name: Set up Python 3.10
1414
uses: actions/[email protected]
1515
with:
16-
python-version: 3.7
17-
- name: Get pip cache dir
18-
id: pip-cache-dir
19-
run: echo "::set-output name=dir::$(pip cache dir)"
20-
- name: Cache pip
21-
uses: actions/[email protected]
22-
with:
23-
path: ${{ steps.pip-cache-dir.outputs.dir }}
24-
key: pip|3.7|${{ hashFiles('setup.py') }}
16+
python-version: "3.10"
17+
cache: pip
18+
cache-dependency-path: setup.py
2519
- name: Install dependencies
2620
run: |
2721
python -m pip install -U pip wheel setuptools

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-22.04
1212
strategy:
1313
matrix:
14-
python-version: [3.7, 3.9]
14+
python-version: ["3.8", "3.10"]
1515
steps:
1616
- uses: actions/[email protected]
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
pytest --cov-branch --cov-report xml --cov bip tests
3030
- name: Coveralls report
31-
if: matrix.python-version == 3.7
31+
if: matrix.python-version == "3.10"
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def find_version(*where):
105105
'Natural Language :: Polish',
106106
'Operating System :: POSIX :: Linux',
107107
'Programming Language :: Python :: 3 :: Only',
108-
'Programming Language :: Python :: 3.7',
109108
'Programming Language :: Python :: 3.8',
109+
'Programming Language :: Python :: 3.9',
110+
'Programming Language :: Python :: 3.10',
110111
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Content Management System',
111112
],
112113
install_requires=base_reqs,
@@ -120,5 +121,5 @@ def find_version(*where):
120121
'bip=bip.cli:main',
121122
]
122123
},
123-
python_requires='~=3.7',
124+
python_requires='~=3.8',
124125
)

src/bip/app.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def make_app() -> Application:
4949
if flask_environment != 'dev':
5050
app.logger.info(f'BIP application running in mode {flask_environment}')
5151
configure_app(app)
52+
prepare_app(app)
5253
# setup keyring for headless environments
5354
if flask_environment in ('production', 'test'):
5455
keyring.set_keyring(CryptFileKeyring())
@@ -143,23 +144,28 @@ def configure_database(_app: Application) -> None:
143144
db.init(db_name, **kw)
144145

145146

147+
def prepare_app(app: Application) -> None:
148+
"""Former ``before_first_request`` hook, now standalone function.
149+
150+
:param app: application object
151+
:type app: Application
152+
"""
153+
if os.getenv('FLASK_ENV') == 'test' and not os.getenv('SITE_JSON'):
154+
site = test_site()
155+
else:
156+
site_object_path = os.path.abspath(os.environ['SITE_JSON'])
157+
with open(site_object_path) as fp:
158+
site = Site.from_json(fp.read())
159+
app.site = app.jinja_env.globals['site'] = site
160+
161+
146162
def configure_hooks(app: Application) -> None:
147163
"""Set up application lifetime hooks.
148164
149165
:param app: application object
150166
:type app: Application
151167
"""
152168

153-
@app.before_first_request
154-
def load_site_objects() -> None:
155-
if os.getenv('FLASK_ENV') == 'test' and not os.getenv('SITE_JSON'):
156-
site = test_site()
157-
else:
158-
site_object_path = os.path.abspath(os.environ['SITE_JSON'])
159-
with open(site_object_path) as fp:
160-
site = Site.from_json(fp.read())
161-
app.site = app.jinja_env.globals['site'] = site
162-
163169
@app.before_request
164170
def db_connect() -> None:
165171
db.connect(reuse_if_open=True)

0 commit comments

Comments
 (0)