Skip to content
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
8 changes: 7 additions & 1 deletion .github/workflows/ci-pr-checks-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ on:
type: string
required: false
default: ''
test-report-path:
description: Only for Spring Boot. Path(s) to test reports (e.g. Cucumber, Surefire, Failsafe) to upload as an artifact if the Maven build fails. One path per line, relative to the repository root. Requires maven-skip-tests to be false
type: string
required: false
default: ''
trivy-library-disable-scan:
description: Disable Trivy library scan
type: boolean
Expand Down Expand Up @@ -201,7 +206,7 @@ jobs:
if: |
inputs.enable-container-image-scan == true &&
inputs.application-type == 'spring-boot'
uses: felleslosninger/github-workflows/.github/workflows/ci-spring-boot-container-scan.yml@main
uses: felleslosninger/github-workflows/.github/workflows/ci-spring-boot-container-scan.yml@PF-2710
permissions:
contents: read
with:
Expand All @@ -215,6 +220,7 @@ jobs:
maven-skip-tests: ${{ inputs.maven-skip-tests }}
application-path: ${{ inputs.application-path }}
module-name: ${{ inputs.module-name }}
test-report-path: ${{ inputs.test-report-path }}
trivy-library-disable-scan: ${{ inputs.trivy-library-disable-scan }}
trivy-library-ignore-unfixed: ${{ inputs.trivy-library-ignore-unfixed }}
trivy-library-severity: ${{ inputs.trivy-library-severity }}
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/ci-spring-boot-container-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
# 3. Set up JDK
# 4. Build Spring Boot image using Paketo buildpacks. The image will be
# built based on the application path or module name (if provided)
# 5. Run Trivy vulnerability scan on the built image
# 5. Upload test reports as an artifact if the build fails and
# 'test-report-path' is set
# 6. Run Trivy vulnerability scan on the built image
#
# Trigger:
# Triggered by workflow calls (workflow_call)
Expand Down Expand Up @@ -86,6 +88,11 @@ on:
default: ""
required: false
type: string
test-report-path:
description: Path(s) to test reports (e.g. Cucumber, Surefire, Failsafe) to upload as an artifact if the Maven build fails. One path per line, relative to the repository root. If not provided, nothing is uploaded
type: string
required: false
default: ""
trivy-library-disable-scan:
description: Disable Trivy library scan
type: boolean
Expand Down Expand Up @@ -204,6 +211,28 @@ jobs:
-Dspring-boot.build-image.imageName="$IMAGE_NAME:$IMAGE_TAG" \
-Dspring-boot.build-image.builder="paketobuildpacks/$IMAGE_PACK:$IMAGE_PACK_TAG"

- name: Set test report artifact name
id: test-report-artifact
if: |
failure() &&
inputs.test-report-path != ''
env:
IMAGE_NAME: ${{ inputs.image-name || github.event.repository.name }}
run: |
# Image names may contain characters not allowed in artifact names (e.g. '/' and ':')
SAFE_NAME=$(printf '%s' "$IMAGE_NAME" | tr -c 'A-Za-z0-9._-' '-')
echo "name=test-reports-${SAFE_NAME}" >> "$GITHUB_OUTPUT"

- name: Upload test reports
if: |
failure() &&
inputs.test-report-path != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7.0.2
with:
name: ${{ steps.test-report-artifact.outputs.name }}
path: ${{ inputs.test-report-path }}
if-no-files-found: ignore

- name: Run Trivy vulnerability scanner (image)
uses: felleslosninger/github-workflows/.github/actions/trivy-scan@main
with:
Expand Down
26 changes: 26 additions & 0 deletions docs/pull-request-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,39 @@ These are applicable to Spring Boot and Quarkus application types.
| `maven-lifecycle` | `string` | `install` |
| `maven-skip-tests` | `boolean` | `true` |
| `module-name` | `string` | Not set |
| `test-report-path` | `string` | Not set |

> [!NOTE]
> **Multi-module projects:** If your application is part of a multi-module Maven
> project, you should override `module-name` instead of `application-path`. The
> workflow will automatically append the `-pl <module-name> -am` flags to ensure
> required internal dependencies are built before generating the image.

##### Test reports

Set `test-report-path` to upload test reports (for example Cucumber HTML,
Surefire or Failsafe reports) as the artifact `test-reports-<image-name>` when
the Maven build fails. Characters in the image name that are not allowed in
artifact names (such as `/` and `:`) are replaced with `-`. Use one path per
line:

```yaml
maven-skip-tests: false
test-report-path: |
target/cucumber-reports/
target/failsafe-reports/
```

- `maven-skip-tests` must be `false`, otherwise the tests do not run and no
reports are generated.
- Paths are relative to the repository root, not to `application-path`. If
`application-path` is not the root, prefix the paths with it, for example
`apps/my-app/target/cucumber-reports/`.
- For multi-module projects built with `module-name`, the reports end up in
each module's `target` folder. Use a glob such as
`**/target/cucumber-reports/`.
- If no files match, nothing is uploaded and the step does not fail.

#### Container image scanning (Quarkus overrides)

| Override | Type | Workflow default |
Expand Down
Loading