Skip to content

Unit Tests

Unit Tests #2130

Workflow file for this run

# Copyright 2024 Google LLC
#
# 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.
# Github action job to test core java library features on
# downstream client libraries before they are released.
name: Unit Tests
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
schedule:
- cron: '30 9 * * *' # 09:30 UTC every day
jobs:
unitTests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
java: [8, 11]
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d' --utc)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- uses: actions/cache@v3
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.date }}
- name: Maven go offline
id: mvn-offline
if: steps.mvn-cache.outputs.cache-hit != 'true'
run: ./mvnw compile dependency:go-offline
- name: Mvn install # Need this when the directory/pom structure changes
id: install1
continue-on-error: true
run: |
./mvnw \
--batch-mode \
--show-version \
--threads 1.5C \
--define maven.test.skip=true \
--define maven.javadoc.skip=true \
install
- name: Retry install on failure
id: install2
if: steps.install1.outcome == 'failure'
run: |
./mvnw \
--batch-mode \
--show-version \
--threads 1.5C \
--define maven.test.skip=true \
--define maven.javadoc.skip=true \
install
- name: Unit Tests
run: |
./mvnw \
--batch-mode \
--fail-at-end \
--threads 1.5C \
test
- name: Aggregate Report
run: |
./mvnw \
--batch-mode \
--define aggregate=true \
surefire-report:report-only
- name: Archive logs
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: Unit Test Logs - Java ${{ matrix.java }}
path: |
**/target/surefire-reports/*
**/target/site