Skip to content

[CTM-444, CTM-447] Upgrade swagger and jetty #552

[CTM-444, CTM-447] Upgrade swagger and jetty

[CTM-444, CTM-447] Upgrade swagger and jetty #552

name: Build, Test, Tag and Publish
on:
pull_request:
branches: [ '**' ]
push:
paths-ignore: [ '*.md' ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
# don't cancel in-progress workflows for pushes to main
cancel-in-progress: ${{ !(github.event_name == 'push' && github.ref_name == 'main') }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build all projects without running tests
run: ./gradlew --build-cache build -x test
unit-tests:
needs: [ build ]
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports: [ "5432:5432" ]
steps:
- uses: actions/checkout@v6
# Needed by sonar to get the git history for the branch the PR will be merged into.
with:
fetch-depth: 0
- name: Initialize Postgres DB
env:
PGPASSWORD: postgres
run: psql -h 127.0.0.1 -U postgres -f ./local-dev/local-postgres-init.sql
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Cache SonarCloud packages
uses: actions/cache@v5
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build, assemble, and test
id: build-test
run: ./gradlew --build-cache --scan test jacocoTestReport
# The SonarQube scan is done here, so it can upload the coverage report generated by the tests.
- name: SonarQube scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew --build-cache sonar
- name: Upload Test Reports
if: steps.build-test.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: Test Reports
path: service/build/reports
retention-days: 14
bump-check:
runs-on: ubuntu-latest
outputs:
is-bump: ${{ steps.bumpcheck.outputs.is-bump }}
steps:
- uses: actions/checkout@v6
- name: Skip version bump merges
id: bumpcheck
uses: ./.github/actions/bump-skip
with:
event-name: ${{ github.event_name }}
tag-job:
if: needs.bump-check.outputs.is-bump == 'no'
uses: ./.github/workflows/tag.yml
needs: [ build, unit-tests, bump-check ]
secrets: inherit
# Publish Docker image to Google Container Registry, also reports to Sherlock
docker-image-job:
if: needs.bump-check.outputs.is-bump == 'no'
needs: [ build, bump-check, tag-job ]
uses: ./.github/workflows/publish-docker.yml
with:
new-tag: ${{ needs.tag-job.outputs.new-tag }}
# Publish Python client to PyPI
python-client-job:
if: needs.bump-check.outputs.is-bump == 'no' && github.event_name == 'push' && github.ref_name == 'main'
needs: [ build, bump-check, tag-job ]
uses: ./.github/workflows/release-python-client.yml
with:
new-tag: ${{ needs.tag-job.outputs.new-tag }}
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# Publish Java client to Artifactory
java-client-job:
if: needs.bump-check.outputs.is-bump == 'no' && github.event_name == 'push' && github.ref_name == 'main'
needs: [ build, bump-check, tag-job ]
uses: ./.github/workflows/publish-java-client.yml
# Publish GitHub Release
release-job:
if: needs.bump-check.outputs.is-bump == 'no' && github.event_name == 'push' && github.ref_name == 'main'
needs: [ build, bump-check, tag-job ]
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
with:
# override release-drafter's version calculation to use the version generated by bumper
version: '${{ needs.tag-job.outputs.new-tag }}'
# publish the release; it is no longer draft
publish: true
config-name: release-drafter-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Get Jira ID
# Look for a Jira ID in the format 'CORE-###' within the commit message.
# If no Jira ID is found in the PR title, default to 'CORE-###'.
get-jira-id:
if: needs.bump-check.outputs.is-bump == 'no' && github.event_name == 'push' && github.ref_name == 'main'
needs: [ build, bump-check, tag-job ]
runs-on: ubuntu-latest
outputs:
jiraId: ${{ steps.set-jira-id.outputs.jiraId }}
steps:
- name: Set Jira ID
id: set-jira-id
run: |
JIRA_ID=$(echo "${{ github.event.head_commit.message }}" | grep -oE 'CORE-[0-9]+' | head -1 || echo 'CORE-###')
echo "jiraId=${JIRA_ID}" >> $GITHUB_OUTPUT
# Publish new version to DSP infrastructure
publish-app-version-job:
if: needs.bump-check.outputs.is-bump == 'no' && github.event_name == 'push' && github.ref_name == 'main'
needs: [ build, bump-check, tag-job, get-jira-id, docker-image-job ]
uses: ./.github/workflows/publish-app-version.yml
with:
new-tag: ${{ needs.tag-job.outputs.new-tag }}
jiraId: ${{ needs.get-jira-id.outputs.jiraId }}
secrets:
BROADBOT_TOKEN: ${{ secrets.BROADBOT_TOKEN }}