-
Notifications
You must be signed in to change notification settings - Fork 19
/
config.yml
769 lines (736 loc) · 31.9 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# Python CircleCI 2.1 configuration file
# Circle docs https://circleci.com/docs/2.0/language-python/
# Set deployment variables in CircleCI as environment variables
version: 2.1
# Snippet for installing CloudFoundry CLI version 8
install-cf8: &install-cf8
run:
name: Install CF8
command: |
curl -A "" -L -o cf8.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
sudo dpkg -i cf8.deb
rm cf8.deb
cf8 api https://api.fr.cloud.gov
install-python-dev-dependencies: &install-python-dev-dependencies
run:
name: Install python dev dependencies
command: |
pip install -U pip
pip install pipenv
pipenv install --dev
pipenv run python -m playwright install
wait-for-tasks: &wait-for-tasks
# Each task starts a container, which counts towards our RAM limit
# This makes sure we wait for them to complete before running new ones.
# At the time of writing, our tasks don't take more than 60 seconds to complete on production.
run:
name: Wait for maintenance tasks to complete
command: |
sleep 120 # (Two minutes)
jobs:
build_and_test: # runs not using Workflows must have a `build` job as entry point
# directory where steps are run
working_directory: ~/code
docker:
# CircleCI Python images available at: https://hub.docker.com/r/cimg/python/
- image: cimg/python:3.12.5-browsers
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
POSTGRES_ANALYTICS_USER: analytics
POSTGRES_ANALYTICS_PASSWORD: analytics_password
# CircleCI PostgreSQL images available at: https://hub.docker.com/_/postgres
- image: postgres:12.15-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: password
steps:
- checkout
# Removing chache for now, we either need to build our image or move the cache location
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
- restore_cache:
keys:
- node-v4-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "gulpfile.js" }}
# - node-v4-{{ .Branch }}-
# - node-v4-
- run:
name: Install gettext
command: sudo apt-get update && sudo apt-get install -yqq gettext
- run:
name: Node install, generate CSS
command: |
npm ci
node node_modules/gulp/bin/gulp build
- save_cache:
paths:
- /home/circleci/code/node_modules/
key: node-v4-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "gulpfile.js" }}
- restore_cache:
keys:
- pip-packages-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
# - pip-packages-v4-{{ .Branch }}-
# - pip-packages-v4-
- *install-python-dev-dependencies
- run:
name: Migrate the database
command: pipenv run crt_portal/manage.py migrate
- save_cache:
paths:
- /home/circleci/code/.venv # this path depends on where pipenv creates a virtualenv
key: pip-packages-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
name: Run prettier code formatting check
command: npm run lint:check
- run:
name: Run unit tests & check coverage
command: |
pipenv run coverage run --source='crt_portal' crt_portal/manage.py test --settings=crt_portal.test_settings shortener tms features cts_forms
pipenv run coverage report --fail-under=80 -m
- run:
name: Run bandit (Python security) tests
command: |
pipenv run bandit -r crt_portal/ --exclude cts_forms/tests
- run:
name: Run flake8 test for Python code style
command: |
pipenv run flake8
- run:
name: add or update response templates
command: |
pipenv run crt_portal/manage.py update_response_templates
- run:
name: add or update analytics notebooks examples
command: |
pipenv run crt_portal/manage.py update_ipynb_examples
- run:
name: compile messages for internationalization
command: |
pipenv run crt_portal/manage.py compilemessages
- run:
name: create mock reports
command: |
pipenv run crt_portal/manage.py create_mock_reports 100
- run:
name: save a sample of reports as an artifact
command: |
PGPASSWORD="$POSTGRES_PASSWORD" pg_dump -h localhost -p 5432 -d circle_test -U root --no-owner --no-privileges -t '(geocoding_|cts_forms_|tms_|shortener_)*' -t django_content_type -t actstream_action > example.sql
- store_artifacts:
path: example.sql
destination: example.sql
- run:
name: run server for tests
environment:
DEBUG: true
command: |
# create pa11y_tester
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_user('pa11y_tester', 'admin@myproject.com', '$PA11Y_PASSWORD')" | pipenv run crt_portal/manage.py shell
# runserver
pipenv run crt_portal/manage.py runserver 0.0.0.0:8000
background: true
- run:
name: Run pa11y-ci accessibility check
environment:
PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
command: |
curl --retry-delay 5 --retry 10 --retry-all-errors http://localhost:8000
npm run test:a11y-without-report
- store_artifacts:
path: ./pa11y-screenshots
- run:
name: E2E tests
environment:
PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
command: pipenv run pytest crt_portal/cts_forms/tests/integration/*.py --base-url=http://localhost:8000
- run:
name: Create a test user for e2e tests that require authentication.
command: pipenv run crt_portal/manage.py create_test_user
- run:
name: Authed E2E tests
environment:
PUPPETEER_EXECUTABLE_PATH: /usr/bin/google-chrome
command: pipenv run pytest crt_portal/cts_forms/tests/integration_authed/*.py --base-url=http://localhost:8000
- store_artifacts:
path: ./e2e-screenshots
e2e-test-dev:
description: Runs E2E tests against dev
working_directory: ~/code
docker:
# CircleCI Python images available at: https://hub.docker.com/r/cimg/python/
- image: cimg/python:3.12.5-browsers
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- *install-python-dev-dependencies
- run:
name: E2E tests
command: pipenv run pytest crt_portal/cts_forms/tests/integration/*.py --base-url=https://crt-portal-django-dev.app.cloud.gov
e2e-test-stage:
description: Runs E2E tests against stage
working_directory: ~/code
docker:
# CircleCI Python images available at: https://hub.docker.com/r/cimg/python/
- image: cimg/python:3.12.5-browsers
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- *install-python-dev-dependencies
- run:
name: E2E tests
command: pipenv run pytest crt_portal/cts_forms/tests/integration/*.py --base-url=https://crt-portal-django-stage.app.cloud.gov
# owasp scans on live sites
# NOTE: These don't use docker or the circleci base image because, as of writing, circleci docker-in-docker doesn't support mounting volumes.
owasp-scan-dev:
machine:
image: ubuntu-2204:2024.01.1
working_directory: ~/code
steps:
- checkout
- run:
name: Pull owasp zap docker image and run scan
command: |
docker run -v $(pwd):/zap/wrk/:rw -t softwaresecurityproject/zap-stable zap-baseline.py -t https://crt-portal-django-dev.app.cloud.gov/report/ -c .circleci/zap.conf --autooff -z "-config rules.cookie.ignorelist=django_language"
owasp-scan-stage:
machine:
image: ubuntu-2204:2024.01.1
working_directory: ~/code
steps:
- checkout
- run:
name: Pull owasp zap docker image and run scan
command: |
docker run -v $(pwd):/zap/wrk/:rw -t softwaresecurityproject/zap-stable zap-baseline.py -t https://crt-portal-django-stage.app.cloud.gov/report/ -c .circleci/zap.conf --autooff -z "-config rules.cookie.ignorelist=django_language"
owasp-scan-prod:
machine:
image: ubuntu-2204:2024.01.1
working_directory: ~/code
steps:
- checkout
- run:
name: Pull owasp zap docker image and run scan
command: |
docker run -v $(pwd):/zap/wrk/:rw -t softwaresecurityproject/zap-stable zap-baseline.py -t https://civilrights.justice.gov/report -c .circleci/zap.conf --autooff -z "-config rules.cookie.ignorelist=django_language"
# deployments
deploy-dev:
working_directory: ~/code
docker:
# standard docker python image
- image: python:3.12.5
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
CF_MANIFEST: manifest_dev.yaml
CF_STAGING_TIMEOUT: 40
CF_STARTUP_TIMEOUT: 10
CF_SPACE: dev
# CircleCI PostgreSQL images available at: https://hub.docker.com/_/postgres
- image: postgres:12.15-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: password
steps:
- checkout
# removing as we deal with caching problem
# - restore_cache:
# # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
# key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
- run:
name: Node install
command: |
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
apt-get update && \
apt-get install -yqq nodejs && \
rm -rf /var/lib/apt/lists/*
npm ci --production
node node_modules/gulp/bin/gulp build-css
node node_modules/gulp/bin/gulp build-js
- run:
name: install cf8
command: |
curl -A "" -L -o cf8.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
dpkg -i cf8.deb
rm cf8.deb
cf8 api https://api.fr.cloud.gov
# - save_cache: # cache Python and Node dependencies using checksum of Pipfile and package.json as the cache-key
# key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
# paths:
# - ".venv"
# - "/usr/local/bin"
# - "/usr/local/lib/python3.8/site-packages"
- run:
name: Login to cloud.gov
command: cf8 login -u ${CRT_USERNAME_DEV} -p ${CRT_PASSWORD_DEV} -o doj-crtportal -s ${CF_SPACE}
- acquire-lock:
app: crt-portal-django
- run:
name: Deploy clamav-rest to dev
# Hide possibly sensitive build information, while still producing output to avoid triggering a no_output_timeout
command: cf8 push clamav-rest --strategy rolling -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-django to dev
no_output_timeout: 20m
command: cf8 push crt-portal-django --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-jupyter to dev
no_output_timeout: 20m
command: cf8 push crt-portal-jupyter --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- release-lock:
app: crt-portal-django
deploy-stage:
working_directory: ~/code
docker:
- image: python:3.12.5
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
CF_MANIFEST: manifest_staging.yaml
CF_STAGING_TIMEOUT: 40
CF_STARTUP_TIMEOUT: 10
CF_SPACE: staging
# CircleCI PostgreSQL images available at: https://hub.docker.com/_/postgres
- image: postgres:12.15-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: password
steps:
- checkout
- restore_cache:
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
- run:
name: Node install
command: |
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
apt-get update && \
apt-get install -yqq nodejs && \
rm -rf /var/lib/apt/lists/*
npm ci --production
node node_modules/gulp/bin/gulp build-css
node node_modules/gulp/bin/gulp build-js
# database will be migrated in cloud.gov
- run:
name: install cf8
command: |
curl -A "" -L -o cf8.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
dpkg -i cf8.deb
rm cf8.deb
cf8 api https://api.fr.cloud.gov
- save_cache: # cache Python and Node dependencies using checksum of Pipfile and package.json as the cache-key
key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
paths:
- '.venv'
- '/usr/local/bin'
- '/usr/local/lib/python3.12/site-packages'
- run:
name: Login to cloud.gov
command: cf8 login -u ${CRT_USERNAME_STAGE} -p ${CRT_PASSWORD_STAGE} -o doj-crtportal -s ${CF_SPACE}
- run:
name: Deploy clamav-rest to staging
command: cf8 push clamav-rest --strategy rolling -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-django to staging
no_output_timeout: 20m
command: cf8 push crt-portal-django --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-jupyter to staging
no_output_timeout: 20m
command: cf8 push crt-portal-jupyter --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
deploy-prod:
working_directory: ~/code
docker:
# CircleCI Python images available at: https://hub.docker.com/r/cimg/python/
- image: python:3.12.5
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
CF_MANIFEST: manifest_prod.yaml
CF_STAGING_TIMEOUT: 40
CF_STARTUP_TIMEOUT: 10
CF_SPACE: prod
# CircleCI PostgreSQL images available at: https://hub.docker.com/_/postgres
- image: postgres:12.15-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: password
steps:
- checkout
- restore_cache:
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
- run:
name: Node install
command: |
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
apt-get update && \
apt-get install -yqq nodejs && \
rm -rf /var/lib/apt/lists/*
npm ci --production
node node_modules/gulp/bin/gulp build-css
node node_modules/gulp/bin/gulp build-js
# database will be migrated in cloud.gov
- run:
name: install cf8
command: |
curl -A "" -L -o cf8.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
dpkg -i cf8.deb
rm cf8.deb
cf8 api https://api.fr.cloud.gov
- save_cache: # cache Python and Node dependencies using checksum of Pipfile and package.json as the cache-key
key: deps-v4-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum "package.json" }}
paths:
- '.venv'
- '/usr/local/bin'
- '/usr/local/lib/python3.12/site-packages'
- run:
name: Login to cloud.gov
command: cf8 login -u ${CRT_USERNAME_PROD} -p ${CRT_PASSWORD_PROD} -o doj-crtportal -s ${CF_SPACE}
- run:
name: Deploy clamav-rest to production
command: cf8 push clamav-rest --strategy rolling -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-django to production
no_output_timeout: 20m
command: cf8 push crt-portal-django --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
- run:
name: Deploy crt-portal-jupyter to production
no_output_timeout: 20m
command: cf8 push crt-portal-jupyter --strategy rolling --app-start-timeout 180 -f ${CF_MANIFEST} | sed 's/.*/Use cf logs to view build information/'
prod-maintenance-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: prod
steps:
# Install cloud foundry tools
- *install-cf8
# login into cloud.gov prod space
- run:
name: Login to cloud.gov Production
command: cf login -u ${CRT_USERNAME_PROD} -p ${CRT_PASSWORD_PROD} -o doj-crtportal -s ${CF_SPACE}
# Refresh the trend view task in prod deactivated
# - run:
# name: Refresh trends view
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py refresh_trends" --name refresh-trends -m 512M -k 7G
# Mark by_repeat_writer true on reports that were submitted by repeat writers or which have violation summaries identical to other reports
- run:
name: Flag reports submitted by repeat writers or that have violation summaries identical to other reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py flag_repeat_writers" --name flag-repeat-writers -m 512M -k 7G
- *wait-for-tasks
# Clear expired sessions in staging session table
- run:
name: clearsessions management command
command: cf run-task crt-portal-django -c "python crt_portal/manage.py clearsessions" --name clear-sessions -m 512M -k 7G
- *wait-for-tasks
#
# - run:
# name: generate yearly reports command
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py generate_yearly_reports" --name generate-yearly-reports -m 512M -k 7G
- run:
name: generate repeat_writer_info
command: cf run-task crt-portal-django -c "python crt_portal/manage.py generate_repeat_writer_info" --name generate-repeat-writer-info -m 512M -k 7G
- *wait-for-tasks
- run:
name: check saved searches
command: cf run-task crt-portal-django -c "python crt_portal/manage.py check_saved_searches" --name process-reports -m 512M -k 7G
- *wait-for-tasks
- run:
name: send scheduled notifications
command: cf run-task crt-portal-django -c "python crt_portal/manage.py send_scheduled_notifications" --name send-scheduled-notifications -m 512M -k 7G
- *wait-for-tasks
- run:
name: dispose of reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py dispose_reports" --name dispose-reports -m 512M -k 7G
staging-maintenance-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: staging
steps:
# Install cloud foundry tools
- *install-cf8
# login to Staging Cloud.gov space
- run:
name: Login to cloud.gov Staging
command: cf login -u ${CRT_USERNAME_STAGE} -p ${CRT_PASSWORD_STAGE} -o doj-crtportal -s ${CF_SPACE}
# Refresh the form letters sent view in staging
- run:
name: Refresh form letters sent view
command: cf run-task crt-portal-django -c "python crt_portal/manage.py refresh_form_letters_sent_view" --name refresh-form-letters-sent-view -m 512M -k 5G
- *wait-for-tasks
# Mark by_repeat_writer true on reports that were submitted by repeat writers or which have violation summaries identical to other reports
- run:
name: Flag reports submitted by repeat writers or that have violation summaries identical to other reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py flag_repeat_writers" --name flag-repeat-writers -m 512M -k 5G
- *wait-for-tasks
# Refresh the trend view in staging deactivated
# - run:
# name: Refresh trends view
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py refresh_trends" --name refresh-trends -m 512M -k 5G
# Clear expired sessions in staging session table
- run:
name: clearsessions management command
command: cf run-task crt-portal-django -c "python crt_portal/manage.py clearsessions" --name clear-sessions -m 512M -k 5G
- *wait-for-tasks
# - run:
# name: generate yearly reports command
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py generate_yearly_reports" --name generate-yearly-reports -m 512M -k 5G
- run:
name: generate repeat_writer_info
command: cf run-task crt-portal-django -c "python crt_portal/manage.py generate_repeat_writer_info" --name generate-repeat-writer-info -m 512M -k 5G
- *wait-for-tasks
- run:
name: check saved searches
command: cf run-task crt-portal-django -c "python crt_portal/manage.py check_saved_searches" --name process-reports -m 512M -k 7G
- *wait-for-tasks
- run:
name: send scheduled notifications
command: cf run-task crt-portal-django -c "python crt_portal/manage.py send_scheduled_notifications" --name send-scheduled-notifications -m 512M -k 7G
- *wait-for-tasks
- run:
name: dispose of reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py dispose_reports" --name dispose-reports -m 512M -k 7G
dev-maintenance-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: dev
steps:
# Install cloud foundry tools
- *install-cf8
# login to Cloud.gov dev space
- run:
name: Login to cloud.gov Dev
command: cf login -u ${CRT_USERNAME_DEV} -p ${CRT_PASSWORD_DEV} -o doj-crtportal -s ${CF_SPACE}
# Refresh the form letters sent view in dev
- run:
name: Refresh form letters sent view
command: cf run-task crt-portal-django -c "python crt_portal/manage.py refresh_form_letters_sent_view" --name refresh-form-letters-sent-view -m 512M -k 5G
- *wait-for-tasks
# Mark by_repeat_writer true on reports that were submitted by repeat writers or which have violation summaries identical to other reports
- run:
name: Flag reports submitted by repeat writers or that have violation summaries identical to other reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py flag_repeat_writers" --name flag-repeat-writers -m 512M -k 5G
- *wait-for-tasks
# Refresh the trend view in dev deactivated
# - run:
# name: Refresh trends view
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py refresh_trends" --name refresh-trends -m 512M -k 5G
# Clear expired sessions in staging session table
- run:
name: clearsessions management command
command: cf run-task crt-portal-django -c "python crt_portal/manage.py clearsessions" --name clear-sessions -m 512M -k 5G
- *wait-for-tasks
# - run:
# name: generate yearly reports command
# command: cf run-task crt-portal-django -c "python crt_portal/manage.py generate_yearly_reports" --name generate-yearly-reports -m 512M -k 5G
- run:
name: check saved searches
command: cf run-task crt-portal-django -c "python crt_portal/manage.py check_saved_searches" --name process-reports -m 512M -k 7G
- *wait-for-tasks
- run:
name: send scheduled notifications
command: cf run-task crt-portal-django -c "python crt_portal/manage.py send_scheduled_notifications" --name send-scheduled-notifications -m 512M -k 7G
- *wait-for-tasks
- run:
name: dispose of reports
command: cf run-task crt-portal-django -c "python crt_portal/manage.py dispose_reports" --name dispose-reports -m 512M -k 7G
dev-jupyter-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: dev
steps:
# Install cloud foundry tools
- *install-cf8
# login to Cloud.gov dev space
- run:
name: Login to cloud.gov Dev
command: cf login -u ${CRT_USERNAME_DEV} -p ${CRT_PASSWORD_DEV} -o doj-crtportal -s ${CF_SPACE}
- run:
name: run scheduled notebooks
command: cf ssh crt-portal-jupyter -c 'export LD_LIBRARY_PATH="$HOME/deps/0/lib:$HOME/deps/1/lib:$HOME/deps/2/lib" && export PATH="$PATH:$HOME/deps/2/python/bin/" && cd /home/vcap/app && python run_scheduled_refresh.py'
staging-jupyter-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: staging
steps:
# Install cloud foundry tools
- *install-cf8
# login to Cloud.gov stage space
- run:
name: Login to cloud.gov Staging
command: cf login -u ${CRT_USERNAME_STAGE} -p ${CRT_PASSWORD_STAGE} -o doj-crtportal -s ${CF_SPACE}
- run:
name: run scheduled notebooks
command: cf ssh crt-portal-jupyter -c 'export LD_LIBRARY_PATH="$HOME/deps/0/lib:$HOME/deps/1/lib:$HOME/deps/2/lib" && export PATH="$PATH:$HOME/deps/2/python/bin/" && cd /home/vcap/app && python run_scheduled_refresh.py'
prod-jupyter-tasks:
docker:
# Use CircleCI convenience base image since we only need
# CloudFoundry CLI
- image: cimg/base:2024.02
environment:
- CF_SPACE: prod
steps:
# Install cloud foundry tools
- *install-cf8
# login to Cloud.gov prod space
- run:
name: Login to cloud.gov Prod
command: cf login -u ${CRT_USERNAME_PROD} -p ${CRT_PASSWORD_PROD} -o doj-crtportal -s ${CF_SPACE}
- run:
name: run scheduled notebooks
command: cf ssh crt-portal-jupyter -c 'export LD_LIBRARY_PATH="$HOME/deps/0/lib:$HOME/deps/1/lib:$HOME/deps/2/lib" && export PATH="$PATH:$HOME/deps/2/python/bin/" && cd /home/vcap/app && python run_scheduled_refresh.py'
commands:
acquire-lock:
description: 'Make sure nothing else is deploying.'
parameters:
app:
type: enum
enum: ['clamav-rest', 'crt-portal-django']
steps:
- run:
name: 'Wait for other deployments to finish'
no_output_timeout: 2h
command: |
. env-helpers.sh << parameters.app >>
cf_wait_for_lock CCI_NEXT_TICKET CCI_SERVING_TICKET
release-lock:
description: "Indicate that we're done using cloudfoundry, allowing the next process in line to use it."
parameters:
app:
type: enum
enum: ['clamav-rest', 'crt-portal-django']
steps:
- run:
name: 'Let other deployments start'
command: |
. env-helpers.sh << parameters.app >>
serving="$(cf_increment_env CCI_SERVING_TICKET)"
printf "Lock released - now serving ticket $((serving + 1))\n"
workflows:
build-test-deploy:
jobs:
- build_and_test
- owasp-scan-dev:
filters:
branches:
only: /^release.*/
- owasp-scan-stage:
filters:
branches:
only: master
- owasp-scan-prod:
requires:
- deploy-prod
filters:
branches:
only: master
- deploy-dev:
requires:
- build_and_test
filters:
branches:
only: develop
- deploy-stage:
requires:
- owasp-scan-dev
- build_and_test
filters:
branches:
only: /^release.*/
- deploy-prod:
requires:
- owasp-scan-stage
- build_and_test
filters:
branches:
only: master
- e2e-test-dev:
requires:
- deploy-dev
filters:
branches:
only: develop
- e2e-test-stage:
requires:
- deploy-stage
filters:
branches:
only: /^release.*/
# Scheduled maintenance jobs for portal
# Dev scheduled jobs
periodic-tasks-dev:
jobs:
- dev-maintenance-tasks #run on dev
triggers:
- schedule:
cron: '0 0 * * *' # run past 8pm every night EST
filters:
branches:
only: develop
periodic-tasks-jupyter-dev:
jobs:
- dev-jupyter-tasks
triggers:
- schedule:
cron: '0 0,6,12,18 * * *' # run four times per day
filters:
branches:
only: develop
# Staging scheduled jobs
periodic-tasks-staging:
jobs:
- staging-maintenance-tasks #run on stage
triggers:
- schedule:
cron: '0 4 * * *' # run past midnight every night EST
filters:
branches:
only: /^release.*/
periodic-tasks-jupyter-staging:
jobs:
- staging-jupyter-tasks
triggers:
- schedule:
cron: '0 1,7,13,19 * * *' # run four times per day
filters:
branches:
only: /^release.*/
# prod scheduled jobs
periodic-tasks-prod:
jobs:
- prod-maintenance-tasks #run on prod
triggers:
- schedule:
cron: '0 5 * * *' # run at 1am every night EST
filters:
branches:
only: master
periodic-tasks-jupyter-prod:
jobs:
- prod-jupyter-tasks
triggers:
- schedule:
cron: '0 * * * *' # run every hour
filters:
branches:
only: master