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 }} diff --git a/Pipfile b/Pipfile index c237211210..76b1ed4222 100644 --- a/Pipfile +++ b/Pipfile @@ -40,10 +40,10 @@ 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.3.1" +sentry-sdk = "==2.5.1" whitenoise = "==6.6.0" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index bfc527c779..297ac479b9 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5fe5da0bd747ef2a0efe251ee320dfe929be978482a02236fc58385c602361c4" + "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": [ @@ -1247,12 +1248,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": [ 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( 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 ):