Skip to content

Commit 73216a0

Browse files
authored
[COM-724] update to python 3.10 (#647)
1 parent e7716c9 commit 73216a0

File tree

11 files changed

+69
-51
lines changed

11 files changed

+69
-51
lines changed

.github/workflows/api-ci.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ jobs:
2121
- uses: actions/checkout@v2
2222
- run: "true"
2323

24-
linting:
24+
api-linting:
2525
needs: setup-job
2626
runs-on: ubuntu-24.04
2727

2828
strategy:
2929
matrix:
30-
python-version: [3.9]
30+
python-version: ["3.10"]
3131

3232
steps:
3333
- uses: actions/checkout@v2
@@ -56,7 +56,7 @@ jobs:
5656
run: |
5757
make pylint
5858
59-
testing:
59+
api-testing:
6060
needs: setup-job
6161
env:
6262
FLASK_ENV: "testing"
@@ -70,7 +70,7 @@ jobs:
7070

7171
strategy:
7272
matrix:
73-
python-version: [3.9]
73+
python-version: ["3.10"]
7474

7575
services:
7676
postgres:
@@ -81,7 +81,6 @@ jobs:
8181
POSTGRES_DB: postgres
8282
ports:
8383
- 5432:5432
84-
# needed because the postgres container does not provide a healthcheck
8584
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
8685

8786
steps:
@@ -107,26 +106,11 @@ jobs:
107106
run: |
108107
make test
109108
110-
# - name: Sets Codecov branch name
111-
# run: |
112-
# echo "CODECOV_BRANCH=PR_${{github.head_ref}}" >> $GITHUB_ENV
113-
# if: github.event_name == 'pull_request'
114-
115-
# - name: Upload coverage to Codecov
116-
# uses: codecov/codecov-action@v4
117-
# with:
118-
# flags: compliance-api
119-
# name: codecov-compliance-api
120-
# fail_ci_if_error: true
121-
# verbose: true
122-
# token: ${{ secrets.CODECOV_TOKEN }}
123-
# override_branch: ${{ env.CODECOV_BRANCH }}
124-
125-
build:
109+
api-build:
126110
runs-on: ubuntu-24.04
127111
strategy:
128112
matrix:
129-
python-version: [3.9]
113+
python-version: ["3.10"]
130114
name: Build
131115
steps:
132116
- uses: actions/checkout@v2

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This document outlines the setup instructions for both the backend and front-end
44

55
## Backend Setup in WSL
66

7-
### 1. Install Python 3.12.4
8-
Ensure Python 3.12.4 is installed in your WSL environment. Download it from the [official Python website](https://www.python.org/downloads/release/python-3124/).
7+
### 1. Install Python 3.10
8+
Ensure Python 3.10 is installed in your WSL environment. Download it from the [official Python website](https://www.python.org/downloads/release/python-3124/).
99

1010
### 2. Set Up PYTHONPATH
1111
Add the following line to your `.bashrc` or `.zshrc` file to set the `PYTHONPATH` environment variable:
@@ -29,7 +29,7 @@ make run
2929

3030
## Backend Setup on Windows
3131

32-
## Step 1: Download the Latest Python Version
32+
## Step 1: Download the Python 3.10 Version
3333

3434
1. Visit the official Python website: [Python Downloads](https://www.python.org/downloads/)
3535
2. Download and install the latest version of Python for your operating system.
@@ -79,11 +79,14 @@ make run
7979
Change to the front-end directory:
8080
cd compliance-web
8181

82-
### 2. Install Dependencies
82+
### 2. Requirements
83+
- [Node.js](https://nodejs.org/en/) 18
84+
85+
### 3. Install Dependencies
8386
Install necessary npm packages:
8487
npm install
8588

86-
### 3. Run Development Server
89+
### 4. Run Development Server
8790
Launch the development server:
8891
npm run dev
8992

compliance-api/.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ persistent=yes
5353

5454
# Minimum Python version to use for version dependent checks. Will default to
5555
# the version used to run pylint.
56-
py-version=3.9
56+
py-version=3.10
5757

5858
# Discover python modules and packages in the file system subtree.
5959
recursive=yes

compliance-api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-buster
1+
FROM python:3.10-buster
22

33
USER root
44

compliance-api/README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A compliance Python flask API application to be used as a template.
66

77
### Development Environment
88
* Install the following:
9-
- [Python](https://www.python.org/)
9+
- [Python 3.10](https://www.python.org/)
1010
- [Docker](https://www.docker.com/)
1111
- [Docker-Compose](https://docs.docker.com/compose/install/)
1212
* Install Dependencies
@@ -20,6 +20,33 @@ The development scripts for this application allow customization via an environm
2020

2121
## Commands
2222

23+
### Database Data
24+
#### Docker
25+
1. Get the postgres db backup `.dump` from current `dev` in OpenShift.
26+
2. Connect to the docker postgres db
27+
```bash
28+
psql -h localhost -p <DOCKER_POSTGRES_PORT> -U compliance -d compliance-db
29+
```
30+
3. Create the required roles app and doggen:
31+
```sql
32+
CREATE ROLE postgres;
33+
CREATE ROLE docgen;
34+
CREATE ROLE app WITH
35+
LOGIN
36+
SUPERUSER
37+
CREATEDB
38+
CREATEROLE
39+
REPLICATION
40+
BYPASSRLS;
41+
```
42+
4. Restore the db dump
43+
```bash
44+
pg_restore -h localhost -U compliance -p <DOCKER_POSTGRES_PORT> -d compliance-db -v <DEV_DB_BACKUP.DUMP>
45+
```
46+
47+
You should now be able to query the table with the restored data.
48+
49+
2350
### Development
2451

2552
The following commands support various development scenarios and needs.

compliance-api/requirements.txt

-3 KB
Binary file not shown.

compliance-api/requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-r prod.txt
33

44
coverage
5-
pylint==v2.13.8
5+
pylint==2.13.8
66
pylint-flask
77
pytest
88
pytest-cov

compliance-api/requirements/prod.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ python-dotenv
1212
psycopg2-binary
1313
marshmallow-sqlalchemy==1.0.0
1414
marshmallow_enum
15+
marshmallow==3.18.0
1516
jsonschema
1617
requests
1718
itsdangerous
1819
werkzeug
1920
sqlalchemy-utils
2021
Flask-Caching
2122
sqlalchemy
22-
secure
23+
secure>=1.0.0
2324
python-dotenv
2425
requests
2526
flask_cors

compliance-api/setup.cfg

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,20 @@ good-names=
6464
id
6565

6666
[pylint]
67-
ignore=migrations,test
67+
ignore=migrations,test,venv,htmlcov,.pytest_cache,__pycache__
6868
max_line_length=120
6969
notes=FIXME,XXX,TODO
7070
ignored-modules=flask_sqlalchemy,sqlalchemy,SQLAlchemy,alembic,scoped_session
7171
ignored-classes=scoped_session
72-
generated-members=Error # allows dynamically generated member references
72+
generated-members=Error
7373
min-similarity-lines=15
74-
disable=C0301,W0511
74+
disable=C0301,W0511,R0801,C0114,C0115,C0116,R0902,R0913,R0914,R0915
7575
load-plugins=pylint_flask
7676
min-public-methods=1
77+
jobs=5
78+
persistent=yes
79+
reports=no
80+
score=no
7781

7882
[isort]
7983
line_length = 120

compliance-api/src/compliance_api/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@
2424

2525

2626
# Security Response headers
27-
csp = (
28-
secure.ContentSecurityPolicy()
27+
secure_headers = secure.Secure(
28+
csp=secure.ContentSecurityPolicy()
2929
.default_src("'self'")
3030
.script_src("'self' 'unsafe-inline'")
3131
.style_src("'self' 'unsafe-inline'")
3232
.img_src("'self' data:")
3333
.object_src("'self'")
34-
.connect_src("'self'")
35-
)
36-
37-
hsts = secure.StrictTransportSecurity().include_subdomains().preload().max_age(31536000)
38-
referrer = secure.ReferrerPolicy().no_referrer()
39-
cache_value = secure.CacheControl().no_store().max_age(0)
40-
xfo_value = secure.XFrameOptions().deny()
41-
secure_headers = secure.Secure(
42-
csp=csp, hsts=hsts, referrer=referrer, cache=cache_value, xfo=xfo_value
34+
.connect_src("'self'"),
35+
hsts=secure.StrictTransportSecurity()
36+
.include_subdomains()
37+
.preload()
38+
.max_age(31536000),
39+
referrer=secure.ReferrerPolicy().no_referrer(),
40+
cache=secure.CacheControl().no_store().max_age(0),
41+
xfo=secure.XFrameOptions().deny()
4342
)
4443

4544

@@ -111,7 +110,7 @@ def set_secure_headers(response):
111110
"""Set CORS headers for security."""
112111
# if random.random() < 0.1: # Only run GC 10% of the time
113112
# gc.collect()
114-
secure_headers.framework.flask(response)
113+
secure_headers.set_headers(response)
115114
response.headers.add("Cross-Origin-Resource-Policy", "*")
116115
response.headers["Cross-Origin-Opener-Policy"] = "*"
117116
response.headers["Cross-Origin-Embedder-Policy"] = "unsafe-none"

0 commit comments

Comments
 (0)