Skip to content

Commit 8cbf3ae

Browse files
committed
Move detect changes job to deploy-backend
1 parent f8fa6ae commit 8cbf3ae

4 files changed

Lines changed: 31 additions & 55 deletions

File tree

.github/workflows/continuous-deployment.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,11 @@ jobs:
1515
secrets:
1616
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1717

18-
detect-recordprocessor-changes:
19-
runs-on: ubuntu-latest
20-
outputs:
21-
has_changes: ${{ steps.detect.outputs.has_changes }}
22-
steps:
23-
- name: Checkout
24-
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
25-
with:
26-
fetch-depth: 0
27-
28-
- name: Detect recordprocessor changes compared to master
29-
id: detect
30-
run: |
31-
if git diff --quiet "${{ github.event.before }}" "${{ github.sha }}" -- lambdas/recordprocessor/ lambdas/shared/src/common/; then
32-
echo "has_changes=false" >> "$GITHUB_OUTPUT"
33-
else
34-
echo "has_changes=true" >> "$GITHUB_OUTPUT"
35-
fi
36-
3718
deploy-internal-dev-backend:
38-
needs: [run-quality-checks, detect-recordprocessor-changes]
19+
needs: run-quality-checks
3920
uses: ./.github/workflows/deploy-backend.yml
4021
with:
4122
apigee_environment: internal-dev
42-
build_recordprocessor_image: ${{needs.detect-recordprocessor-changes.outputs.has_changes == 'true'}}
4323
create_mns_subscription: true
4424
environment: dev
4525
sub_environment: internal-dev
@@ -95,14 +75,13 @@ jobs:
9575
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
9676

9777
deploy-higher-dev-envs:
98-
needs: [run-internal-dev-tests, detect-recordprocessor-changes]
78+
needs: run-internal-dev-tests
9979
strategy:
10080
matrix:
10181
sub_environment_name: [ref, internal-qa]
10282
uses: ./.github/workflows/deploy-backend.yml
10383
with:
10484
apigee_environment: ${{ matrix.sub_environment_name }}
105-
build_recordprocessor_image: ${{needs.detect-recordprocessor-changes.outputs.has_changes == 'true'}}
10685
create_mns_subscription: true
10786
environment: dev
10887
sub_environment: ${{ matrix.sub_environment_name }}

.github/workflows/deploy-backend.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
apigee_environment:
77
required: true
88
type: string
9-
build_recordprocessor_image:
9+
build_recordprocessor_override:
1010
required: false
1111
type: boolean
12-
default: false
12+
default: true
1313
create_mns_subscription:
1414
required: false
1515
type: boolean
@@ -43,11 +43,11 @@ on:
4343
- dev
4444
- preprod
4545
- prod
46-
build_recordprocessor_image:
46+
build_recordprocessor_override:
4747
description: Build and push a new recordprocessor image for this deployment
4848
required: false
4949
type: boolean
50-
default: false
50+
default: true
5151
sub_environment:
5252
type: string
5353
description: Set the sub environment name e.g. pr-xxx, or green/blue in higher environments
@@ -56,12 +56,31 @@ env: # Sonarcloud - do not allow direct usage of untrusted data
5656
APIGEE_ENVIRONMENT: ${{ inputs.apigee_environment }}
5757
ENVIRONMENT: ${{ inputs.environment }}
5858
SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
59+
build_recordprocessor: true
5960

6061
run-name: Deploy Backend - ${{ inputs.environment }} ${{ inputs.sub_environment }}
6162

6263
jobs:
64+
detect-recordprocessor-changes:
65+
runs-on: ubuntu-latest
66+
if: github.event.action != 'opened' || github.event.action != 'reopened' || !inputs.build_recordprocessor_override
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Detect recordprocessor changes in PR
74+
id: detect
75+
run: |
76+
if git diff --quiet "${{ github.event.before }}" "${{ github.sha }}" -- lambdas/recordprocessor/ lambdas/shared/src/common/; then
77+
echo "build_record_processor=false" >> "$GITHUB_OUTPUT"
78+
else
79+
echo "build_record_processor=true" >> "$GITHUB_OUTPUT"
80+
fi
81+
6382
build-and-push-recordprocessor:
64-
if: ${{ inputs.build_recordprocessor_image }}
83+
if: ${{ env.build_record_processor || inputs.build_recordprocessor_override }}
6584
permissions:
6685
id-token: write
6786
contents: read
@@ -104,7 +123,7 @@ jobs:
104123
echo "recordprocessor_image_tag=${IMAGE_TAG}" >> "$GITHUB_OUTPUT"
105124
106125
resolve-recordprocessor-image-tag:
107-
if: ${{ !inputs.build_recordprocessor_image }}
126+
if: ${{ !env.build_record_processor || !inputs.build_recordprocessor_override }}
108127
permissions:
109128
id-token: write
110129
contents: read
@@ -114,8 +133,6 @@ jobs:
114133
runs-on: ubuntu-latest
115134
environment:
116135
name: ${{ inputs.environment }}
117-
env:
118-
AWS_REGION: eu-west-2
119136
steps:
120137
- name: Connect to AWS
121138
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
@@ -129,6 +146,7 @@ jobs:
129146
env:
130147
REPOSITORY_NAME: imms-recordprocessor-repo
131148
TAG_PREFIX: ${{ inputs.sub_environment }}-
149+
AWS_REGION: eu-west-2
132150
run: |
133151
IMAGE_TAG=$(
134152
aws ecr describe-images \
@@ -144,7 +162,7 @@ jobs:
144162
145163
if [ -z "${IMAGE_TAG}" ]; then
146164
echo "No existing recordprocessor image found for prefix '${TAG_PREFIX}'."
147-
echo "Trigger a run with build_recordprocessor_image=true to build one."
165+
echo "Trigger a run with build_recordprocessor=true to build one."
148166
exit 1
149167
fi
150168

.github/workflows/pr-deploy-and-test.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,12 @@ jobs:
1414
secrets:
1515
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1616

17-
detect-recordprocessor-changes:
18-
runs-on: ubuntu-latest
19-
if: github.event.action == 'synchronize'
20-
outputs:
21-
has_changes: ${{ steps.detect.outputs.has_changes }}
22-
steps:
23-
- name: Checkout
24-
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
25-
with:
26-
fetch-depth: 0
27-
28-
- name: Detect recordprocessor changes in PR
29-
id: detect
30-
run: |
31-
if git diff --quiet "${{ github.event.before }}" "${{ github.event.pull_request.head.sha }}" -- lambdas/recordprocessor/ lambdas/shared/src/common/; then
32-
echo "has_changes=false" >> "$GITHUB_OUTPUT"
33-
else
34-
echo "has_changes=true" >> "$GITHUB_OUTPUT"
35-
fi
36-
3717
deploy-pr-backend:
38-
needs: [run-quality-checks, detect-recordprocessor-changes]
18+
needs: run-quality-checks
3919
if: ${{ always() && !failure() && !cancelled() }}
4020
uses: ./.github/workflows/deploy-backend.yml
4121
with:
4222
apigee_environment: internal-dev
43-
build_recordprocessor_image: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || needs.detect-recordprocessor-changes.outputs.has_changes == 'true' }}
4423
create_mns_subscription: true
4524
environment: dev
4625
sub_environment: pr-${{github.event.pull_request.number}}

lambdas/recordprocessor/src/batch_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def process_csv_to_fhir(incoming_message_body: dict) -> int:
2626
Returns the number of rows processed. While this is not used by the handler, the number of rows
2727
processed must be correct and therefore is returned for logging and test purposes.
2828
"""
29-
encoder = "utf-8" # default encoding
29+
encoder = "utf-8" # default encoding.
3030
try:
3131
incoming_message_body["encoder"] = encoder
3232
interim_message_body = file_level_validation(incoming_message_body=incoming_message_body)

0 commit comments

Comments
 (0)