Skip to content

Add cache to CI

Add cache to CI #1

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: Maven Build
description: Build with tests + Rebuild using the built Maven + Integration tests
inputs:
java-version:
description: 'The Java version to use'
required: true
default: '17'
upload-distribution:
description: 'If the built distribution should be uploaded'
required: false
default: false
runs:
using: "composite"
steps:
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository/cached
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-
- name: Checking out Maven
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Maven
run:
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4"
- name: Build with Maven
run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven
- name: Upload built Maven
uses: actions/upload-artifact@v4
if: ${{ inputs.upload-distribution }}
with:
name: built-maven
path: apache-maven/target/
- name: Extract tarball
shell: bash
run: |
set +e
if [ -f ${{ env.TAR_BALL }} ]; then
temp_dir=$(mktemp -d)
tar -xzf ${{ env.TAR_BALL }} -C "$temp_dir" --strip 1
maven_bin_dir=$temp_dir/bin
if [ -d $maven_bin_dir ]; then
echo "tar.gz file \"${{ env.TAR_BALL }}\" successfully extracted in temporarily directory \"$temp_dir.\""
echo "TEMP_MAVEN_BIN_DIR=$maven_bin_dir" >> $GITHUB_ENV
else
echo "$maven_bin_dir does not exist."
exit 1;
fi
else
echo "${{ env.TAR_BALL }} does not exist."
exit 1;
fi
env:
TAR_BALL: apache-maven/target/apache-maven-bin.tar.gz
- name: Clean with Maven
run: ./mvnw -e -B -V clean
- name: Build again with Maven SNAPSHOT
shell: bash
run: |
set +e
export PATH=${{ env.TEMP_MAVEN_BIN_DIR }}:$PATH
mvn verify site -e -B -V -DdistributionFileName=apache-maven -Preporting
- name: Running integration tests
shell: bash
run: ./mvnw install -e -B -V -Prun-its,embedded -DmavenDistro="$GITHUB_WORKSPACE/maven/apache-maven/target/apache-maven-bin.zip" -f maven-integration-testing/pom.xml
- name: Upload artifact on integration testing
uses: actions/upload-artifact@v4
if: failure() && matrix.os != 'windows-latest'
with:
name: ${{ github.run_number }}-integration-test-artifact-${{ runner.os }}-${{ inputs.java-version }}
path: ./maven-integration-testing/core-it-suite/target/test-classes/