Skip to content

Commit c150af4

Browse files
authored
Fix: [AEA-0000] - use sementic-version for release numbering (#44)
## Summary - Routine Change ### Details - switch to using sementic-version to manage versions
1 parent 9ddb5a5 commit c150af4

18 files changed

Lines changed: 6557 additions & 428 deletions

.devcontainer/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update \
99
openjdk-8-jdk 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
12+
xz-utils tk-dev liblzma-dev netcat ruby-full build-essential zlib1g-dev
1313

1414
# install aws stuff
1515
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
@@ -29,7 +29,10 @@ USER vscode
2929
# Install ASDF
3030
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3; \
3131
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc; \
32-
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc;
32+
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc; \
33+
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
34+
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
35+
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
3336

3437
ENV PATH="$PATH:/home/vscode/.asdf/bin/"
3538

@@ -41,7 +44,8 @@ RUN asdf plugin add python; \
4144
asdf plugin-add java; \
4245
asdf plugin-add maven; \
4346
asdf plugin add direnv; \
44-
asdf plugin add actionlint;
47+
asdf plugin add actionlint; \
48+
asdf plugin add nodejs;
4549

4650
WORKDIR /workspaces/validation-service-fhir-r4
4751
ADD .tool-versions /workspaces/validation-service-fhir-r4/.tool-versions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
}
6363
}
6464
},
65-
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/validation-service-fhir-r4; make install"
65+
"postCreateCommand": "rm -f ~/.docker/config.json; git config --global --add safe.directory /workspaces/eps-FHIR-validator-lambda; make install"
6666
// "features": {},
6767
// Use 'forwardPorts' to make a list of ports inside the container available locally.
6868
// "forwardPorts": [],

.github/dependabot.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# rebase-strategy is set to 'disabled', as automated rebasing was causing
1111
# too many CI environments to be created, reducing available capacity for
1212
# us and other teams as well.
13-
#########################################################################
13+
#########################################################################
1414

1515
version: 2
1616
updates:
@@ -20,7 +20,9 @@ updates:
2020
directory: "/"
2121
schedule:
2222
interval: "daily"
23-
23+
commit-message:
24+
prefix: "Upgrade: [dependabot] - "
25+
2426
###################################
2527
# Java workspace ##################
2628
###################################
@@ -30,6 +32,8 @@ updates:
3032
schedule:
3133
interval: "daily"
3234
open-pull-requests-limit: 20
35+
commit-message:
36+
prefix: "Upgrade: [dependabot] - "
3337

3438
###################################
3539
# Poetry #########################
@@ -39,3 +43,5 @@ updates:
3943
schedule:
4044
interval: "daily"
4145
versioning-strategy: increase
46+
commit-message:
47+
prefix: "Upgrade: [dependabot] - "

.github/pull_request_template.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,41 @@
1111
### Details
1212

1313
Add any summary information of what is in the change. **Remove this line if you have nothing to add.**
14+
15+
**Remove the sections below this line once you have named your PR**
16+
17+
## Pull Request Naming
18+
19+
Pull requests should be named using the following format:
20+
21+
```text
22+
Tag: [AEA-NNNN] - Short description
23+
```
24+
25+
Tag can be one of:
26+
27+
- `Fix` - for a bug fix. (Patch release)
28+
- `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release)
29+
- `New` - implemented a new feature. (Minor release)
30+
- `Breaking` - for a backwards-incompatible enhancement or feature. (Major release)
31+
- `Docs` - changes to documentation only. (Patch release)
32+
- `Build` - changes to build process only. (No release)
33+
- `Upgrade` - for a dependency upgrade. (Patch release)
34+
- `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release)
35+
36+
Correct tagging is necessary for our automated versioning and release process ([Release](./RELEASE.md)).
37+
38+
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.
39+
40+
### Rerunning Checks
41+
42+
If you need to rename your pull request, you can restart the checks by either:
43+
44+
- Closing and reopening the pull request
45+
- Amend your last commit and force push to the branch
46+
```bash
47+
git commit --amend --no-edit
48+
git push --force
49+
```
50+
51+
Rerunning the checks from within the pull request will not use the updated title.

.github/workflows/ci.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: merge to main workflow
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
env:
8+
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
9+
10+
jobs:
11+
quality_checks:
12+
uses: ./.github/workflows/quality_checks.yml
13+
secrets:
14+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15+
16+
get_commit_id:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
20+
steps:
21+
- name: Get Commit ID
22+
id: commit_id
23+
run: |
24+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
25+
26+
tag_release:
27+
needs: quality_checks
28+
runs-on: ubuntu-latest
29+
outputs:
30+
spec_version: ${{steps.output_spec_version.outputs.SPEC_VERSION}}
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ env.BRANCH_NAME }}
36+
fetch-depth: 0
37+
38+
# using git commit sha for version of action to ensure we have stable version
39+
- name: Install asdf
40+
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
41+
with:
42+
asdf_branch: v0.11.3
43+
44+
- name: Cache asdf
45+
uses: actions/cache@v4
46+
with:
47+
path: |
48+
~/.asdf
49+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
50+
restore-keys: |
51+
${{ runner.os }}-asdf-
52+
53+
- name: Install asdf dependencies in .tool-versions
54+
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
55+
with:
56+
asdf_branch: v0.11.3
57+
env:
58+
PYTHON_CONFIGURE_OPTS: --enable-shared
59+
60+
- name: Install node packages
61+
run: |
62+
make install-node
63+
64+
- name: Set SPEC_VERSION env var to be short git SHA and get next tag varsion
65+
id: output_spec_version
66+
run: |
67+
SPEC_VERSION=$(git rev-parse --short HEAD)
68+
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
69+
tagFormat=$(jq -r .tagFormat .releaserc)
70+
if [ "${tagFormat}" = "null" ]
71+
then
72+
tagFormat="v\${version}"
73+
fi
74+
# disabling shellcheck as replace does not work
75+
# shellcheck disable=SC2001
76+
NEW_SPEC_VERSION=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
77+
echo "## SPEC VERSION :** ${SPEC_VERSION}" >> "$GITHUB_STEP_SUMMARY"
78+
echo "## NEXT TAG WILL BE :** ${NEW_SPEC_VERSION}" >> "$GITHUB_STEP_SUMMARY"
79+
echo "SPEC_VERSION=${SPEC_VERSION }" >> "$GITHUB_OUTPUT"
80+
echo "SPEC_VERSION=${SPEC_VERSION}" >> "$GITHUB_ENV"
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
84+
package_code:
85+
needs: tag_release
86+
uses: ./.github/workflows/sam_package_code.yml
87+
88+
release_dev:
89+
needs: [tag_release, package_code, get_commit_id]
90+
uses: ./.github/workflows/sam_release_code.yml
91+
with:
92+
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
93+
STACK_NAME: fhir-validator
94+
TARGET_ENVIRONMENT: dev
95+
BUILD_ARTIFACT: packaged_code
96+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
97+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
98+
LOG_LEVEL: INFO
99+
LOG_RETENTION_DAYS: 30
100+
CREATE_INT_RELEASE_NOTES: true
101+
CREATE_PROD_RELEASE_NOTES: true
102+
secrets:
103+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
104+
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
105+
INT_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.INT_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
106+
PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE }}
107+
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
108+
109+
release_qa:
110+
needs: [tag_release, release_dev, package_code, get_commit_id]
111+
uses: ./.github/workflows/sam_release_code.yml
112+
with:
113+
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.spec_version}}
114+
STACK_NAME: fhir-validator
115+
TARGET_ENVIRONMENT: qa
116+
BUILD_ARTIFACT: packaged_code
117+
VERSION_NUMBER: ${{needs.tag_release.outputs.spec_version}}
118+
COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}}
119+
LOG_LEVEL: INFO
120+
LOG_RETENTION_DAYS: 30
121+
secrets:
122+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PR Title Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
pr_title_format_check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check PR Title is Prefixed with Change Type
11+
env:
12+
PR_TITLE: ${{ github.event.pull_request.title }}
13+
run: |
14+
if [[ "$PR_TITLE" =~ ^(Fix|Update|New|Breaking|Docs|Build|Upgrade|Chore):.*$ ]]; then
15+
echo "PR title is prefixed with change type."
16+
else
17+
echo "PR title is not prefixed with change type."
18+
echo "Please prefix your PR title with a change type (Fix, Update, New, Breaking, Docs, Build, Upgrade, Chore)."
19+
echo "See the contributing guide for more details:"
20+
echo "https://github.com/NHSDigital/nhs-fhir-middy-error-handler/blob/main/CONTRIBUTING.md"
21+
exit 1
22+
fi
23+
24+
- name: Check PR Title contains Ticket/Dependabot Reference
25+
env:
26+
PR_TITLE: ${{ github.event.pull_request.title }}
27+
run: |
28+
if [[ "$PR_TITLE" =~ ^.*:.*\[([A-Z]+-[0-9]+|dependabot)\].*-.*$ ]]; then
29+
echo "PR title contains ticket or dependabot reference."
30+
else
31+
echo "PR title does not contain ticket or dependabot reference."
32+
echo "Please ensure PR title contains a ticket (eg. 'Fix: [AEA-####] - ...', or 'Chore: [dependabot] - ...')."
33+
exit 1
34+
fi

.github/workflows/pull_request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
secrets:
1414
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1515

16+
pr_title_format_check:
17+
uses: ./.github/workflows/pr_title_check.yml
18+
1619
get_issue_number:
1720
runs-on: ubuntu-latest
1821
needs: quality_checks

.github/workflows/release.yml

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
name: release workflow
1+
name: release to environments
22

33
on:
4-
push:
5-
branches: [main]
6-
tags: [v**]
4+
workflow_dispatch:
75

86
env:
97
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
@@ -58,43 +56,56 @@ jobs:
5856
env:
5957
PYTHON_CONFIGURE_OPTS: --enable-shared
6058

61-
- name: Install python packages
59+
- name: Install node packages
6260
run: |
63-
make install-python
61+
make install-node
6462
65-
- name: Set SPEC_VERSION env var for merges to main
66-
run: echo "SPEC_VERSION=$(poetry run python scripts/calculate_version.py)" >> "$GITHUB_ENV"
67-
if: github.ref == 'refs/heads/main'
68-
69-
- name: Set SPEC_VERSION env var for tags
70-
run: echo "SPEC_VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV"
71-
if: github.ref != 'refs/heads/main'
72-
73-
- name: Create release (tags and main)
74-
id: create-release
75-
# using commit hash for version v1.13.0
76-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
77-
continue-on-error: true
63+
- name: Set SPEC_VERSION to be next tag varsion
64+
id: output_spec_version
65+
run: |
66+
NEXT_VERSION=$(npx semantic-release --dry-run | grep -i 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/')
67+
tagFormat=$(jq -r .tagFormat .releaserc)
68+
if [ "${tagFormat}" = "null" ]
69+
then
70+
tagFormat="v\${version}"
71+
fi
72+
# disabling shellcheck as replace does not work
73+
# shellcheck disable=SC2001
74+
SPEC_VERSION=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
75+
echo "## SPEC VERSION :** ${SPEC_VERSION}" >> "$GITHUB_STEP_SUMMARY"
76+
echo "SPEC_VERSION=${SPEC_VERSION }" >> "$GITHUB_OUTPUT"
77+
echo "SPEC_VERSION=${SPEC_VERSION}" >> "$GITHUB_ENV"
78+
env:
79+
GITHUB_TOKEN: ${{ github.token }}
80+
81+
- name: tag release
7882
env:
7983
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
run: |
85+
npx semantic-release
86+
87+
- name: Get release for editing
88+
id: get_release
89+
# version 1.2.4
90+
uses: cardinalby/git-get-release-action@cedef2faf69cb7c55b285bad07688d04430b7ada
91+
env:
92+
GITHUB_TOKEN: ${{ github.token }}
8093
with:
8194
tag: ${{ env.SPEC_VERSION }}
82-
commit: ${{ github.sha }}
95+
96+
- name: Edit Release
97+
# version 1.2.0
98+
uses: irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
99+
with:
100+
token: ${{ secrets.GITHUB_TOKEN }}
101+
id: ${{ steps.get_release.outputs.id }}
83102
body: |
84-
## Commit message
85-
${{ github.event.head_commit.message }}
86103
## Info
87104
[See code diff](${{ github.event.compare }})
88105
[Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
89106
90107
It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
91-
92-
- name: output SPEC_VERSION
93-
id: output_spec_version
94-
run: |
95-
echo "## RELEASE TAG :** ${{ env.SPEC_VERSION }}" >> "$GITHUB_STEP_SUMMARY"
96-
echo "SPEC_VERSION=${{ env.SPEC_VERSION }}" >> "$GITHUB_OUTPUT"
97-
108+
98109
package_code:
99110
needs: tag_release
100111
uses: ./.github/workflows/sam_package_code.yml

0 commit comments

Comments
 (0)