Skip to content

Add tests

Add tests #12661

Workflow file for this run

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
name: Java CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# allow single build per branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# clear all permissions for GITHUB_TOKEN
permissions: {}
env:
MIMIR_VERSION: 0.10.4
MIMIR_BASEDIR: ~/.mimir
MIMIR_LOCAL: ~/.mimir/local
MAVEN_OPTS: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./target/java_heapdump.hprof
jobs:
initial-build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
java-version: 17
distribution: 'temurin'
- name: Checkout maven
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Prepare Mimir for Maven 3.x
shell: bash
run: |
mkdir -p ${{ env.MIMIR_BASEDIR }}
cp .github/ci-mimir-session.properties ${{ env.MIMIR_BASEDIR }}/session.properties
cp .github/ci-mimir-daemon.properties ${{ env.MIMIR_BASEDIR }}/daemon.properties
cp .github/ci-extensions.xml .mvn/extensions.xml
- name: Restore Mimir caches
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ env.MIMIR_LOCAL }}
key: master-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
master-${{ runner.os }}-
master-
- name: Set up Maven
shell: bash
run: mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.4:wrapper "-Dmaven=4.0.0-rc-4"
- name: Prepare Mimir for Maven 4.x
shell: bash
run: |
rm .mvn/extensions.xml
mkdir -p ~/.m2
cp .github/ci-extensions.xml ~/.m2/extensions.xml
- name: Build Maven distributions
shell: bash
run: ./mvnw verify -e -B -V
- name: List contents of target directory
shell: bash
run: ls -la apache-maven/target
- name: Upload Mimir caches
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ !cancelled() && !failure() }}
with:
name: cache-${{ runner.os }}-initial
retention-days: 1
path: ${{ env.MIMIR_LOCAL }}
- name: Upload Maven distributions
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: maven-distributions
path: |
apache-maven/target/apache-maven*.zip
apache-maven/target/apache-maven*.tar.gz
- name: Upload test artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ failure() || cancelled() }}
with:
name: initial-logs
retention-days: 1
path: |
**/target/surefire-reports/*
**/target/java_heapdump.hprof
- name: Upload Mimir logs
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: always()
with:
name: initial-mimir-logs
include-hidden-files: true
retention-days: 1
path: |
~/.mimir/*.log
full-build:
needs: initial-build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: ['17', '21', '25']
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Install Graphviz (MacOS)
if: runner.os == 'macOS'
run: brew install graphviz
- name: Install Graphviz (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get install graphviz
- name: Install Graphviz (Windows)
if: runner.os == 'Windows'
run: choco install graphviz
- name: Checkout maven
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Prepare Mimir for Maven 4.x
shell: bash
run: |
mkdir -p ${{ env.MIMIR_BASEDIR }}
cp .github/ci-mimir-session.properties ${{ env.MIMIR_BASEDIR }}/session.properties
cp .github/ci-mimir-daemon.properties ${{ env.MIMIR_BASEDIR }}/daemon.properties
mkdir -p ~/.m2
cp .github/ci-extensions.xml ~/.m2/extensions.xml
- name: Restore Mimir caches
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ env.MIMIR_LOCAL }}
key: master-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
master-${{ runner.os }}-
master-
- name: Download Maven distribution
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: maven-distributions
path: maven-dist
- name: List downloaded files
shell: bash
run: ls -la maven-dist
- name: Extract Maven distribution
shell: bash
run: |
mkdir -p maven-local
if [ "${{ runner.os }}" = "Windows" ]; then
unzip maven-dist/apache-maven-*-bin.zip -d maven-local
# Get the name of the extracted directory
MAVEN_DIR=$(ls maven-local)
# Move contents up one level
mv "maven-local/$MAVEN_DIR"/* maven-local/
rm -r "maven-local/$MAVEN_DIR"
else
tar xzf maven-dist/apache-maven-*-bin.tar.gz -C maven-local --strip-components 1
fi
echo "MAVEN_HOME=$PWD/maven-local" >> $GITHUB_ENV
echo "$PWD/maven-local/bin" >> $GITHUB_PATH
- name: Build with downloaded Maven
shell: bash
run: mvn verify -Papache-release -Dgpg.skip=true -e -B -V
- name: Build site with downloaded Maven
shell: bash
run: mvn site -e -B -V -Preporting
- name: Upload Mimir caches
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ !cancelled() && !failure() }}
with:
name: cache-${{ runner.os }}-full-build-${{ matrix.java }}
retention-days: 1
path: ${{ env.MIMIR_LOCAL }}
- name: Upload test artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure() || cancelled()
with:
name: full-build-logs-${{ runner.os }}-${{ matrix.java }}
retention-days: 1
path: |
**/target/surefire-reports/*
**/target/java_heapdump.hprof
- name: Upload Mimir logs
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: always()
with:
name: full-build-mimir-logs-${{ runner.os }}-${{ matrix.java }}
include-hidden-files: true
retention-days: 1
path: |
~/.mimir/*.log
integration-tests:
needs: initial-build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: ['17', '21', '25']
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Checkout maven
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Prepare Mimir for Maven 4.x
shell: bash
run: |
mkdir -p ${{ env.MIMIR_BASEDIR }}
cp .github/ci-mimir-session.properties ${{ env.MIMIR_BASEDIR }}/session.properties
cp .github/ci-mimir-daemon.properties ${{ env.MIMIR_BASEDIR }}/daemon.properties
mkdir -p ~/.m2
cp .github/ci-extensions.xml ~/.m2/extensions.xml
- name: Restore Mimir caches
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ env.MIMIR_LOCAL }}
key: master-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
master-${{ runner.os }}-
master-
- name: Download Maven distribution
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: maven-distributions
path: maven-dist
- name: List downloaded files
shell: bash
run: ls -la maven-dist
- name: Extract Maven distribution
shell: bash
run: |
mkdir -p maven-local
if [ "${{ runner.os }}" = "Windows" ]; then
unzip maven-dist/apache-maven-*-bin.zip -d maven-local
# Get the name of the extracted directory
MAVEN_DIR=$(ls maven-local)
# Move contents up one level
mv "maven-local/$MAVEN_DIR"/* maven-local/
rm -r "maven-local/$MAVEN_DIR"
else
tar xzf maven-dist/apache-maven-*-bin.tar.gz -C maven-local --strip-components 1
fi
echo "MAVEN_HOME=$PWD/maven-local" >> $GITHUB_ENV
echo "$PWD/maven-local/bin" >> $GITHUB_PATH
- name: Build Maven and ITs and run them
shell: bash
run: mvn install -e -B -V -Prun-its,mimir
- name: Upload Mimir caches
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ !cancelled() && !failure() }}
with:
name: cache-${{ runner.os }}-integration-tests-${{ matrix.java }}
retention-days: 1
path: ${{ env.MIMIR_LOCAL }}
- name: Upload test artifacts
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: ${{ failure() || cancelled() }}
with:
name: integration-test-logs-${{ runner.os }}-${{ matrix.java }}
retention-days: 1
path: |
**/target/surefire-reports/*
**/target/failsafe-reports/*
./its/core-it-suite/target/test-classes/**
**/target/java_heapdump.hprof
- name: Upload Mimir logs
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: always()
with:
name: integration-test-mimir-logs-${{ runner.os }}-${{ matrix.java }}
include-hidden-files: true
retention-days: 1
path: |
~/.mimir/*.log
consolidate-caches:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
needs:
- full-build
- integration-tests
steps:
- name: Download Caches
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
merge-multiple: true
pattern: 'cache-${{ runner.os }}*'
path: ${{ env.MIMIR_LOCAL }}
- name: Publish cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
if: ${{ github.event_name != 'pull_request' && !cancelled() && !failure() }}
with:
path: ${{ env.MIMIR_LOCAL }}
key: master-${{ runner.os }}-${{ github.run_id }}