Skip to content

Merge pull request #1999 from DependencyTrack/nscuro-patch-1 #7042

Merge pull request #1999 from DependencyTrack/nscuro-patch-1

Merge pull request #1999 from DependencyTrack/nscuro-patch-1 #7042

Workflow file for this run

# This file is part of Dependency-Track.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.
name: Tests CI
on:
push:
branches:
- 'main' # Main branch
- 'feature-**' # Feature branch
- '[0-9]+.[0-9]+.x' # Release branches
paths-ignore:
- '**/*.md'
- 'docs/**'
pull_request:
branches:
- 'main' # Main branch
- 'feature-**' # Feature branch
- '[0-9]+.[0-9]+.x' # Release branches
paths-ignore:
- '**/*.md'
- 'docs/**'
workflow_dispatch:
# The following concurrency group cancels in-progress jobs or runs on pull_request events only;
# if github.head_ref is undefined, the concurrency group will fallback to the run ID,
# which is guaranteed to be both unique and defined for the run.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: { }
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
with:
# For PRs, ensure that the actual HEAD commit is checked out,
# rather than an artificial merge commit. We need the actual
# commit in order for coverage reports to be matched properly.
# https://github.com/actions/checkout/issues/426
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
# Do not store the GitHub token in .git/config.
# Required because we upload the workspace as workflow artifact.
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # tag=v5.2.0
with:
distribution: 'temurin'
java-version: '25'
cache: 'maven'
- name: Execute unit tests
env:
TESTCONTAINERS_REUSE_ENABLE: "true"
run: make test
- name: Generate test report
if: ${{ always() }}
run: mvn -B surefire-report:report-only -Daggregate=true -DlinkXRef=false
- name: Upload test report
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # tag=v7.0.0
with:
name: test-report
path: target/reports/
if-no-files-found: warn
# Publishing coverage to Codacy is only possible for builds of push events.
# PRs from forks do not get access to repository secrets.
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Publish test coverage
if: ${{ github.event_name != 'pull_request' && github.repository_owner == 'DependencyTrack' }}
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # tag=v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
language: Java
coverage-reports: coverage-report/target/site/jacoco-aggregate/jacoco.xml
- name: Upload PR workspace
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # tag=v7.0.0
with:
name: pr-workspace
include-hidden-files: true
path: |-
./**/*
!./**/target/classes/**/*
!./**/*.jar
!./**/*.war
!./**/bom.json
!./apiserver/target/dependency-track-apiserver/**/*
!./apiserver/target/war/**/*