Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
feat(java-tests): add unit-test job
Browse files Browse the repository at this point in the history
test: fix secret descriptions

feat(java-tests): add unit testing
  • Loading branch information
erzz committed Jan 7, 2022
1 parent 07634b5 commit 21e95bd
Showing 1 changed file with 77 additions and 40 deletions.
117 changes: 77 additions & 40 deletions .github/workflows/java-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ on:
type: string
description: "Max number of BLOCKER Code Climate findings allowed"
default: 0
# <------------- POLARIS OPTIONS -------------->
# <--------------- POLARIS OPTIONS ----------------->
polaris-url:
required: true
type: string
Expand Down Expand Up @@ -79,10 +79,39 @@ on:
type: string
description: "Max number of TOTAL Polaris findings allowed"
default: 0
# <-------------- UNIT-TEST OPTIONS ---------------->
gcp-sa-auth:
required: false
type: boolean
description: "If GCP authentication using a service account JSON key is required for any test set to true"
default: false
gcp-oidc-auth:
required: false
type: boolean
description: "If GCP authentication using OIDC is required for any test set to true"
default: false
unit-test-command:
required: false
type: string
description: "Override the unit test command with your own if required"
default: "./mvnw -s maven-settings.xml test --fail-at-end -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B"
secrets:
# <------------------ OIDC AUTH -------------------->
wip:
required: false
description: "The workfload identity provider to use for OIDC auth"
service-account:
required: false
description: "The service account to impersonate when using OIDC auth"
# <----------------- SA KEY AUTH ------------------->
service-account-key:
required: false
description: "The service account key to use for authentication.ß"
# <------------------ MAVEN AUTH ------------------->
mvn-settings-file:
required: false
description: "If a maven settings file is required for build then add it here"
# <----------------- POLARIS AUTH ----------------->
polaris-access-token:
required: true
description: "A secret containing your Polaris access token"
Expand Down Expand Up @@ -171,43 +200,51 @@ jobs:
name: Polaris SAST Reports
path: .synopsys/polaris/cli-scan.json

# # <------------------- UNIT TESTS --------------------->
# unit-tests:
# name: Unit Tests
# runs-on: ubuntu-latest
# env:
# GOOGLE_APPLICATION_CREDENTIALS: sa.json
# steps:
# - name: Checkout the code
# uses: actions/checkout@v2

# - name: Authenticate to GCP
# id: auth
# uses: google-github-actions/auth@v0
# with:
# credentials_json: ${{ secrets.DEV_API_SA_CREDS }}

# - name: Add Maven Settings
# env:
# MAVEN_SETTINGS_FILE: ${{ secrets.MAVEN_SETTINGS_FILE }}
# run: |
# echo "$MAVEN_SETTINGS_FILE" > maven-settings.xml
# - name: Execute Unit Tests
# run: |
# ./mvnw -s maven-settings.xml test --fail-at-end -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B
# - name: Upload Surefire Reports
# uses: ScaCap/action-surefire-report@v1
# if: always()
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# report_paths: "**/surefire-reports/TEST-*.xml"

# - name: Upload Unit Test Reports
# uses: actions/upload-artifact@v2
# if: always()
# with:
# name: Unit Test Reports
# path: |
# retail-pim-api-srv/target/jacoco/reports/index.html
# retail-pim-api-srv/target/surefire-reports/TEST-*.xml
# <------------------- UNIT TESTS --------------------->
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2

- name: Authenticate to GCP (SA Key)
if: ${{ inputs.gcp-sa-auth }}
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.service-account-key }}

- name: Authenticate to GCP (OIDC)
if: ${{ inputs.gcp-oidc-auth }}
uses: google-github-actions/auth@v0
with:
workload_identity_provider: ${{ secrets.wip }}
service_account: ${{ secrets.service-account }}

- name: Include maven-settings.xml
if: ${{ inputs.mvn-settings }}
env:
# Hack to handle passing of strings with mixed quotes
FILE: ${{ secrets.mvn-settings-file }}
run: |
echo "Creating maven-settings.xml..."
echo "$FILE" > maven-settings.xml
- name: Execute Unit Tests
run: ${{ inputs.unit-test-command }}

- name: Upload Surefire Reports
uses: ScaCap/action-surefire-report@v1
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: "**/surefire-reports/TEST-*.xml"

- name: Upload Unit Test Reports
uses: actions/upload-artifact@v2
if: always()
with:
name: Unit Test Reports
path: |
**/target/jacoco/reports/index.html
**/target/surefire-reports/TEST-*.xml

0 comments on commit 21e95bd

Please sign in to comment.