Skip to content

Commit 4e3d8af

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev_container_build
2 parents f19fc9c + cb3642c commit 4e3d8af

20 files changed

+492
-6820
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update \
99
jq apt-transport-https ca-certificates gnupg-agent \
1010
software-properties-common bash-completion python3-pip make libbz2-dev \
1111
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
12-
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev pre-commit
12+
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
1313

1414
USER vscode
1515

@@ -18,15 +18,20 @@ RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
1818
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
1919
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc;
2020

21-
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-prescription-tracker-ui/node_modules/.bin"
21+
ENV PATH="$PATH:/home/vscode/.asdf/bin/:/workspaces/eps-prescription-tracker-ui/node_modules/.bin:/workspaces/eps-workflow-quality-checks/.venv/bin"
2222

2323
# Install ASDF plugins#
24-
RUN asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
24+
RUN asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \
25+
asdf plugin add actionlint; \
26+
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \
27+
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \
28+
asdf plugin add python
2529

2630
WORKDIR /workspaces/eps-workflow-quality-checks
2731

2832
ADD .tool-versions /workspaces/eps-workflow-quality-checks/.tool-versions
2933
ADD .tool-versions /home/vscode/.tool-versions
3034

31-
RUN asdf install; \
35+
RUN asdf install python; \
36+
asdf install; \
3237
asdf reshim nodejs;

.gitallowed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"?
2+
.*\.gitallowed.*

.github/config/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAG_FORMAT: "v${version}"

.github/scripts/ignore.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
# dummy file for shellcheck to work

.github/workflows/pull_request.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: pr
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
env:
8+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
9+
10+
jobs:
11+
pr_title_format_check:
12+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
13+
get_asdf_version:
14+
runs-on: ubuntu-22.04
15+
outputs:
16+
asdf_version: ${{ steps.asdf-version.outputs.version }}
17+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v5
21+
22+
- name: Get asdf version
23+
id: asdf-version
24+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
25+
- name: Load config value
26+
id: load-config
27+
run: |
28+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
29+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
30+
quality_checks:
31+
uses: ./.github/workflows/quality-checks.yml
32+
needs: [get_asdf_version]
33+
with:
34+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
35+
secrets:
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
tag_release:
38+
needs: [quality_checks, get_asdf_version]
39+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
40+
with:
41+
dry_run: true
42+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
43+
branch_name: ${{ github.event.pull_request.head.ref }}
44+
publish_package: false
45+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
46+
secrets: inherit

.github/workflows/quality-checks.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
description: Toggle to run sonar code analyis on this repository.
1717
default: true
1818
required: false
19+
asdfVersion:
20+
type: string
21+
required: true
1922
reinstall_poetry:
2023
type: boolean
2124
description: Toggle to reinstall poetry on top of python version installed by asdf.
@@ -31,8 +34,8 @@ jobs:
3134
- uses: actions/setup-java@v5
3235
if: ${{ inputs.install_java }}
3336
with:
34-
java-version: '21'
35-
distribution: 'corretto'
37+
java-version: "21"
38+
distribution: "corretto"
3639

3740
- name: Checkout code
3841
uses: actions/checkout@v5
@@ -99,7 +102,7 @@ jobs:
99102
run: |
100103
poetry_tool_version=$(cat .tool-versions | grep poetry)
101104
poetry_version=${poetry_tool_version//"poetry "}
102-
asdf uninstall poetry $poetry_version
105+
asdf uninstall poetry "$poetry_version"
103106
asdf install poetry
104107
105108
- name: Setting up .npmrc
@@ -116,16 +119,16 @@ jobs:
116119
- name: Check if project uses Poetry
117120
id: check_poetry
118121
run: |
119-
if [ -f pyproject.toml ] && grep -q '\[tool.poetry\]' pyproject.toml; then
122+
if [ -f "pyproject.toml" ] && grep -q '\[tool.poetry\]' "pyproject.toml"; then
120123
echo "****************"
121124
echo "Project uses poetry"
122125
echo "****************"
123-
echo "uses_poetry=true" >> $GITHUB_OUTPUT
126+
echo "uses_poetry=true" >> "$GITHUB_OUTPUT"
124127
else
125128
echo "****************"
126129
echo "Project does not use poetry"
127130
echo "****************"
128-
echo "uses_poetry=false" >> $GITHUB_OUTPUT
131+
echo "uses_poetry=false" >> "$GITHUB_OUTPUT"
129132
fi
130133
131134
- name: Check if project uses Java
@@ -135,27 +138,27 @@ jobs:
135138
echo "****************"
136139
echo "Detected a Java project"
137140
echo "****************"
138-
echo "uses_java=true" >> $GITHUB_OUTPUT
141+
echo "uses_java=true" >> "$GITHUB_OUTPUT"
139142
else
140143
echo "****************"
141144
echo "Project does not use Java"
142145
echo "****************"
143-
echo "uses_java=false" >> $GITHUB_OUTPUT
146+
echo "uses_java=false" >> "$GITHUB_OUTPUT"
144147
fi
145-
148+
146149
- name: Check for SAM templates
147150
id: check_sam_templates
148151
run: |
149152
if [ -d "SAMtemplates" ]; then
150153
echo "****************"
151154
echo "Project has SAM templates"
152155
echo "****************"
153-
echo "sam_exists=true" >> $GITHUB_OUTPUT
156+
echo "sam_exists=true" >> "$GITHUB_OUTPUT"
154157
else
155158
echo "****************"
156159
echo "Project does not have SAM templates"
157160
echo "****************"
158-
echo "sam_exists=false" >> $GITHUB_OUTPUT
161+
echo "sam_exists=false" >> "$GITHUB_OUTPUT"
159162
fi
160163
161164
- name: Check for cloudformation templates
@@ -165,27 +168,27 @@ jobs:
165168
echo "****************"
166169
echo "Project has cloudformation templates"
167170
echo "****************"
168-
echo "cf_exists=true" >> $GITHUB_OUTPUT
171+
echo "cf_exists=true" >> "$GITHUB_OUTPUT"
169172
else
170173
echo "****************"
171174
echo "Project does not have cloudformation templates"
172175
echo "****************"
173-
echo "cf_exists=false" >> $GITHUB_OUTPUT
176+
echo "cf_exists=false" >> "$GITHUB_OUTPUT"
174177
fi
175-
178+
176179
- name: Check for cdk
177180
id: check_cdk
178181
run: |
179182
if [ -d "packages/cdk" ]; then
180183
echo "****************"
181184
echo "Project has cdk"
182185
echo "****************"
183-
echo "cdk_exists=true" >> $GITHUB_OUTPUT
186+
echo "cdk_exists=true" >> "$GITHUB_OUTPUT"
184187
else
185188
echo "****************"
186189
echo "Project does not have cdk"
187190
echo "****************"
188-
echo "cdk_exists=false" >> $GITHUB_OUTPUT
191+
echo "cdk_exists=false" >> "$GITHUB_OUTPUT"
189192
fi
190193
191194
- name: Check licenses (Makefile)
@@ -206,7 +209,7 @@ jobs:
206209
207210
# known packages with dual licensing
208211
IGNORE_PACKAGES="PyGithub chardet text-unidecode"
209-
LICENSES=$(poetry run pip-licenses --ignore-packages ${IGNORE_PACKAGES})
212+
LICENSES=$(poetry run pip-licenses --ignore-packages "${IGNORE_PACKAGES}")
210213
INCOMPATIBLE_LIBS=$(echo "$LICENSES" | grep 'GPL' || true)
211214
212215
if [[ -z $INCOMPATIBLE_LIBS ]]; then
@@ -217,7 +220,7 @@ jobs:
217220
echo "$INCOMPATIBLE_LIBS"
218221
exit 1
219222
fi
220-
223+
221224
- name: Run code lint
222225
run: make lint
223226

@@ -242,12 +245,12 @@ jobs:
242245
243246
- name: Run unit tests
244247
run: make test
245-
248+
246249
- name: Run cdk-synth
247250
if: steps.check_cdk.outputs.cdk_exists == 'true'
248251
run: |
249252
make cdk-synth
250-
253+
251254
- name: Install AWS SAM CLI
252255
if: steps.check_sam_templates.outputs.sam_exists == 'true'
253256
run: |
@@ -342,8 +345,8 @@ jobs:
342345
uses: NHSDigital/eps-action-sbom@main
343346

344347
- name: "check is SONAR_TOKEN exists"
345-
env:
346-
super_secret: ${{ secrets.SONAR_TOKEN }}
348+
env:
349+
super_secret: ${{ secrets.SONAR_TOKEN }}
347350
if: ${{ env.super_secret != '' && inputs.run_sonar == true }}
348351
run: echo "SONAR_TOKEN_EXISTS=true" >> "$GITHUB_ENV"
349352

.github/workflows/release.yml

Lines changed: 28 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,37 @@ env:
88
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
99

1010
jobs:
11-
tag_release:
12-
runs-on: ubuntu-latest
11+
get_asdf_version:
12+
runs-on: ubuntu-22.04
1313
outputs:
14-
version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }}
14+
asdf_version: ${{ steps.asdf-version.outputs.version }}
15+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
1516
steps:
1617
- name: Checkout code
1718
uses: actions/checkout@v5
18-
with:
19-
ref: ${{ env.BRANCH_NAME }}
20-
fetch-depth: 0
21-
22-
# using git commit sha for version of action to ensure we have stable version
23-
- name: Install asdf
24-
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
25-
with:
26-
asdf_branch: v0.14.1
27-
28-
- name: Cache asdf
29-
uses: actions/cache@v4
30-
with:
31-
path: |
32-
~/.asdf
33-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
34-
restore-keys: |
35-
${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
36-
37-
- name: Install asdf dependencies in .tool-versions
38-
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
39-
with:
40-
asdf_branch: v0.14.1
41-
42-
- name: Install dependencies
43-
run: |
44-
make install
45-
46-
- name: Set VERSION_TAG to be next tag varsion
47-
id: output_version_tag
48-
run: |
49-
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
50-
tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
51-
if [ "${tagFormat}" = "null" ]
52-
then
53-
tagFormat="v\${version}"
54-
fi
55-
# disabling shellcheck as replace does not work
56-
# shellcheck disable=SC2001
57-
VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
58-
echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
59-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
60-
echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
61-
env:
62-
GITHUB_TOKEN: ${{ github.token }}
6319

64-
- name: tag release
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Get asdf version
21+
id: asdf-version
22+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
23+
- name: Load config value
24+
id: load-config
6725
run: |
68-
npx semantic-release
69-
70-
- name: Get release for editing
71-
id: get_release
72-
# version 1.2.4
73-
uses: cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
74-
env:
75-
GITHUB_TOKEN: ${{ github.token }}
76-
with:
77-
tag: ${{ env.VERSION_TAG }}
78-
79-
- name: Edit Release
80-
# version 1.2.0
81-
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
82-
with:
83-
token: ${{ secrets.GITHUB_TOKEN }}
84-
id: ${{ steps.get_release.outputs.id }}
85-
body: |
86-
## Info
87-
[See code diff](${{ github.event.compare }})
88-
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
89-
90-
It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
26+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
27+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
28+
quality_checks:
29+
needs: [get_asdf_version]
30+
uses: ./.github/workflows/quality-checks.yml
31+
with:
32+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
33+
secrets:
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35+
tag_release:
36+
needs: [quality_checks, get_asdf_version]
37+
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
38+
with:
39+
dry_run: false
40+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
41+
branch_name: main
42+
publish_package: false
43+
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
44+
secrets: inherit

0 commit comments

Comments
 (0)