Skip to content
Merged
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 .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @hmcts/api-marketplace
35 changes: 35 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contribution guidelines

We're happy to accept 3rd-party contributions. Please make sure you read this document before you do any work though,
as we have some expectations related to the content and quality of change sets.

## Before contributing

Any ideas on the user journeys and general service experience you may have **should be first consulted
with us by submitting a new issue** to this repository. Ideas are always welcome, but if something is divergent or unrelated
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.

In the interest of creating a friendly collaboration environment, please read and adhere to an open source contributor's
[code of conduct](http://contributor-covenant.org/version/1/4/).

## Making a contribution

After your idea has been accepted you can implement it. We don't allow direct changes to the codebase from the public,
they have to go through a review first.

Here's what you should do:
1. [fork](https://help.github.com/articles/fork-a-repo/) this repository and clone it to your machine,
2. create a new branch for your change:
* use the latest *main* to branch from,
3. implement the change in your branch:
* if the change is non-trivial it's a good practice to split it into several logically independent units and deliver
each one as a separate commit,
* make sure the commit messages use proper language and accurately describe commit's content, e.g. *"Unify postcode lookup elements spacing"*.
More information on good commit messages can be found [here](http://chris.beams.io/posts/git-commit/),
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,
5. push the change to your GitHub fork,
6. submit a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) to our repository:
* ensure that the pull request and related GitHub issue reference each other.

At this point the pull request will wait for someone from our team to review. It may be accepted straight away,
or we may ask you to make some additional amendments before incorporating it into the main branch.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### What would you like to change?

### How do you think that would improve the project?

### If this entry is related to a bug, please provide the steps to reproduce it
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Before creating a pull request make sure that:**

- [ ] commit messages are meaningful and follow good commit message guidelines
- [ ] README and other documentation has been updated / added (if needed)
- [ ] tests have been updated / new tests has been added (if needed)

Please remove this line and everything above and fill the following sections:


### JIRA link (if applicable) ###



### Change description ###



**Does this PR introduce a breaking change?** (check one with "x")

```
[ ] Yes
[ ] No
```
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/" # location of build.gradle
schedule:
interval: "daily" # or "weekly", "monthly"
open-pull-requests-limit: 5
commit-message:
prefix: "chore(deps)"
groups:
all-dependencies:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/" # location of your workflow files
schedule:
interval: "weekly"
34 changes: 34 additions & 0 deletions .github/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
https://pmd.github.io/pmd-7.17.0/pmd-7.17.0.xsd">

<description>Custom ruleset including exclusions</description>

<rule ref="category/java/codestyle.xml/MethodNamingConventions">
<properties>
<!-- This regex allows underscores in JUnit 5 test method names -->
<property name="junit5TestPattern" value="^[a-z][a-zA-Z0-9_]*$"/>
</properties>
</rule>
<rule ref="category/java/bestpractices.xml">
<exclude name="GuardLogStatement"/>
<exclude name="UnitTestAssertionsShouldIncludeMessage"/>
<exclude name="UnitTestContainsTooManyAsserts"/>
<exclude name="PreserveStackTrace"/>
</rule>
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="CallSuperInConstructor"/>
<exclude name="LongVariable"/>
<exclude name="ShortVariable"/>
<exclude name="TooManyStaticImports"/>
</rule>
<rule ref="category/java/errorprone.xml">
<exclude name="InvalidLogMessageFormat"/>
</rule>
<rule ref="category/java/performance.xml"/>
<rule ref="category/java/security.xml"/>
</ruleset>
188 changes: 188 additions & 0 deletions .github/workflows/ci-build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: CI Build and Publish

on:
workflow_call:
secrets:
AZURE_DEVOPS_ARTIFACT_USERNAME:
required: true
AZURE_DEVOPS_ARTIFACT_TOKEN:
required: true
HMCTS_ADO_PAT:
required: true
inputs:
is_release:
required: false
type: boolean
default: false
is_publish:
required: true
type: boolean
trigger_docker:
required: true
type: boolean
trigger_deploy:
required: true
type: boolean


jobs:
Artefact-Version:
runs-on: ubuntu-latest
outputs:
artefact_version: ${{ inputs.is_release && steps.artefact.outputs.release_version || steps.artefact.outputs.draft_version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Generate Artefact Version
id: artefact
uses: hmcts/artefact-version-action@v1
with:
release: ${{ inputs.is_release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Build:
needs: [Artefact-Version]
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_vars.outputs.repo_name }}
artefact_name: ${{ steps.repo_vars.outputs.artefact_name }}
steps:
- name: Checkout source code
uses: actions/checkout@v6

- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v5
with:
gradle-version: current

- name: Gradle Build
env:
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
run: |
echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION"
gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION

- name: Extract repo name
id: repo_vars
run: |
repo_name=${GITHUB_REPOSITORY##*/}
echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT
echo "artefact_name=${repo_name}-${{ needs.Artefact-Version.outputs.artefact_version }}" >> $GITHUB_OUTPUT

- name: Upload JAR Artefact
uses: actions/upload-artifact@v5
with:
name: app-jar
path: build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar

Provider-Deploy:
needs: [ Artefact-Version, Build ]
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v6

- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v5
with:
gradle-version: current

- name: Gradle Publish
if: ${{ inputs.is_publish }}
env:
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
run: |
if [ -z "AZURE_DEVOPS_ARTIFACT_USERNAME" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_USERNAME is null or not set"
fi

if [ -z "$AZURE_DEVOPS_ARTIFACT_TOKEN" ]; then
echo "::warning::AZURE_DEVOPS_ARTIFACT_TOKEN is null or not set"
fi

echo "Publishing artefact for version: $ARTEFACT_VERSION"

gradle publish \
-DARTEFACT_VERSION=$ARTEFACT_VERSION \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN \
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$AZURE_DEVOPS_ARTIFACT_USERNAME \
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN

Build-Docker:
needs: [ Provider-Deploy, Build, Artefact-Version ]
if: ${{ inputs.trigger_docker }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6

- name: Download JAR Artefact
uses: actions/download-artifact@v6
with:
name: app-jar
path: build/libs

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image to GitHub
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ needs.Artefact-Version.outputs.artefact_version }}
build-args: |
BASE_IMAGE=openjdk:21-jdk-slim
JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar

Deploy:
needs: [ Provider-Deploy, Build, Artefact-Version ]
if: ${{ inputs.trigger_deploy }}
runs-on: ubuntu-latest
steps:
- name: Extract repo name
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

- name: Trigger ADO pipeline
uses: hmcts/trigger-ado-pipeline@v1
with:
pipeline_id: 460
ado_pat: ${{ secrets.HMCTS_ADO_PAT }}
template_parameters: >
{
"GROUP_ID": "uk.gov.hmcts.cp",
"ARTIFACT_ID": "${{ env.REPO_NAME }}",
"ARTIFACT_VERSION": "${{ needs.Artefact-Version.outputs.artefact_version }}",
"TARGET_REPOSITORY": "${{ github.repository }}"
}

23 changes: 23 additions & 0 deletions .github/workflows/ci-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build and Publish (Non-Release)

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
ci-draft:
uses: ./.github/workflows/ci-build-publish.yml
secrets:
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
with:
is_publish: ${{ github.event_name == 'push' }}
trigger_docker: ${{ github.event_name == 'push' }}
trigger_deploy: ${{ github.event_name == 'push' }}
19 changes: 19 additions & 0 deletions .github/workflows/ci-released.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI Build and Publish – Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
ci-release:
uses: ./.github/workflows/ci-build-publish.yml
secrets:
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
HMCTS_ADO_PAT: ${{ secrets.HMCTS_CP_ADO_PAT }}
with:
is_release: true
is_publish: true
trigger_docker: true
trigger_deploy: true
36 changes: 36 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Code analysis

on:
pull_request:
branches:
- master
- main

jobs:
pmd-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'

- uses: pmd/pmd-github-action@v2
id: pmd
with:
rulesets: '.github/pmd-ruleset.xml'
sourcePath: 'src/main/java'
analyzeModifiedFilesOnly: false

- name: Fail build if there are violations
if: always()
run: |
VIOLATIONS="${{ steps.pmd.outputs.violations }}"
if [ -n "$VIOLATIONS" ] && [ "$VIOLATIONS" != "0" ]; then
echo "PMD found $VIOLATIONS violations"
exit 1
fi
Loading
Loading