Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitallowed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id-token: write
1 change: 1 addition & 0 deletions .github/config/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TAG_FORMAT: "v${version}"
46 changes: 46 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#########################################################################
# Dependabot configuration file
#########################################################################

version: 2

updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "18:00" # UTC
open-pull-requests-limit: 20
commit-message:
prefix: "Upgrade: [dependabot] - "

###################################
# NPM workspace ##################
###################################
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "18:00"
open-pull-requests-limit: 20
versioning-strategy: increase
commit-message:
prefix: "Upgrade: [dependabot] - "

###################################
# Poetry #########################
###################################
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "18:00"
open-pull-requests-limit: 20
versioning-strategy: increase
commit-message:
prefix: "Upgrade: [dependabot] - "
59 changes: 59 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## 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.**

## Pull Request Naming

Pull requests should be named using the following format:

```text
Tag: [AEA-NNNN] - Short description
```

Tag can be one of:

- `Fix` - for a bug fix. (Patch release)
- `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release)
- `New` - implemented a new feature. (Minor release)
- `Breaking` - for a backwards-incompatible enhancement or feature. (Major release)
- `Docs` - changes to documentation only. (Patch release)
- `Build` - changes to build process only. (No release)
- `Upgrade` - for a dependency upgrade. (Patch release)
- `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release)

If the current release is x.y.z then
- a patch release increases z by 1
- a minor release increases y by 1
- a major release increases x by 1

Correct tagging is necessary for our automated versioning and release process.

The description of your pull request will be used as the commit message for the merge, and also be included in the changelog. Please ensure that your title is sufficiently descriptive.

### Rerunning Checks

If you need to rename your pull request, you can restart the checks by either:

- Closing and reopening the pull request
- pushing an empty commit
```bash
git commit --allow-empty -m 'trigger build'
git push
```
- Amend your last commit and force push to the branch
```bash
git commit --amend --no-edit
git push --force
```

Rerunning the checks from within the pull request will not use the updated title.
90 changes: 90 additions & 0 deletions .github/workflows/build_multi_arch_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and push docker image

on:
workflow_call:

jobs:

build_image:
permissions:
id-token: write
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-22.04
- arch: arm64
runner: ubuntu-22.04-arm
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
fetch-depth: 0

# use setup-node rather than asdf so that it works multi-arch
- name: setup node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f
with:
node-version-file: .tool-versions
- name: make install
run: |
make install-node

- name: Build container
run: |
make build-base-image
docker tag ghcr.io/nhsdigital/eps-devcontainer-base:latest ghcr.io/nhsdigital/eps-devcontainers:latest-${{ matrix.arch }}
docker save "ghcr.io/nhsdigital/eps-devcontainers:latest-${{ matrix.arch }}" -o eps-devcontainer-base-latest-${{ matrix.arch }}.img
env:
GH_TOKEN: ${{ github.token }}
ARCHITECTURE: ${{ matrix.arch }}
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
name: Upload docker images
with:
name: eps-devcontainer-base-latest-${{ matrix.arch }}.img
path: |
eps-devcontainer-base-latest-${{ matrix.arch }}.img

publish_image:
needs: build_image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Free Disk Space for Docker
uses: endersonmenezes/free-disk-space@e6ed9b02e683a3b55ed0252f1ee469ce3b39a885
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
rm_cmd: "rm"
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
- name: Download amd64 images
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: eps-devcontainer-base-latest-amd64.img
- name: Download arm64 images
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: eps-devcontainer-base-latest-arm64.img
- name: Load and push multi-arch image
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
echo "loading images"
docker load -i eps-devcontainer-base-latest-amd64.img
docker load -i eps-devcontainer-base-latest-arm64.img
echo "pushing images"
docker push ghcr.io/nhsdigital/eps-devcontainers:latest-amd64
docker push ghcr.io/nhsdigital/eps-devcontainers:latest-arm64
echo "creating manifest"
docker manifest create ghcr.io/nhsdigital/eps-devcontainers:latest \
--amend ghcr.io/nhsdigital/eps-devcontainers:latest-amd64 \
--amend ghcr.io/nhsdigital/eps-devcontainers:latest-arm64
echo "pushing manifest"
docker manifest push ghcr.io/nhsdigital/eps-devcontainers:latest
96 changes: 96 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: pull_request

on:
pull_request:
branches: [main]

env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}

jobs:
dependabot-auto-approve-and-merge:
needs: quality_checks
uses: NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@2b3ddfd1e59daf9905522d0140c6cd08e2547432
secrets:
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}

get_asdf_version:
runs-on: ubuntu-22.04
outputs:
asdf_version: ${{ steps.asdf-version.outputs.version }}
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8

- name: Get asdf version
id: asdf-version
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
- name: Load config value
id: load-config
run: |
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"

quality_checks:
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@trivy
needs: [get_asdf_version]
with:
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

pr_title_format_check:
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@2b3ddfd1e59daf9905522d0140c6cd08e2547432

get_issue_number:
runs-on: ubuntu-22.04
needs: quality_checks
outputs:
issue_number: ${{ steps.get_issue_number.outputs.result }}
version: ${{ steps.get_issue_number.outputs.version_number }}

steps:
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
name: get issue number
id: get_issue_number
with:
script: |
if (context.issue.number) {
// Return issue number if present
return context.issue.number;
} else {
// Otherwise return issue number from commit
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
}
result-encoding: string

get_commit_id:
runs-on: ubuntu-22.04
outputs:
commit_id: ${{ steps.commit_id.outputs.commit_id }}
sha_short: ${{ steps.commit_id.outputs.sha_short }}

steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
ref: ${{ env.BRANCH_NAME }}

- name: Get Commit ID
id: commit_id
run: |
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"


package_docker_image:
uses: ./.github/workflows/build_multi_arch_image.yml
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ install-hooks: install-python
install-hooks:
build-base-image: generate-language-version-files
CONTAINER_NAME=$(CONTAINER_NAME) \
devcontainer build \
npx devcontainer build \
--workspace-folder ./src/base/ \
--push false \
--platform linux/${ARCHITECTURE} \
--image-name "${IMAGE_NAME}"

generate-language-version-files:
Expand All @@ -31,3 +32,11 @@ scan-base-image:
--ignorefile .trivyignore.yaml \
--exit-code 1 \
--format table ${IMAGE_NAME}

lint: lint-githubactions

test:
echo "Not implemented"

lint-githubactions:
actionlint
17 changes: 11 additions & 6 deletions scripts/generate_language_version_files.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

# Get the current directory of the script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LANGUAGE_VERSIONS_DIR="${SCRIPT_DIR}/../src/base/.devcontainer/language_versions"

# Define repositories to fetch .tool-versions from
REPOS=(
"NHSDigital/electronic-prescription-service-clinical-prescription-tracker"
Expand Down Expand Up @@ -30,12 +34,13 @@ REPOS=(


# Define output files
NODEJS_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/nodejs-versions.txt"
PYTHON_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/python-versions.txt"
JAVA_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/java-versions.txt"
TERRAFORM_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/terraform-versions.txt"
GOLANG_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/golang-versions.txt"
ALL_LANGUAGES_FILE="/workspaces/eps-devcontainers/src/base/.devcontainer/language_versions/language-versions.txt"
mkdir -p "${LANGUAGE_VERSIONS_DIR}"
NODEJS_FILE="${LANGUAGE_VERSIONS_DIR}/nodejs-versions.txt"
PYTHON_FILE="${LANGUAGE_VERSIONS_DIR}/python-versions.txt"
JAVA_FILE="${LANGUAGE_VERSIONS_DIR}/java-versions.txt"
TERRAFORM_FILE="${LANGUAGE_VERSIONS_DIR}/terraform-versions.txt"
GOLANG_FILE="${LANGUAGE_VERSIONS_DIR}/golang-versions.txt"
ALL_LANGUAGES_FILE="${LANGUAGE_VERSIONS_DIR}/language-versions.txt"
# Clear existing files
true > "$NODEJS_FILE"
true > "$PYTHON_FILE"
Expand Down
Loading