From 6e9757cf96a839c812ea98134e8a900d58b02e70 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Thu, 13 Jun 2024 13:09:20 +0530 Subject: [PATCH 1/5] Update test workflow and upload artifacts version (#2265) * pass codecov token to reusable workflow * save test cache only on push runs * update upload artifacts version --- .github/workflows/deploy.yml | 4 ++++ .github/workflows/docs.yml | 2 +- .github/workflows/reusable-test.yml | 22 +++++++++++++++++++--- .github/workflows/test-merge-queue.yml | 4 ++++ .github/workflows/test-pull-request.yml | 4 ++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 059d2312aa..9463328ce4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -34,6 +34,10 @@ env: jobs: test: uses: ./.github/workflows/reusable-test.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + event_name: ${{ github.event_name }} build: needs: test diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e670e90fe2..6299ccbeb6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -37,7 +37,7 @@ jobs: make -C ./docs html - name: Upload sphinx documentation - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: sphinx-docs path: ./docs/_build/html diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 789624b72f..fbce6e7a24 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -2,6 +2,14 @@ name: Test on: workflow_call: + secrets: + CODECOV_TOKEN: + required: true + inputs: + event_name: + required: false + type: string + default: 'pull_request' jobs: test: @@ -12,8 +20,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Cache Docker layers - uses: actions/cache@v3 + - name: Restore Docker layers cache + id: cache-restore + uses: actions/cache/restore@v4 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'docker/dev.Dockerfile') }} @@ -54,7 +63,14 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - name: Move cache + - name: Move new cache run: | rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Save Docker layers cache + if: ${{ inputs.event_name == 'push' || github.event_name == 'push' }} + uses: actions/cache/save@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'docker/dev.Dockerfile') }} diff --git a/.github/workflows/test-merge-queue.yml b/.github/workflows/test-merge-queue.yml index 66045ae4e3..3e091ffc3a 100644 --- a/.github/workflows/test-merge-queue.yml +++ b/.github/workflows/test-merge-queue.yml @@ -6,3 +6,7 @@ on: jobs: test: uses: ./.github/workflows/reusable-test.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + event_name: ${{ github.event_name }} diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index acb394fedb..30aa54f2c9 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -10,3 +10,7 @@ concurrency: jobs: test: uses: ./.github/workflows/reusable-test.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + event_name: ${{ github.event_name }} From 1313433695b710e2ee6750726478b9a8742535e9 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Thu, 13 Jun 2024 13:15:36 +0530 Subject: [PATCH 2/5] Fix facility cover upload for local setups (#2264) fix facility cover upload for local setups Co-authored-by: Vignesh Hari --- care/facility/api/serializers/facility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/care/facility/api/serializers/facility.py b/care/facility/api/serializers/facility.py index 73779bdfd9..28df9b80f7 100644 --- a/care/facility/api/serializers/facility.py +++ b/care/facility/api/serializers/facility.py @@ -165,7 +165,7 @@ def save(self, **kwargs): facility = self.instance image = self.validated_data["cover_image"] image_extension = image.name.rsplit(".", 1)[-1] - config, bucket_name = get_client_config(BucketType.FACILITY, True) + config, bucket_name = get_client_config(BucketType.FACILITY) s3 = boto3.client("s3", **config) image_location = f"cover_images/{facility.external_id}_cover.{image_extension}" s3.put_object( From 8a0aa3034057e90e7a0801f5b6ce1c77fa0c080e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:16:41 +0530 Subject: [PATCH 3/5] Bump sentry-sdk from 2.3.1 to 2.5.1 (#2261) Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 2.3.1 to 2.5.1. - [Release notes](https://github.com/getsentry/sentry-python/releases) - [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-python/compare/2.3.1...2.5.1) --- updated-dependencies: - dependency-name: sentry-sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vignesh Hari --- Pipfile | 2 +- Pipfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Pipfile b/Pipfile index c237211210..dbec56b231 100644 --- a/Pipfile +++ b/Pipfile @@ -43,7 +43,7 @@ pywebpush = "==1.14.0" redis = { extras = ["hiredis"], version = "==5.0.3" } # constraint for redis-om redis-om = "==0.3.1" requests = "==2.32.3" -sentry-sdk = "==2.3.1" +sentry-sdk = "==2.5.1" whitenoise = "==6.6.0" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index bfc527c779..2298f9e01f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5fe5da0bd747ef2a0efe251ee320dfe929be978482a02236fc58385c602361c4" + "sha256": "cc9eeb6e4bd3aae75d144e6f458ba357d91236a6a27045383672e7976296088b" }, "pipfile-spec": 6, "requires": { @@ -1247,12 +1247,12 @@ }, "sentry-sdk": { "hashes": [ - "sha256:139a71a19f5e9eb5d3623942491ce03cf8ebc14ea2e39ba3e6fe79560d8a5b1f", - "sha256:c5aeb095ba226391d337dd42a6f9470d86c9fc236ecc71cfc7cd1942b45010c6" + "sha256:1f87acdce4a43a523ae5aa21a3fc37522d73ebd9ec04b1dbf01aa3d173852def", + "sha256:fbc40a78a8a9c6675133031116144f0d0940376fa6e4e1acd5624c90b0aaf58b" ], "index": "pypi", "markers": "python_version >= '3.6'", - "version": "==2.3.1" + "version": "==2.5.1" }, "six": { "hashes": [ From d49e4e11bb6ea3e2ed280b0a75b192d0bdff7337 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:52:02 +0530 Subject: [PATCH 4/5] Bump redis from 5.0.3 to 5.0.5 (#2262) Bumps [redis](https://github.com/redis/redis-py) from 5.0.3 to 5.0.5. - [Release notes](https://github.com/redis/redis-py/releases) - [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES) - [Commits](https://github.com/redis/redis-py/compare/v5.0.3...v5.0.5) --- updated-dependencies: - dependency-name: redis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Pipfile | 2 +- Pipfile.lock | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Pipfile b/Pipfile index dbec56b231..76b1ed4222 100644 --- a/Pipfile +++ b/Pipfile @@ -40,7 +40,7 @@ pydantic = "==1.10.15" # fix for fhir.resources < 7.0.2 pyjwt = "==2.8.0" python-slugify = "==8.0.4" pywebpush = "==1.14.0" -redis = { extras = ["hiredis"], version = "==5.0.3" } # constraint for redis-om +redis = { extras = ["hiredis"], version = "==5.0.5" } # constraint for redis-om redis-om = "==0.3.1" requests = "==2.32.3" sentry-sdk = "==2.5.1" diff --git a/Pipfile.lock b/Pipfile.lock index 2298f9e01f..297ac479b9 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "cc9eeb6e4bd3aae75d144e6f458ba357d91236a6a27045383672e7976296088b" + "sha256": "7d926299b4a6a70b52ff723433da0406c26cf2a6faeee3ec7432368be663f120" }, "pipfile-spec": 6, "requires": { @@ -1100,11 +1100,12 @@ "hiredis" ], "hashes": [ - "sha256:4973bae7444c0fbed64a06b87446f79361cb7e4ec1538c022d696ed7a5015580", - "sha256:5da9b8fe9e1254293756c16c008e8620b3d15fcc6dde6babde9541850e72a32d" + "sha256:30b47d4ebb6b7a0b9b40c1275a19b87bb6f46b3bed82a89012cf56dea4024ada", + "sha256:3417688621acf6ee368dec4a04dd95881be24efd34c79f00d31f62bb528800ae" ], + "index": "pypi", "markers": "python_version >= '3.7'", - "version": "==5.0.3" + "version": "==5.0.5" }, "redis-om": { "hashes": [ From cda75bb5985e5dc380f5b1e9356fd1ee8c38db5b Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:48:02 +0530 Subject: [PATCH 5/5] Allow Nurses to clear their home facility (#2206) --- care/facility/tests/test_unlink_district_admins.py | 7 +++++++ care/users/api/viewsets/users.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/care/facility/tests/test_unlink_district_admins.py b/care/facility/tests/test_unlink_district_admins.py index edee3d67a9..8f7ee3674f 100644 --- a/care/facility/tests/test_unlink_district_admins.py +++ b/care/facility/tests/test_unlink_district_admins.py @@ -79,3 +79,10 @@ def test_unlink_faciltity_admin_different_district(self): ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEqual(response.json()["detail"], "User not found") + + def test_unlink_home_facility_by_nurse(self): + self.client.force_login(self.staff1) + response = self.client.delete( + f"/api/v1/users/{self.staff1.username}/clear_home_facility/" + ) + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) diff --git a/care/users/api/viewsets/users.py b/care/users/api/viewsets/users.py index 167a1047f2..bbf587dec7 100644 --- a/care/users/api/viewsets/users.py +++ b/care/users/api/viewsets/users.py @@ -287,6 +287,11 @@ def clear_home_facility(self, request, *args, **kwargs): if not user.home_facility: raise ValidationError({"home_facility": "No Home Facility Present"}) if ( + requesting_user.id == user.id + and requesting_user.user_type == User.TYPE_VALUE_MAP["Nurse"] + ): + pass + elif ( requesting_user.user_type < User.TYPE_VALUE_MAP["DistrictAdmin"] or requesting_user.user_type in User.READ_ONLY_TYPES ):