Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actions, deduplicate tests #37

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 34 additions & 15 deletions .github/workflows/feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,22 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: build -Pversion=${{ steps.capture_version.outputs.app_version }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build & test
run: ./gradlew build -Pversion=${{ steps.capture_version.outputs.app_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: jacocoTestCoverageVerification
- name: Test coverage verification
run: ./gradlew jacocoTestCoverageVerification

- name: Integration Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: integrationTest --tests '*IntegrationTest'
- name: Integration test
run: ./gradlew integrationTest --tests '*IntegrationTest'

- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish -Pversion=${{ steps.capture_version.outputs.app_version }}
run: ./gradlew publish -Pversion=${{ steps.capture_version.outputs.app_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -72,6 +67,30 @@ jobs:
name: assessment-api-jar
path: assessment-service/build/libs/assessment-service-${{ steps.capture_version.outputs.app_version }}.jar

- name: Upload checkstyle report
if: always()
uses: actions/upload-artifact@v4
with:
name: checkstyle-report
path: assessment-service/build/reports/checkstyle
retention-days: 14

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: assessment-service/build/reports/tests
retention-days: 14

- name: Upload jacoco coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report
path: assessment-service/build/reports/jacoco
retention-days: 14

ecr:
needs: [ build-test-publish, define-image-tag ]
runs-on: ubuntu-latest
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,27 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Build JAR with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: assemble
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew assemble
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Capture version
shell: bash
id: capture_version
run: |
VERSION=$(grep "version=" gradle.properties | cut -d'=' -f2)
echo "app_version=${VERSION}" >> $GITHUB_OUTPUT
echo "Captured version: $VERSION"

- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: upload jarfile
uses: actions/upload-artifact@v4
with:
Expand Down
55 changes: 41 additions & 14 deletions .github/workflows/pr-merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,59 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: build
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build & test
run: ./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: jacocoTestCoverageVerification
- name: Test coverage verification
run: ./gradlew jacocoTestCoverageVerification

- name: Integration Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: integrationTest --tests '*IntegrationTest'
- name: Integration test
run: ./gradlew integrationTest --tests '*IntegrationTest'

- name: Set to github user
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions Bot"

- name: Update version
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
run: ./gradlew release -Prelease.useAutomaticVersion=true

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: assessment-service/build/test-results
retention-days: 14

- name: Upload checkstyle report
if: always()
uses: actions/upload-artifact@v4
with:
name: checkstyle-report
path: assessment-service/build/reports/checkstyle
retention-days: 14

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
arguments: release -Prelease.useAutomaticVersion=true
name: test-report
path: assessment-service/build/reports/tests
retention-days: 14

- name: Upload jacoco coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report
path: assessment-service/build/reports/jacoco
retention-days: 14


vulnerability-report:
if: github.event.pull_request.merged == true
Expand Down
53 changes: 35 additions & 18 deletions .github/workflows/push-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,52 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: build
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build & test
run: ./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: jacocoTestCoverageVerification
- name: Test coverage verification
run: ./gradlew jacocoTestCoverageVerification

- name: Integration Test
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: integrationTest --tests '*IntegrationTest'
- name: Integration test
run: ./gradlew integrationTest --tests '*IntegrationTest'

- name: Update snapshot version
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: updateSnapshotVersion
run: ./gradlew updateSnapshotVersion

- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload checkstyle report
if: always()
uses: actions/upload-artifact@v4
with:
name: checkstyle-report
path: assessment-service/build/reports/checkstyle
retention-days: 14

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: assessment-service/build/reports/tests
retention-days: 14

- name: Upload jacoco coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report
path: assessment-service/build/reports/jacoco
retention-days: 14

vulnerability-scan:
runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Please ensure this matches the command used by the [pr-merge-main](.github/workf
workflow to maintain consistency.

```shell
snyk monitor --org=legal-aid-agency --all-projects --exclude=build,generated
snyk monitor --org=legal-aid-agency --all-projects --exclude=build,generated --target-reference=main
```

You should then see the new vulnerability in the LAA Dashboard, otherwise it is a new
Expand Down
4 changes: 3 additions & 1 deletion assessment-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'

//Used for integration tests
implementation platform('org.testcontainers:testcontainers-bom:1.19.3')
testImplementation platform('org.testcontainers:testcontainers-bom:1.20.4')
testImplementation 'org.testcontainers:testcontainers'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:oracle-free'
}

test {
useJUnitPlatform()

finalizedBy jacocoTestReport
}

jacocoTestReport {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'net.researchgate.release' version '3.0.2'
id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.24' apply false
id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.25' apply false
}

subprojects {
Expand Down