-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
# Description :pencil: Summary: The proposed changes to move the lambda layer for processing secrets to a separate repository and publishing it as a release artifact for the tracker API will have a significant business impact. This modification ensures a more modular and scalable architecture, allowing for independent updates and version control, thereby enhancing the maintainability and flexibility of the system. It also facilitates the seamless upgrade of the secret processing functionality for the tracker API without disrupting other components, streamlining development and deployment processes. :ticket: Jira Reference: <https://nhsd-jira.digital.nhs.uk/browse/AEA-3612>
- Loading branch information
1 parent
75a7415
commit 17b2714
Showing
23 changed files
with
8,253 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu | ||
|
||
RUN apt-get update \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y dist-upgrade \ | ||
&& apt-get -y install --no-install-recommends htop vim curl git build-essential \ | ||
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \ | ||
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \ | ||
jq apt-transport-https ca-certificates gnupg-agent \ | ||
software-properties-common bash-completion python3-pip make libbz2-dev \ | ||
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ | ||
xz-utils tk-dev liblzma-dev netcat | ||
|
||
# install aws stuff | ||
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \ | ||
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \ | ||
/tmp/aws-cli/aws/install && \ | ||
rm tmp/awscliv2.zip && \ | ||
rm -rf /tmp/aws-cli | ||
|
||
USER vscode | ||
|
||
# Install ASDF | ||
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \ | ||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \ | ||
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; | ||
|
||
ENV PATH="$PATH:/home/vscode/.asdf/bin/" | ||
|
||
# Install ASDF plugins | ||
RUN asdf plugin add python; \ | ||
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \ | ||
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \ | ||
asdf plugin-add direnv; \ | ||
asdf plugin-add golang https://github.com/kennyp/asdf-golang.git; \ | ||
asdf plugin add golangci-lint https://github.com/hypnoglow/asdf-golangci-lint.git; \ | ||
asdf plugin add actionlint; | ||
|
||
|
||
WORKDIR /workspaces/electronic-prescription-service-get-secrets | ||
ADD .tool-versions /workspaces/electronic-prescription-service-get-secrets/.tool-versions | ||
ADD .tool-versions /home/vscode/.tool-versions | ||
|
||
RUN asdf install; \ | ||
asdf reshim python; \ | ||
asdf reshim poetry; \ | ||
asdf direnv setup --shell bash --version 2.32.2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "..", | ||
"args": {} | ||
}, | ||
"mounts": [ | ||
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind", | ||
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind", | ||
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind" | ||
], | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": { | ||
"version": "latest", | ||
"moby": "true", | ||
"installDockerBuildx": "true" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"AmazonWebServices.aws-toolkit-vscode", | ||
"redhat.vscode-yaml", | ||
"ms-python.python", | ||
"ms-python.flake8", | ||
"eamodio.gitlens", | ||
"github.vscode-pull-request-github", | ||
"lfm.vscode-makefile-term", | ||
"GrapeCity.gc-excelviewer", | ||
"redhat.vscode-xml", | ||
"streetsidesoftware.code-spell-checker", | ||
"timonwong.shellcheck", | ||
"mkhl.direnv", | ||
"github.vscode-github-actions" | ||
], | ||
"settings": { | ||
"python.defaultInterpreterPath": "/workspaces/electronic-prescription-service-get-secrets/.venv/bin/python", | ||
"python.analysis.autoSearchPaths": true, | ||
"python.analysis.extraPaths": [], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.enabled": true, // required to format on save | ||
"editor.formatOnPaste": false, // required | ||
"editor.formatOnType": false, // required | ||
"editor.formatOnSave": true, // optional | ||
"editor.formatOnSaveMode": "file", | ||
"cSpell.words": [ | ||
"fhir", | ||
"Formik", | ||
"pino", | ||
"serialisation" | ||
] | ||
} | ||
} | ||
}, | ||
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/electronic-prescription-service-get-secrets; make install; direnv allow ." | ||
// "features": {}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "" | ||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
######################################################################### | ||
# Dependabot configuration file | ||
######################################################################### | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
# Workflow files stored in the | ||
# default location of `.github/workflows` | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
################################### | ||
# NPM workspace ################## | ||
################################### | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
versioning-strategy: increase | ||
|
||
################################### | ||
# Poetry ######################### | ||
################################### | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
versioning-strategy: increase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Summary | ||
|
||
**Remove items from this list if they are not relevant. Remove this line once this has been done** | ||
|
||
- Routine Change | ||
- :exclamation: Breaking Change | ||
- :robot: Operational or Infrastructure Change | ||
- :sparkles: New Feature | ||
- :warning: Potential issues that might be caused by this change | ||
|
||
### Details | ||
|
||
Add any summary information of what is in the change. **Remove this line if you have nothing to add.** | ||
|
||
## Reviews Required | ||
|
||
**Check who should review this. Remove this line once this has been done** | ||
|
||
- [x] Dev | ||
- [ ] Test | ||
- [ ] Tech Author | ||
- [ ] Product Owner | ||
|
||
## Review Checklist | ||
|
||
:information_source: This section is to be filled in by the **reviewer**. | ||
|
||
- [ ] I have reviewed the changes in this PR and they fill all or part of the acceptance criteria of the ticket, and the code is in a mergeable state. | ||
- [ ] If there were infrastructure, operational, or build changes, I have made sure there is sufficient evidence that the changes will work. | ||
- [ ] I have ensured the jira ticket has been updated with the github pull request link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: build | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
SONAR_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BRANCH_NAME }} | ||
fetch-depth: 0 | ||
|
||
# using git commit sha for version of action to ensure we have stable version | ||
- name: Install asdf | ||
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 | ||
with: | ||
asdf_branch: v0.11.3 | ||
|
||
- name: Cache asdf | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.asdf | ||
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} | ||
restore-keys: | | ||
${{ runner.os }}-asdf- | ||
- name: Install asdf dependencies in .tool-versions | ||
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 | ||
with: | ||
asdf_branch: v0.11.3 | ||
env: | ||
PYTHON_CONFIGURE_OPTS: --enable-shared | ||
|
||
- name: make install | ||
run: | | ||
make install | ||
- name: run check-licenses | ||
run: make check-licenses | ||
|
||
- name: run lint | ||
run: make lint | ||
|
||
- name: run compile-go | ||
run: make compile-go | ||
|
||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packaged_code | ||
path: | | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
name: 'Combine PRs' | ||
|
||
# Controls when the action will run - in this case triggered manually | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branchPrefix: | ||
description: 'Branch prefix to find combinable PRs based on' | ||
required: true | ||
default: 'dependabot' | ||
mustBeGreen: | ||
description: 'Only combine PRs that are green (status is success)' | ||
required: true | ||
default: "true" | ||
combineBranchName: | ||
description: 'Name of the branch to combine PRs into' | ||
required: true | ||
default: 'combine-dependabot-PRs' | ||
ignoreLabel: | ||
description: 'Exclude PRs with this label' | ||
required: true | ||
default: 'nocombine' | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "combine-prs" | ||
combine-prs: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- uses: actions/github-script@v7 | ||
id: create-combined-pr | ||
name: Create Combined PR | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
let branchesAndPRStrings = []; | ||
let baseBranch = null; | ||
let baseBranchSHA = null; | ||
for (const pull of pulls) { | ||
const branch = pull['head']['ref']; | ||
console.log('Pull for branch: ' + branch); | ||
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) { | ||
console.log('Branch matched prefix: ' + branch); | ||
let statusOK = true; | ||
if(${{ github.event.inputs.mustBeGreen }}) { | ||
console.log('Checking green status: ' + branch); | ||
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) { | ||
repository(owner: $owner, name: $repo) { | ||
pullRequest(number:$pull_number) { | ||
commits(last: 1) { | ||
nodes { | ||
commit { | ||
statusCheckRollup { | ||
state | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
const vars = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pull['number'] | ||
}; | ||
const result = await github.graphql(stateQuery, vars); | ||
const [{ commit }] = result.repository.pullRequest.commits.nodes; | ||
const state = commit.statusCheckRollup.state | ||
console.log('Validating status: ' + state); | ||
if(state != 'SUCCESS') { | ||
console.log('Discarding ' + branch + ' with status ' + state); | ||
statusOK = false; | ||
} | ||
} | ||
console.log('Checking labels: ' + branch); | ||
const labels = pull['labels']; | ||
for(const label of labels) { | ||
const labelName = label['name']; | ||
console.log('Checking label: ' + labelName); | ||
if(labelName == '${{ github.event.inputs.ignoreLabel }}') { | ||
console.log('Discarding ' + branch + ' with label ' + labelName); | ||
statusOK = false; | ||
} | ||
} | ||
if (statusOK) { | ||
console.log('Adding branch to array: ' + branch); | ||
const prString = '#' + pull['number'] + ' ' + pull['title']; | ||
branchesAndPRStrings.push({ branch, prString }); | ||
baseBranch = pull['base']['ref']; | ||
baseBranchSHA = pull['base']['sha']; | ||
} | ||
} | ||
} | ||
if (branchesAndPRStrings.length == 0) { | ||
core.setFailed('No PRs/branches matched criteria'); | ||
return; | ||
} | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/heads/' + '${{ github.event.inputs.combineBranchName }}', | ||
sha: baseBranchSHA | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?'); | ||
return; | ||
} | ||
let combinedPRs = []; | ||
let mergeFailedPRs = []; | ||
for(const { branch, prString } of branchesAndPRStrings) { | ||
try { | ||
await github.rest.repos.merge({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
base: '${{ github.event.inputs.combineBranchName }}', | ||
head: branch, | ||
}); | ||
console.log('Merged branch ' + branch); | ||
combinedPRs.push(prString); | ||
} catch (error) { | ||
console.log('Failed to merge branch ' + branch); | ||
mergeFailedPRs.push(prString); | ||
} | ||
} | ||
console.log('Creating combined PR'); | ||
const combinedPRsString = combinedPRs.join('\n'); | ||
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString; | ||
if(mergeFailedPRs.length > 0) { | ||
const mergeFailedPRsString = mergeFailedPRs.join('\n'); | ||
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString | ||
} | ||
await github.rest.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: 'Combined PR', | ||
head: '${{ github.event.inputs.combineBranchName }}', | ||
base: baseBranch, | ||
body: body | ||
}); |
Oops, something went wrong.