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

[PRMP-620] bump up nodejs and packages version #98

Merged
merged 15 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Use Node.js 16.x
- name: Use Node.js 22.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 22.x

- name: Run test coverage
run: |
Expand Down
165 changes: 165 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
## When copying this to a new ORC repository...
##
## 1) Create environments for dev, test, pre-prod and prod (https://github.com/nhsconnect/<repo>/settings/environments).
##
## 2) For each environment, add the following secrets:
## - BACKEND_BUCKET
## - BACKEND_KEY
## - IAM_ROLE_READONLY
##
## 3) Create the following repository secret (https://github.com/nhsconnect/<repo>/settings/secrets/actions):
## - ECR_REPOSITORY_NAME
##
## 4) Edit the ## REPOSITORY SPECIFIC ## section below.

name: Terraform Plan
on:
pull_request:
branches: [ main ]

permissions:
contents: read # Required for actions/checkout
id-token: write # Required for requesting the JWT
pull-requests: write # Required to write comments

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- name: Set up git repo
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 'latest'

- run: npm ci

- name: eslint
run: npm run lint

plan:
strategy:
matrix:
environment: [dev, test, pre-prod, prod]
name: ${{ matrix.environment }}
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
defaults:
run:
working-directory: ./terraform
steps:
- name: Set up git repo
uses: actions/checkout@v4

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.IAM_ROLE_READONLY }}
aws-region: eu-west-2

- name: terraform fmt
id: fmt
working-directory: ./
run: terraform fmt -recursive -check

- name: terraform init
id: init
run: terraform init -no-color -upgrade -backend-config="bucket=${{ secrets.TF_BACKEND_BUCKET }}" -backend-config="key=${{ secrets.TF_BACKEND_KEY }}" -backend-config="dynamodb_table=${{ secrets.TF_BACKEND_DYNAMODB_TABLE }}"

- name: terraform validate
id: validate
run: terraform validate -no-color

## REPOSITORY SPECIFIC ##
- name: Setup Terraform variables
id: vars
run: |-
IMAGE_TAG=$(aws ecr describe-images --repository-name ${{ secrets.ECR_REPOSITORY_NAME }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]')
cat > pipeline.auto.tfvars <<EOF
task_image_tag = $IMAGE_TAG
EOF

- name: terraform plan
id: plan
run: |
terraform plan -var-file="${{ matrix.environment }}.tfvars" -no-color -out=tfplan
terraform show -no-color tfplan > tfplan.txt
echo "summary=$(grep -E 'Plan: [0-9]+ to add, [0-9]+ to change, [0-9]+ to destroy\.|No changes\. Your infrastructure matches the configuration\.' tfplan.txt | sed 's/.*No changes\. Your infrastructure matches the configuration/Plan: no changes/g' | sed 's/.*Plan: //g' | sed 's/\..*//g')" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Add PR comment
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Report for environment: ${{ matrix.environment }}')
})

// 2. Prepare format of the comment
const output = `### Report for environment: ${{ matrix.environment }}

#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
<details><summary>Format Output</summary>

\`\`\`\n
${{ steps.fmt.outputs.stdout }}
\`\`\`

</details>

#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
<details><summary>Initialization Output</summary>

\`\`\`\n
${{ steps.init.outputs.stdout }}
\`\`\`

</details>

#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>

\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`

</details>

#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`

<details><summary>Show Plan (${{ steps.plan.outputs.summary }})</summary>

\`\`\`\n
${{ steps.plan.outputs.stdout }}
\`\`\`

</details>`;

// 3. If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
}

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
18 changes: 1 addition & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
FROM node:16.19.0-alpine AS builder

# install python native requirements
RUN apk update && \
apk add --no-cache bash tini && \
rm -rf /var/cache/apk/*

RUN apk add --no-cache \
python3 \
py3-pip \
&& pip3 install --upgrade pip \
&& pip3 install \
awscli \
&& rm -rf /var/cache/apk/*

# Install sequelize postgress native dependencies
RUN apk add --no-cache g++ make
FROM node:22.5-alpine AS builder

COPY package*.json /app/

Expand Down
2 changes: 1 addition & 1 deletion Dojofile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:38621b49ed7f3fa303e75ef5e2d6a79b9062514a"
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:45392161cfdf863d023c1a0e65dedea5470c8ea9"
2 changes: 1 addition & 1 deletion Dojofile-dtest
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:38621b49ed7f3fa303e75ef5e2d6a79b9062514a"
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:45392161cfdf863d023c1a0e65dedea5470c8ea9"
DOJO_DRIVER=docker-compose
DOJO_DOCKER_COMPOSE_FILE=docker-compose-dtest.yml
2 changes: 1 addition & 1 deletion Dojofile-infra
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DOJO_DOCKER_IMAGE="nhsdev/deductions-infra-dojo:14-35ab462b"
DOJO_DOCKER_IMAGE="nhsdev/deductions-infra-dojo:24-47f9f50f"
2 changes: 1 addition & 1 deletion Dojofile-itest
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:38621b49ed7f3fa303e75ef5e2d6a79b9062514a"
DOJO_DOCKER_IMAGE="nhsdev/node-dojo:45392161cfdf863d023c1a0e65dedea5470c8ea9"
DOJO_DRIVER=docker-compose
DOJO_DOCKER_COMPOSE_FILE=docker-compose-itest.yml
8 changes: 4 additions & 4 deletions docker-compose-dtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ services:
ports:
- 3000:3000
localstack:
image: localstack/localstack:0.10.9
image: localstack/localstack:3.6.0
environment:
- SERVICES=s3:4572
- SERVICES=s3
- DEBUG=true
- PORT_WEB_UI=5555
- LAMBDA_EXECUTOR=local
- DATA_DIR=/tmp/localstack/data
- DOCKER_HOST=unix:///var/run/docker.sock
- S3_BUCKET_NAME=test-bucket
- LOCALSTACK_URL=http://localstack:4572
- GATEWAY_LISTEN=0.0.0.0:4572
volumes:
- ./scripts/create-bucket.sh:/docker-entrypoint-initaws.d/create-bucket.sh
- ./scripts/create-bucket.sh:/etc/localstack/init/ready.d/create-bucket.sh
- /var/run/docker.sock:/var/run/docker.sock
dynamodb-local:
image: amazon/dynamodb-local
Expand Down
10 changes: 4 additions & 6 deletions docker-compose-itest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ services:
ports:
- "3000:3000"
localstack:
image: localstack/localstack:0.10.9
image: localstack/localstack:3.6.0
environment:
- SERVICES=s3:4572
- SERVICES=s3
- S3_BUCKET_NAME=test-bucket
- LOCALSTACK_URL=http://localstack:4572
- GATEWAY_LISTEN=0.0.0.0:4572
ports:
- "4572:4572"
volumes:
- ./scripts/create-bucket.sh:/docker-entrypoint-initaws.d/create-bucket.sh
- ./scripts/create-bucket.sh:/etc/localstack/init/ready.d/create-bucket.sh
- /var/run/docker.sock:/var/run/docker.sock
logging:
driver: none
dynamodb-local:
image: amazon/dynamodb-local
command: "-jar DynamoDBLocal.jar -sharedDb -inMemory"
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.4'
services:
localstack:
image: localstack/localstack
image: localstack/localstack:3.6.0
ports:
- 4572:4572
- 5555:5555
Expand All @@ -13,7 +13,7 @@ services:
- LAMBDA_EXECUTOR=local
- DOCKER_HOST=unix:///var/run/docker.sock
- S3_BUCKET_NAME=test-bucket
- LOCALSTACK_URL=http://localstack:4572
- GATEWAY_LISTEN=0.0.0.0:4572
volumes:
- ./scripts/create-bucket.sh:/docker-entrypoint-initaws.d/create-bucket.sh
- ./scripts/create-bucket.sh:/etc/localstack/init/ready.d/create-bucket.sh
- /var/run/docker.sock:/var/run/docker.sock
Loading
Loading