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

dev2stg #4297

Merged
merged 88 commits into from
Oct 8, 2024
Merged

dev2stg #4297

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
076c2b3
2201639_Individuals_Add_a_new_section_to_Display_Delivery_mechanism_d…
Sep 23, 2024
856d56b
mypy
Sep 23, 2024
03cf0db
mypy
Sep 23, 2024
b7d5052
Merge branch 'develop' into 201639_Individuals_Add_a_new_section_to_D…
MarekBiczysko Sep 23, 2024
a14f116
move all the changes into new structure
pkujawa Sep 25, 2024
d2ef462
linter
pkujawa Sep 25, 2024
0fa5a35
adjust options
pkujawa Sep 25, 2024
2c69437
try with assert
pkujawa Sep 25, 2024
956d50b
adjust factory
pkujawa Sep 26, 2024
2139a54
fix e2e
pkujawa Sep 26, 2024
a94de87
Merge branch 'develop' into 201639_Individuals_Add_a_new_section_to_D…
MarekBiczysko Sep 26, 2024
9e99c95
PaymentPlan details show Exchange Rate + Summary PDF (#4240)
pavlo-mk Sep 26, 2024
629a32b
208491: RDI - Rename label to 'Total number of registered Individuals…
pavlo-mk Sep 26, 2024
fef8aa6
Deduplication engine integration demo fixes (#4253)
MarekBiczysko Sep 26, 2024
1067882
Merge remote-tracking branch 'origin' into 201639_Individuals_Add_a_n…
Sep 26, 2024
8d4befd
Merge pull request #4258 from unicef/201639_Individuals_Add_a_new_sec…
mmaciekk Sep 26, 2024
9c6f997
e2e edjustment + increase retry
pkujawa Sep 26, 2024
1b174af
resolve migration conflict
pkujawa Sep 26, 2024
2805fdc
Merge branch 'develop' into allowed_ba_partner_perm_update_new_branch
pkujawa Sep 26, 2024
03e4560
add compose file for running selenium locally, adjust readme
pkujawa Sep 26, 2024
be53494
try
pkujawa Sep 26, 2024
2f5c913
trial
pkujawa Sep 26, 2024
f8e2bab
try
pkujawa Sep 27, 2024
5f6d67c
?
pkujawa Sep 27, 2024
614b3ad
ok
pkujawa Sep 27, 2024
c3af528
hotfix_add_financial_payment_provider_inline_validation (#4193)
MarekBiczysko Sep 27, 2024
d6fb6ba
remove lazy query
Sep 27, 2024
f3d8b2c
fixed health check
johniak Sep 27, 2024
c482ed3
Merge pull request #4262 from unicef/allowed_ba_partner_perm_update_n…
pkujawa Sep 27, 2024
068e0ab
fix e2e
pkujawa Sep 30, 2024
d2986e9
Merge pull request #4268 from unicef/fix-failing-e2e
pkujawa Sep 30, 2024
8c8b1f7
added db host
johniak Sep 30, 2024
9f69988
validate unique ind for role in hh
pkujawa Sep 30, 2024
19a79b4
linter
pkujawa Oct 1, 2024
d903d4b
Merge branch 'develop' into add-error-for-kobo-import-role-not-unique
pkujawa Oct 1, 2024
06a178b
noqa
pkujawa Oct 1, 2024
a3a8739
Changes to Project structure (#4269)
johniak Oct 1, 2024
41e189f
mypy
pkujawa Oct 1, 2024
700ce26
fixes after structure change
johniak Oct 1, 2024
bb0b5ac
fail fast selenium
johniak Oct 1, 2024
e6c0472
fix e2e yesy
pkujawa Oct 1, 2024
1cda51f
remove comented headless
johniak Oct 1, 2024
f431317
e2e fixes
johniak Oct 1, 2024
9d0123e
fixed file path
johniak Oct 1, 2024
4839f1f
fixed report path
johniak Oct 1, 2024
05b0fd2
run all tests
johniak Oct 2, 2024
9ca7a9f
Merge pull request #4272 from unicef/add-error-for-kobo-import-role-n…
pkujawa Oct 2, 2024
20459e7
fixes to reports and coverage
johniak Oct 2, 2024
6009c53
Merge pull request #4273 from unicef/fixes-after-structure-change
johniak Oct 2, 2024
4dee570
2212815_Needs_adjudication_Delays_in_creating_duplicate_tickets_after…
MarekBiczysko Oct 2, 2024
522579b
Program cycle requred for TP, adjust create TP from list in admin
pkujawa Oct 3, 2024
e434edd
linter
pkujawa Oct 3, 2024
b9ffb29
fix tests creating TPs without cycles
pkujawa Oct 3, 2024
372b465
skip forms
pkujawa Oct 3, 2024
63dd69b
fixed test
johniak Oct 3, 2024
0167965
bring back nighlt runs for tests marked before
pkujawa Oct 3, 2024
fd87736
2216761_Adapt_Dedup_integration (#4280)
MarekBiczysko Oct 3, 2024
f9ee4f3
remove usd from label (#4281)
mmaciekk Oct 3, 2024
2355700
text
pkujawa Oct 3, 2024
b747a51
skip trivy failure
wozniakpl Oct 3, 2024
e796d88
Merge pull request #4283 from unicef/fixes-after-structure-change
johniak Oct 3, 2024
7ec51ba
Merge pull request #4265 from unicef/200744/access-denied
mmaciekk Oct 3, 2024
78ef72a
Project structure 3 (#4287)
johniak Oct 3, 2024
bbf6217
Update compose.yml
johniak Oct 3, 2024
a714960
adjust test to testcase
pkujawa Oct 3, 2024
154e9d8
remove edopomoga
pkujawa Oct 3, 2024
aa6ee62
include src in path
pkujawa Oct 3, 2024
a3041d1
linter
pkujawa Oct 3, 2024
79cd0ef
Merge branch 'develop' into create-tp-from-admin
pkujawa Oct 3, 2024
50a2d06
PM: Supporting documents (#4260)
pavlo-mk Oct 3, 2024
4f664e9
fix test admin
pkujawa Oct 3, 2024
77ec188
fix coveragerc
pkujawa Oct 4, 2024
4ba14c0
add ignore to codecov files
pkujawa Oct 4, 2024
fc309cc
move ignored paths to codecov.yml
pkujawa Oct 4, 2024
2e3037e
Merge pull request #4282 from unicef/create-tp-from-admin
pkujawa Oct 4, 2024
14a3721
fixed retrieving version
johniak Oct 4, 2024
048e48b
Merge branch 'develop' of github.com:unicef/hct-mis into develop
johniak Oct 4, 2024
e9dc18d
add vision app (#4274)
domdinicola Oct 4, 2024
d53bfef
change text of xlsx individual update for invalid phone no
pkujawa Oct 6, 2024
629a491
include file
pkujawa Oct 6, 2024
8840882
linter
pkujawa Oct 6, 2024
a6d9d75
Provide superusers and testers via env/arg to `initdemo` (#4295)
wozniakpl Oct 7, 2024
fc7943c
add index on document number
pkujawa Oct 7, 2024
4ad6379
216761 adapt dedup integration (#4298)
MarekBiczysko Oct 7, 2024
c6f075a
Merge branch 'develop' into index-document-number
pkujawa Oct 8, 2024
36f5811
Merge pull request #4299 from unicef/index-document-number
pkujawa Oct 8, 2024
58e9ba8
Merge pull request #4293 from unicef/xlsx-update-phone-validation
pkujawa Oct 8, 2024
75144a9
[Back merge] prod>STG (#4294) (#4296)
domdinicola Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions src/.flake8 → .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exclude =
migrations,
snapshots,
__pypackages__,
frontend,

ignore =
# black formatting related
Expand Down
4 changes: 2 additions & 2 deletions .github/helpers/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ else
-n auto \
--reruns 3 \
--reruns-delay 1 \
--cov-report xml:coverage.xml \
--cov-report xml:test-coverage/coverage.xml \
--randomly-seed=42 \
--create-db \
/tests/unit/
./tests/unit/
;;
"lint")
mkdir -p ./lint-results
Expand Down
8 changes: 4 additions & 4 deletions .github/helpers/docker-compose.selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ volumes:
services:
backend:
volumes:
- ../src/report/screenshot/:/code/screenshot/
- ../src/report/:/code/report/
- ../../tests/test-coverage:/code/test-coverage
- ../../tests/report/:/code/tests/selenium/output_data/report/
- type: volume
source: backend-web-app
target: /code/hct_mis_api/apps/web
target: /code/src/hct_mis_api/apps/web
volume:
nocopy: false
depends_on:
Expand All @@ -31,7 +31,7 @@ services:
- backend-web-app:/tmp/
command: |
sh -c "
cp -r ./hct_mis_api/apps/web/* /tmp/
cp -r /packages/__pypackages__/3.11/lib/hct_mis_api/apps/web/* /tmp/
"
restart: "no"

Expand Down
2 changes: 1 addition & 1 deletion .github/helpers/docker-compose.tst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
backend:
image: ${dev_backend_image}
volumes:
- ../../src/test-coverage:/code/backend/test-coverage
- ../../tests/test-coverage:/code/test-coverage
- ./dev.sh:/code/dev.sh
depends_on:
- db
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,14 @@ jobs:

- name: Unit tests
run: |
# a little hack to allow to have 1 compose file running 2 different test suites because --env-file didn't work as docs suggested it should
dev_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev docker compose \
-f ./.github/helpers/docker-compose.tst.yml \
--profile unit \
run backend ./dev.sh test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./src/coverage.xml
files: ./tests/test-coverage/coverage.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
Expand Down Expand Up @@ -265,22 +264,22 @@ jobs:
-f ./.github/helpers/docker-compose.selenium.yml \
run backend bash -c "
waitforit -host=db -port=5432 -timeout=30
pytest -svvv $extra_options /tests/selenium --cov-report xml:./coverage.xml --html-report=./report/report.html --randomly-seed=42
pytest -svvv $extra_options ./tests/selenium --cov-report xml:test-coverage/coverage.xml --html-report=./tests/selenium/output_data/report/report.html --randomly-seed=42
"
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: report
path: ./src/report/
path: ./tests/report/
retention-days: 5
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: always()
continue-on-error: true
with:
files: ./src/coverage.xml
files: ./test-coverage/coverage.xml
flags: e2e
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
Expand All @@ -297,6 +296,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run Trivy vulnerability scanner
continue-on-error: true # due to getting TOOMANYREQUESTS
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}'
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ ENV/
env.bak/
venv.bak/

.pdm-python

# Spyder project settings
.spyderproject
.spyproject
Expand Down Expand Up @@ -129,3 +131,10 @@ venv.bak/
cov.json

.vscode/
output_data/
.coverage

archive/
output.json
pytest_html_report.html
compose.dist.yml
49 changes: 8 additions & 41 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/ambv/black
rev: 23.12.1
hooks:
- id: black
args: [--config=backend/pyproject.toml]
exclude: "migrations|snapshots"
stages: [commit]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: [--config=backend/.flake8]
additional_dependencies: [flake8-bugbear==22.12.6]
stages: [ commit ]
exclude: /deployment/|/migrations/
# mypy precommit hook
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
verbose: true
args: [--config-file=backend/pyproject.toml, --follow-imports=skip]
pass_filenames: true
stages: [commit]
additional_dependencies: [
types-requests==2.28.11.15,
types-redis==4.5.1.4,
types-python-dateutil==2.8.19.10,
types-pytz==2022.7.1.2,
djangorestframework-stubs==1.9.1,
graphene-stubs==0.15,
django-stubs==1.15.0,
django-stubs-ext==0.7.0,
openpyxl-stubs==0.1.25
]
exclude: /deployment/|/migrations/
- repo: local
hooks:
- id: Linters checks
name: Linters checks
entry: docker compose -f development_tools/compose.yml run --no-TTY -i --rm backend sh -c 'black . --check && isort . --check-only && flake8 . && mypy .'
language: system
pass_filenames: false
verbose: true
16 changes: 16 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,19 @@ coverage:
patch:
default:
target: 95%
ignore:
- "**/forms.py"
- "*/selenium_tests/**"
- "*/tests/**"
- "*/migrations/*"
- "*/apps.py"
- "*/admin/*.py"
- "*/admin.py"
- "**/fixtures.py"
- "hct_mis_api/one_time_scripts/*"
- "hct_mis_api/libs/*"
- "hct_mis_api/settings/*"
- "hct_mis_api/settings.py"
- "hct_mis_api/conftest.py"
- "hct_mis_api/config/settings.py"
- "hct_mis_api/apps/core/management/commands/*"
15 changes: 7 additions & 8 deletions development_tools/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ services:
ports:
- "8080:8000"
volumes:
- ../src:/code/
- ../tests:/tests/
- ../.:/code/
- backend-data:/data
- ../src/pyproject.toml:/packages/pyproject.toml
- ../src/pdm.lock:/packages/pdm.lock
- ../pyproject.toml:/packages/pyproject.toml
- ../pdm.lock:/packages/pdm.lock
- ipython_data_local:/root/.ipython
command: "dev"
depends_on:
Expand Down Expand Up @@ -125,9 +124,9 @@ services:
env_file:
- .env
ports:
- "5433:5432"
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
test: [ "CMD-SHELL", "su - postgres -c 'pg_isready -h db -U postgres'" ]
interval: 10s
timeout: 10s
retries: 5
Expand All @@ -138,8 +137,8 @@ services:
profiles:
- default
- services
expose:
- "6379"
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
Expand Down
17 changes: 15 additions & 2 deletions development_tools/local_selenium_env.sh → development_tools/local_selenium_init.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if [ "$0" = "$BASH_SOURCE" ]; then
echo "Please source this script."
exit 1
fi
export SECRET_KEY=SOME_KEY_HERE
export DEBUG=true
export ENV=dev
Expand Down Expand Up @@ -38,5 +42,14 @@ export CACHE_LOCATION=redis://localhost:6379/1
export USE_DUMMY_EXCHANGE_RATES=yes
export ELASTICSEARCH_HOST=http://localhost:9200
export CELERY_TASK_ALWAYS_EAGER=true
export DATA_VOLUME="./data1"
export LIBRARY_PATHS=true
export LIBRARY_PATHS=true
SCRIPT_DIR=$(realpath "$(dirname $0)")
MAIN_DIR=$(realpath $SCRIPT_DIR/..)
echo "SCRIPT_DIR: $SCRIPT_DIR"
export PYTHONPATH=$MAIN_DIR/src:$PYTHONPATH
export OUTPUT_DATA_ROOT=$MAIN_DIR/tests/selenium/output_data
export DATA_VOLUME=$OUTPUT_DATA_ROOT/data
pushd $MAIN_DIR/src/frontend
yarn
yarn build-for-backend
popd
58 changes: 30 additions & 28 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,34 @@ RUN apt-get update \

ENV PDM_PACKAGES=/packages
ENV CODE=/code
ENV PDM_NO_SELF=True
ENV PDM_PROJECT=$PDM_PACKAGES
ENV PYPACKAGES=$PDM_PACKAGES/__pypackages__/3.11
ENV PYTHONPYCACHEPREFIX=/tmp/pycache \
PYTHONPATH=$PYPACKAGES/lib:$CODE:$PYTHONPATH \
PYTHONPATH=$PYPACKAGES/lib:$PYTHONPATH \
PATH=$PYPACKAGES/bin:$PATH \
XDG_RUNTIME_DIR=/run/user/"${UID}"

ENV DJANGO_SETTINGS_MODULE=hct_mis_api.config.settings
WORKDIR $CODE

COPY --from=waitforit /data/waitforit /usr/local/bin/waitforit

# Dist builder image
FROM base as builder

FROM base as pdm
RUN pip install --upgrade pip &&\
pip install pdm==2.15.2 &&\
pip install setuptools==71.1.0 &&\
pdm config cache_dir /var/cache/pdm &&\
pdm config python.use_venv false &&\
pdm config venv.in_project true &&\
pdm config check_update false

WORKDIR $PDM_PACKAGES
COPY src/pyproject.toml src/pdm.lock ./
RUN pdm sync --prod --no-editable --no-self --no-isolation
COPY README.md LICENSE pyproject.toml pdm.lock ./




# Dev image
FROM builder AS dev
FROM pdm AS dev

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -83,26 +82,14 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHONPATH=$CODE/src:$CODE/test/:$PYTHONPATH
RUN pdm sync --no-editable --no-self --no-isolation

WORKDIR $CODE
COPY ./src/ ./
COPY ./tests /tests



COPY ./docker/entrypoint.sh /bin/
ENTRYPOINT ["entrypoint.sh"]

## Dist (backend only) image
FROM base AS be-dist

COPY ./src/ ./
COPY --chown=hope:hope --from=builder $PDM_PACKAGES $PDM_PACKAGES
COPY --chown=hope:hope --from=certs /data/psql-cert.crt /code/psql-cert.crt

USER hope

COPY ./src/ ./src/
COPY ./tests ./tests
COPY ./manage.py ./manage.py
COPY .flake8 pyproject.toml pdm.lock ./
COPY ./docker/entrypoint.sh /bin/
ENTRYPOINT ["entrypoint.sh"]

Expand All @@ -117,7 +104,22 @@ RUN yarn install --frozen-lockfile --network-timeout 600000
COPY ./src/frontend ./
RUN NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=4096" yarn build

# Dist builder image
FROM pdm as dist-builder
COPY ./src/ ./src/
COPY --chown=hope:hope --from=frontend-builder /fe-build/build $PDM_PACKAGES/src/hct_mis_api/apps/web/static/web
RUN pdm sync --prod --no-editable --no-isolation


FROM be-dist AS dist
## Dist (backend only) image
FROM base AS dist

COPY --chown=hope:hope --from=frontend-builder /fe-build/build ./hct_mis_api/apps/web/static/web

COPY ./src/gunicorn_config.py /conf/gunicorn_config.py
COPY --chown=hope:hope --from=dist-builder $PDM_PACKAGES $PDM_PACKAGES
COPY --chown=hope:hope --from=certs /data/psql-cert.crt /certs/psql-cert.crt

USER hope

COPY ./docker/entrypoint.sh /bin/
ENTRYPOINT ["entrypoint.sh"]
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ wait_for_db() {
}

if [ $# -eq 0 ]; then
exec gunicorn hct_mis_api.wsgi -c /code/gunicorn_config.py
exec gunicorn hct_mis_api.wsgi -c /conf/gunicorn_config.py
else
case "$1" in
"dev")
Expand Down
File renamed without changes.
Loading
Loading