Skip to content

Commit 903602f

Browse files
authored
Merge pull request #1776 from GSA/main
06/12/25 Production Deploy
2 parents 29bee35 + 26b94b8 commit 903602f

File tree

31 files changed

+1307
-962
lines changed

31 files changed

+1307
-962
lines changed

.ds.baseline

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,6 @@
127127
}
128128
],
129129
"results": {
130-
".github/actions/deploy-proxy/action.yml": [
131-
{
132-
"type": "Hex High Entropy String",
133-
"filename": ".github/actions/deploy-proxy/action.yml",
134-
"hashed_secret": "a6c13f5da3788e8d654cd24001dc79a238723248",
135-
"is_verified": false,
136-
"line_number": 18,
137-
"is_secret": false
138-
}
139-
],
140130
".github/workflows/checks.yml": [
141131
{
142132
"type": "Secret Keyword",
@@ -161,15 +151,15 @@
161151
"filename": ".github/workflows/daily_checks.yml",
162152
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
163153
"is_verified": false,
164-
"line_number": 71,
154+
"line_number": 63,
165155
"is_secret": false
166156
},
167157
{
168158
"type": "Basic Auth Credentials",
169159
"filename": ".github/workflows/daily_checks.yml",
170160
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
171161
"is_verified": false,
172-
"line_number": 87,
162+
"line_number": 79,
173163
"is_secret": false
174164
}
175165
],
@@ -305,7 +295,7 @@
305295
"filename": "tests/app/service/test_rest.py",
306296
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
307297
"is_verified": false,
308-
"line_number": 1285,
298+
"line_number": 1282,
309299
"is_secret": false
310300
}
311301
],
@@ -384,5 +374,5 @@
384374
}
385375
]
386376
},
387-
"generated_at": "2025-06-02T13:22:36Z"
377+
"generated_at": "2025-06-09T16:07:54Z"
388378
}

.github/actions/deploy-proxy/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
default: https://github.com/GSA-TTS/cg-egress-proxy.git
1616
proxy_version:
1717
description: git ref to be deployed
18-
default: 1500c67157c1a7a6fbbda7a2de172b3d0a67e703
18+
default: main
1919
runs:
2020
using: composite
2121
steps:

.github/actions/setup-project/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ runs:
99
sudo apt-get update \
1010
&& sudo apt-get install -y --no-install-recommends \
1111
libcurl4-openssl-dev
12-
- name: Set up Python 3.12.3
12+
- name: Set up Python 3.12.2
1313
uses: actions/setup-python@v4
1414
with:
15-
python-version: "3.12.3"
15+
python-version: "3.12.2"
1616
- name: Install poetry
1717
shell: bash
1818
run: pip install poetry==2.1.3

.github/workflows/checks.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,7 @@ jobs:
8787
- uses: actions/checkout@v4
8888
- uses: ./.github/actions/setup-project
8989
- name: Create requirements.txt
90-
run: poetry export --output requirements_tmp.txt --without-hashes
91-
- name: Filter requirements.txt
92-
run: grep -v "oscrypto@ git" requirements_tmp.txt > requirements.txt
93-
- name: Verify requirements.txt
94-
run: ls -l requirements.txt
95-
- name: Print requirements.txt
96-
run: |
97-
echo "Contents of requirements.txt:"
98-
cat requirements.txt
90+
run: poetry export --output requirements.txt
9991
- uses: pypa/gh-action-pip-audit@v1.1.0
10092
with:
10193
inputs: requirements.txt

.github/workflows/daily_checks.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@ jobs:
2626
- uses: actions/checkout@v4
2727
- uses: ./.github/actions/setup-project
2828
- name: Create requirements.txt
29-
run: poetry export --output requirements_tmp.txt --without-hashes
30-
- name: Filter requirements.txt
31-
run: grep -v "oscrypto@ git" requirements_tmp.txt > requirements.txt
32-
- name: Verify requirements.txt
33-
run: ls -l requirements.txt
34-
- name: Print requirements.txt
35-
run: |
36-
echo "Contents of requirements.txt:"
37-
cat requirements.txt
29+
run: poetry export --output requirements.txt
3830
- uses: pypa/gh-action-pip-audit@v1.1.0
3931
with:
4032
inputs: requirements.txt

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ test: ## Run tests and create coverage report
108108
poetry run coverage report -m --fail-under=93
109109
poetry run coverage html -d .coverage_cache
110110

111+
.PHONY: test-debug
112+
test-debug:
113+
poetry run pytest --pdb -x
114+
111115
.PHONY: py-lock
112116
py-lock: ## Syncs dependencies and updates lock file without performing recursive internal updates
113117
poetry sync --no-root

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You will need the following items:
4040
This project currently works with these major versions of the following main
4141
components:
4242

43-
- Python 3.12.x
43+
- Python 3.13.x
4444
- PostgreSQL 15.x (version 12.x is used in the hosted environments)
4545

4646
These instructions will walk you through how to set your machine up with all of
@@ -173,12 +173,12 @@ session to make the changes take effect.
173173
Now we're ready to install the Python version we need with `pyenv`, like so:
174174

175175
```sh
176-
pyenv install 3.12
176+
pyenv install 3.13
177177
```
178178

179-
This will install the latest version of Python 3.12.
179+
This will install the latest version of Python 3.13.
180180

181-
_NOTE: This project currently runs on Python 3.12.x._
181+
_NOTE: This project currently runs on Python 3.13.x._
182182

183183
#### Python Dependency Installation
184184

@@ -311,10 +311,10 @@ If you're upgrading an existing project to a newer version of Python, you can
311311
follow these steps to get yourself up-to-date.
312312

313313
First, use `pyenv` to install the newer version of Python you'd like to use;
314-
we'll use `3.12` in our example here since we recently upgraded to this version:
314+
we'll use `3.13` in our example here since we recently upgraded to this version:
315315

316316
```sh
317-
pyenv install 3.12
317+
pyenv install 3.13
318318
```
319319

320320
Next, delete the virtual environment you previously had set up. If you followed

app/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from celery import Celery, Task, current_task
1212
from flask import current_app, g, has_request_context, jsonify, make_response, request
1313
from flask.ctx import has_app_context
14-
from flask_marshmallow import Marshmallow
1514
from flask_migrate import Migrate
1615
from flask_socketio import SocketIO
1716
from flask_sqlalchemy import SQLAlchemy as _SQLAlchemy
@@ -86,7 +85,6 @@ def apply_driver_hacks(self, app, info, options):
8685
}
8786
)
8887
migrate = Migrate()
89-
ma = Marshmallow()
9088
notify_celery = NotifyCelery()
9189
aws_ses_client = AwsSesClient()
9290
aws_ses_stub_client = AwsSesStubClient()
@@ -131,7 +129,6 @@ def create_app(application):
131129
request_helper.init_app(application)
132130
db.init_app(application)
133131
migrate.init_app(application, db=db)
134-
ma.init_app(application)
135132
zendesk_client.init_app(application)
136133
logging.init_app(application)
137134
aws_sns_client.init_app(application)

app/aws/s3.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from app import job_cache, job_cache_lock
1313
from app.clients import AWS_CLIENT_CONFIG
14+
15+
# from app.service.rest import get_service_by_id
1416
from notifications_utils import aware_utcnow
1517

1618
FILE_LOCATION_STRUCTURE = "service-{}-notify/{}.csv"
@@ -162,6 +164,34 @@ def cleanup_old_s3_objects():
162164
current_app.logger.exception(
163165
"#delete-old-s3-objects An error occurred while cleaning up old s3 objects",
164166
)
167+
try:
168+
response = s3_client.list_objects_v2(Bucket=bucket_name)
169+
170+
service_ids = set()
171+
while True:
172+
for obj in response.get("Contents", []):
173+
# Get the service id out of the upload key
174+
key = obj["Key"]
175+
object_arr = key.split("/")
176+
service_id = object_arr[0]
177+
service_id = service_id.replace("-service-notify", "")
178+
service_ids.add(service_id)
179+
if "NextContinuationToken" in response:
180+
response = s3_client.list_objects_v2(
181+
Bucket=bucket_name,
182+
ContinuationToken=response["NextContinuationToken"],
183+
)
184+
else:
185+
break
186+
retained_services = []
187+
for service_id in service_ids:
188+
retained_services.append(service_id)
189+
190+
return service_ids
191+
except Exception as error:
192+
current_app.logger.exception(
193+
f"#delete-old-s3-objects An error occurred while cleaning up old s3 objects: {str(error)}"
194+
)
165195

166196

167197
def get_job_id_from_s3_object_key(key):

app/celery/tasks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
2020
from app.dao.service_inbound_api_dao import get_service_inbound_api_for_service
2121
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
22+
from app.dao.services_dao import dao_fetch_service_by_id
2223
from app.dao.templates_dao import dao_get_template_by_id
2324
from app.enums import JobStatus, KeyType, NotificationType
2425
from app.errors import TotalRequestsError
@@ -496,7 +497,15 @@ def clean_job_cache():
496497

497498
@notify_celery.task(name="delete-old-s3-objects")
498499
def delete_old_s3_objects():
499-
s3.cleanup_old_s3_objects()
500+
501+
existing_service_ids = s3.cleanup_old_s3_objects()
502+
service_names = []
503+
for service_id in existing_service_ids:
504+
service = dao_fetch_service_by_id(service_id)
505+
service_names.append(service.name)
506+
current_app.logger.info(
507+
f"#delete-old-s3-objects Services with retained csvs: {service_names}"
508+
)
500509

501510

502511
@notify_celery.task(name="process-incomplete-jobs")

0 commit comments

Comments
 (0)