Skip to content

Commit 9f8142b

Browse files
committed
feature: amp-126 init project
1 parent 55fe2f2 commit 9f8142b

File tree

12 files changed

+526
-0
lines changed

12 files changed

+526
-0
lines changed

github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @hmcts/api-marketplace

github/CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contribution guidelines
2+
3+
We're happy to accept 3rd-party contributions. Please make sure you read this document before you do any work though,
4+
as we have some expectations related to the content and quality of change sets.
5+
6+
## Before contributing
7+
8+
Any ideas on the user journeys and general service experience you may have **should be first consulted
9+
with us by submitting a new issue** to this repository. Ideas are always welcome, but if something is divergent or unrelated
10+
to what we're trying to achieve we won't be able to accept it. Please keep this in mind as we don't want to waste anybody's time.
11+
12+
In the interest of creating a friendly collaboration environment, please read and adhere to an open source contributor's
13+
[code of conduct](http://contributor-covenant.org/version/1/4/).
14+
15+
## Making a contribution
16+
17+
After your idea has been accepted you can implement it. We don't allow direct changes to the codebase from the public,
18+
they have to go through a review first.
19+
20+
Here's what you should do:
21+
1. [fork](https://help.github.com/articles/fork-a-repo/) this repository and clone it to your machine,
22+
2. create a new branch for your change:
23+
* use the latest *main* to branch from,
24+
3. implement the change in your branch:
25+
* if the change is non-trivial it's a good practice to split it into several logically independent units and deliver
26+
each one as a separate commit,
27+
* make sure the commit messages use proper language and accurately describe commit's content, e.g. *"Unify postcode lookup elements spacing"*.
28+
More information on good commit messages can be found [here](http://chris.beams.io/posts/git-commit/),
29+
4. test if your feature works as expected and does not break any existing features, this may include implementing additional automated tests or amending existing ones,
30+
5. push the change to your GitHub fork,
31+
6. submit a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) to our repository:
32+
* ensure that the pull request and related GitHub issue reference each other.
33+
34+
At this point the pull request will wait for someone from our team to review. It may be accepted straight away,
35+
or we may ask you to make some additional amendments before incorporating it into the main branch.

github/ISSUE_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### What would you like to change?
2+
3+
### How do you think that would improve the project?
4+
5+
### If this entry is related to a bug, please provide the steps to reproduce it

github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Before creating a pull request make sure that:**
2+
3+
- [ ] commit messages are meaningful and follow good commit message guidelines
4+
- [ ] README and other documentation has been updated / added (if needed)
5+
- [ ] tests have been updated / new tests has been added (if needed)
6+
7+
Please remove this line and everything above and fill the following sections:
8+
9+
10+
### JIRA link (if applicable) ###
11+
12+
13+
14+
### Change description ###
15+
16+
17+
18+
**Does this PR introduce a breaking change?** (check one with "x")
19+
20+
```
21+
[ ] Yes
22+
[ ] No
23+
```

github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gradle"
4+
directory: "/" # location of build.gradle
5+
schedule:
6+
interval: "daily" # or "weekly", "monthly"
7+
open-pull-requests-limit: 5
8+
commit-message:
9+
prefix: "chore(deps)"
10+
groups:
11+
all-dependencies:
12+
patterns:
13+
- "*"
14+
15+
- package-ecosystem: "github-actions"
16+
directory: "/" # location of your workflow files
17+
schedule:
18+
interval: "weekly"

github/pmd-ruleset.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="Custom Ruleset"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
6+
https://pmd.github.io/pmd-7.17.0/pmd-7.17.0.xsd">
7+
8+
<description>Custom ruleset including exclusions</description>
9+
10+
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
11+
<properties>
12+
<!-- This regex allows underscores in JUnit 5 test method names -->
13+
<property name="junit5TestPattern" value="^[a-z][a-zA-Z0-9_]*$"/>
14+
</properties>
15+
</rule>
16+
<rule ref="category/java/bestpractices.xml">
17+
<exclude name="GuardLogStatement"/>
18+
<exclude name="UnitTestAssertionsShouldIncludeMessage"/>
19+
<exclude name="UnitTestContainsTooManyAsserts"/>
20+
<exclude name="PreserveStackTrace"/>
21+
</rule>
22+
<rule ref="category/java/codestyle.xml">
23+
<exclude name="AtLeastOneConstructor"/>
24+
<exclude name="CallSuperInConstructor"/>
25+
<exclude name="LongVariable"/>
26+
<exclude name="ShortVariable"/>
27+
<exclude name="TooManyStaticImports"/>
28+
</rule>
29+
<rule ref="category/java/errorprone.xml">
30+
<exclude name="InvalidLogMessageFormat"/>
31+
</rule>
32+
<rule ref="category/java/performance.xml"/>
33+
<rule ref="category/java/security.xml"/>
34+
</ruleset>
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: CI Build and Publish
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
AZURE_DEVOPS_ARTIFACT_USERNAME:
7+
required: true
8+
AZURE_DEVOPS_ARTIFACT_TOKEN:
9+
required: true
10+
HMCTS_ADO_PAT:
11+
required: true
12+
inputs:
13+
is_release:
14+
required: false
15+
type: boolean
16+
default: false
17+
is_publish:
18+
required: true
19+
type: boolean
20+
trigger_docker:
21+
required: true
22+
type: boolean
23+
trigger_deploy:
24+
required: true
25+
type: boolean
26+
27+
28+
jobs:
29+
Artefact-Version:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
artefact_version: ${{ inputs.is_release && steps.artefact.outputs.release_version || steps.artefact.outputs.draft_version }}
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v6
36+
with:
37+
fetch-depth: 0
38+
39+
- name: Generate Artefact Version
40+
id: artefact
41+
uses: hmcts/artefact-version-action@v1
42+
with:
43+
release: ${{ inputs.is_release }}
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
Build:
48+
needs: [Artefact-Version]
49+
runs-on: ubuntu-latest
50+
outputs:
51+
repo_name: ${{ steps.repo_vars.outputs.repo_name }}
52+
artefact_name: ${{ steps.repo_vars.outputs.artefact_name }}
53+
steps:
54+
- name: Checkout source code
55+
uses: actions/checkout@v6
56+
57+
- name: Set up JDK
58+
uses: actions/setup-java@v5
59+
with:
60+
distribution: 'temurin'
61+
java-version: '21'
62+
63+
- name: Set up Gradle
64+
uses: gradle/actions/setup-gradle@v5
65+
with:
66+
gradle-version: current
67+
68+
- name: Gradle Build
69+
env:
70+
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
71+
run: |
72+
echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION"
73+
gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION
74+
75+
- name: Extract repo name
76+
id: repo_vars
77+
run: |
78+
repo_name=${GITHUB_REPOSITORY##*/}
79+
echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT
80+
echo "artefact_name=${repo_name}-${{ needs.Artefact-Version.outputs.artefact_version }}" >> $GITHUB_OUTPUT
81+
82+
- name: Upload JAR Artefact
83+
uses: actions/upload-artifact@v5
84+
with:
85+
name: app-jar
86+
path: build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar
87+
88+
Provider-Deploy:
89+
needs: [ Artefact-Version, Build ]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Checkout source code
93+
uses: actions/checkout@v6
94+
95+
- name: Set up JDK
96+
uses: actions/setup-java@v5
97+
with:
98+
distribution: 'temurin'
99+
java-version: '21'
100+
101+
- name: Set up Gradle
102+
uses: gradle/actions/setup-gradle@v5
103+
with:
104+
gradle-version: current
105+
106+
- name: Gradle Publish
107+
if: ${{ inputs.is_publish }}
108+
env:
109+
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
112+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
113+
run: |
114+
if [ -z "AZURE_DEVOPS_ARTIFACT_USERNAME" ]; then
115+
echo "::warning::AZURE_DEVOPS_ARTIFACT_USERNAME is null or not set"
116+
fi
117+
118+
if [ -z "$AZURE_DEVOPS_ARTIFACT_TOKEN" ]; then
119+
echo "::warning::AZURE_DEVOPS_ARTIFACT_TOKEN is null or not set"
120+
fi
121+
122+
echo "Publishing artefact for version: $ARTEFACT_VERSION"
123+
124+
gradle publish \
125+
-DARTEFACT_VERSION=$ARTEFACT_VERSION \
126+
-DGITHUB_REPOSITORY=${{ github.repository }} \
127+
-DGITHUB_ACTOR=${{ github.actor }} \
128+
-DGITHUB_TOKEN=$GITHUB_TOKEN \
129+
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$AZURE_DEVOPS_ARTIFACT_USERNAME \
130+
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN
131+
132+
Build-Docker:
133+
needs: [ Provider-Deploy, Build, Artefact-Version ]
134+
if: ${{ inputs.trigger_docker }}
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Checkout Code
138+
uses: actions/checkout@v6
139+
140+
- name: Download JAR Artefact
141+
uses: actions/download-artifact@v6
142+
with:
143+
name: app-jar
144+
path: build/libs
145+
146+
- name: Set up Docker Buildx
147+
uses: docker/setup-buildx-action@v3
148+
149+
- name: Log in to GitHub Packages
150+
uses: docker/login-action@v3
151+
with:
152+
registry: ghcr.io
153+
username: ${{ github.actor }}
154+
password: ${{ secrets.GITHUB_TOKEN }}
155+
156+
- name: Build and Push Docker Image to GitHub
157+
uses: docker/build-push-action@v6
158+
with:
159+
context: .
160+
file: Dockerfile
161+
push: true
162+
tags: |
163+
ghcr.io/${{ github.repository }}:${{ needs.Artefact-Version.outputs.artefact_version }}
164+
build-args: |
165+
BASE_IMAGE=openjdk:21-jdk-slim
166+
JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar
167+
168+
Deploy:
169+
needs: [ Provider-Deploy, Build, Artefact-Version ]
170+
if: ${{ inputs.trigger_deploy }}
171+
runs-on: ubuntu-latest
172+
steps:
173+
- name: Extract repo name
174+
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
175+
176+
- name: Trigger ADO pipeline
177+
uses: hmcts/trigger-ado-pipeline@v1
178+
with:
179+
pipeline_id: 460
180+
ado_pat: ${{ secrets.HMCTS_ADO_PAT }}
181+
template_parameters: >
182+
{
183+
"GROUP_ID": "uk.gov.hmcts.cp",
184+
"ARTIFACT_ID": "${{ env.REPO_NAME }}",
185+
"ARTIFACT_VERSION": "${{ needs.Artefact-Version.outputs.artefact_version }}",
186+
"TARGET_REPOSITORY": "${{ github.repository }}"
187+
}
188+

github/workflows/ci-draft.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build and Publish (Non-Release)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- main
8+
push:
9+
branches:
10+
- master
11+
- main
12+
13+
jobs:
14+
ci-draft:
15+
uses: ./.github/workflows/ci-build-publish.yml
16+
secrets:
17+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
18+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
19+
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
20+
with:
21+
is_publish: ${{ github.event_name == 'push' }}
22+
trigger_docker: ${{ github.event_name == 'push' }}
23+
trigger_deploy: ${{ github.event_name == 'push' }}

github/workflows/ci-released.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI Build and Publish – Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
ci-release:
10+
uses: ./.github/workflows/ci-build-publish.yml
11+
secrets:
12+
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
13+
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
14+
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
15+
with:
16+
is_release: true
17+
is_publish: true
18+
trigger_docker: true
19+
trigger_deploy: true

github/workflows/code-analysis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Code analysis
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
- main
8+
9+
jobs:
10+
pmd-analysis:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: actions/setup-java@v5
18+
with:
19+
distribution: 'temurin'
20+
java-version: '21'
21+
22+
- uses: pmd/pmd-github-action@v2
23+
id: pmd
24+
with:
25+
rulesets: '.github/pmd-ruleset.xml'
26+
sourcePath: 'src/main/java'
27+
analyzeModifiedFilesOnly: false
28+
29+
- name: Fail build if there are violations
30+
if: always()
31+
run: |
32+
VIOLATIONS="${{ steps.pmd.outputs.violations }}"
33+
if [ -n "$VIOLATIONS" ] && [ "$VIOLATIONS" != "0" ]; then
34+
echo "PMD found $VIOLATIONS violations"
35+
exit 1
36+
fi

0 commit comments

Comments
 (0)