Skip to content

Commit 98d8c82

Browse files
committed
Merge branch 'develop' of github.com:NHSDigital/NRLF into feature/eema1-NRL-1285-emptySegmentinOptionalFieldReturns400
2 parents 8a520d4 + 05d5b9a commit 98d8c82

29 files changed

+791
-532
lines changed

.github/workflows/daily-build.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,19 @@ on:
1818

1919
jobs:
2020
build:
21-
name: Build - develop
22-
runs-on: [self-hosted, ci]
21+
name: Build - ${{ github.ref }}
22+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
2323

2424
steps:
25-
- name: Git clone - develop
25+
- name: Git clone - ${{ github.ref }}
2626
uses: actions/checkout@v4
2727
with:
28-
ref: develop
28+
ref: ${{ github.ref }}
2929

30-
- name: Setup asdf cache
31-
uses: actions/cache@v4
32-
with:
33-
path: ~/.asdf
34-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
35-
restore-keys: |
36-
${{ runner.os }}-asdf-
37-
38-
- name: Install asdf
39-
uses: asdf-vm/actions/[email protected]
40-
with:
41-
asdf_branch: v0.13.1
42-
43-
- name: Install zip
44-
run: sudo apt-get install zip
45-
46-
- name: Setup Python environment
30+
- name: Setup environment
4731
run: |
32+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
4833
poetry install --no-root
49-
source $(poetry env info --path)/bin/activate
5034
5135
- name: Run Linting
5236
run: make lint
@@ -55,7 +39,13 @@ jobs:
5539
run: make test
5640

5741
- name: Build Project
58-
run: make build
42+
run: |
43+
echo "PATH: ${PATH}"
44+
echo "HOME: ${HOME}"
45+
echo "python: $(which python)"
46+
echo "asdf: $(which asdf)"
47+
echo "/usr/local/bin: $(ls -la /usr/local/bin)"
48+
make build
5949
6050
- name: Configure Management Credentials
6151
uses: aws-actions/configure-aws-credentials@v4

Dockerfile.ci-build

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt update && \
4+
apt upgrade -y && \
5+
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y \
6+
build-essential \
7+
ca-certificates \
8+
curl \
9+
git \
10+
gnupg \
11+
libbz2-dev \
12+
libffi-dev \
13+
libicu70 \
14+
liblzma-dev \
15+
libncursesw5-dev \
16+
libreadline-dev \
17+
libsqlite3-dev \
18+
libssl-dev \
19+
libxml2-dev \
20+
libxmlsec1-dev \
21+
llvm \
22+
lsb-release \
23+
make \
24+
python3 \
25+
tar \
26+
tk-dev \
27+
unzip \
28+
wget \
29+
xz-utils \
30+
zip \
31+
zlib1g-dev && \
32+
apt clean && \
33+
rm -rf /var/lib/apt/lists/*
34+
35+
WORKDIR /root
36+
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1 && \
37+
echo ". $HOME/.asdf/asdf.sh" >> ~/.bashrc && \
38+
echo ". $HOME/.asdf/completions/asdf.bash" >> ~/.bashrc && \
39+
echo "export ASDF_DIR=$HOME/.asdf" >> ~/.bashrc && \
40+
echo "export PATH=\$ASDF_DIR/bin:\$PATH" >> ~/.bashrc && \
41+
echo "export PATH=\$ASDF_DIR/shims:\$PATH" >> ~/.bashrc
42+
43+
COPY .tool-versions .
44+
RUN for plugin in $(cat .tool-versions | cut -d' ' -f1); do \
45+
./.asdf/bin/asdf plugin add "${plugin}"; \
46+
done && \
47+
./.asdf/bin/asdf install && \
48+
ln -s $(pwd)/.asdf/shims/* /usr/local/bin/.
49+
50+
CMD [ "/bin/bash" ]

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ build-api-packages: ./api/consumer/* ./api/producer/*
7474
./scripts/build-lambda-package.sh $${api} $(DIST_PATH); \
7575
done
7676

77+
build-ci-image: ## Build the CI image
78+
@echo "Building the CI image"
79+
docker build \
80+
-t nhsd-nrlf-ci-build:latest \
81+
-f Dockerfile.ci-build
82+
83+
ecr-login: ## Login to NRLF ECR repo
84+
@echo "Logging into ECR"
85+
$(eval AWS_REGION := $(shell aws configure get region))
86+
$(eval AWS_ACCOUNT_ID := $(shell aws sts get-caller-identity | jq -r .Account))
87+
@aws ecr get-login-password --region "$(AWS_REGION)" \
88+
| docker login --username AWS --password-stdin \
89+
$(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
90+
91+
publish-ci-image: ## Publish the CI image
92+
@echo "Publishing the CI image"
93+
$(eval AWS_REGION := $(shell aws configure get region))
94+
$(eval AWS_ACCOUNT_ID := $(shell aws sts get-caller-identity | jq -r .Account))
95+
@docker tag nhsd-nrlf-ci-build:latest \
96+
$(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/nhsd-nrlf-ci-build:latest
97+
@docker push $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/nhsd-nrlf-ci-build:latest
98+
7799
test: check-warn ## Run the unit tests
78100
@echo "Running unit tests"
79101
pytest --ignore=tests/smoke $(TEST_ARGS)

api/producer/createDocumentReference/create_document_reference.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _check_permissions(
7373
ods_code_parts=metadata.ods_code_parts,
7474
custodian_parts=custodian_parts,
7575
)
76-
return SpineErrorResponse.BAD_REQUEST(
76+
return SpineErrorResponse.UNPROCESSABLE_ENTITY(
7777
diagnostics="The custodian of the provided DocumentReference does not match the expected ODS code for this organisation",
7878
expression="custodian.identifier.value",
7979
)
@@ -201,10 +201,11 @@ def _raise_operation_outcome_error(diagnostics, idx):
201201
"""
202202
raise OperationOutcomeError(
203203
severity="error",
204-
code="invalid",
205-
details=SpineErrorConcept.from_code("BAD_REQUEST"),
204+
code="business-rule",
205+
details=SpineErrorConcept.from_code("UNPROCESSABLE_ENTITY"),
206206
diagnostics=diagnostics,
207207
expression=[f"relatesTo[{idx}].target.identifier.value"],
208+
status_code="422",
208209
)
209210

210211

@@ -236,7 +237,7 @@ def handler(
236237

237238
if not result.is_valid:
238239
logger.log(LogReference.PROCREATE002)
239-
return Response.from_issues(issues=result.issues, statusCode="400")
240+
return Response.from_issues(issues=result.issues, statusCode="422")
240241

241242
core_model = _create_core_model(result.resource, metadata)
242243
if error_response := _check_permissions(core_model, metadata):

0 commit comments

Comments
 (0)