93 lines
6.1 KiB
YAML
93 lines
6.1 KiB
YAML
# This workflow will build a Java project with Maven
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
|
|
|
name: "Continuous Integration"
|
|
|
|
on:
|
|
push:
|
|
branches: [ develop, v2.x-develop ]
|
|
pull_request:
|
|
branches: [ develop, v2.x-develop ]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: [self-hosted, Linux, X64, nacos-ci, nacos-java]
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: "Cache Maven Repos"
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-maven-
|
|
- name: "Checkout"
|
|
uses: actions/checkout@v4
|
|
- name: "Set up JDK 17"
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: 17
|
|
distribution: 'zulu'
|
|
- name: Set up Maven Daemon
|
|
shell: bash
|
|
env:
|
|
MVND_VERSION: '1.0.6'
|
|
# The download speed from downloads.apache.org and archive.apache.org can sometimes be very slow.
|
|
# MVND_BASE_URL: 'https://downloads.apache.org/maven/mvnd'
|
|
# MVND_BASE_URL: 'https://archive.apache.org/dist/maven/mvnd'
|
|
# GitHub releases do not have a .sha256 file.
|
|
MVND_BASE_URL: 'https://github.com/apache/maven-mvnd/releases/download'
|
|
run: |
|
|
case "${{ runner.os }}" in
|
|
Linux) MVND_OS=linux ;;
|
|
macOS) MVND_OS=darwin ;;
|
|
Windows) MVND_OS=windows ;;
|
|
*) echo "Unsupported OS: ${{ runner.os }}"; exit 1 ;;
|
|
esac
|
|
case "${{ runner.arch }}" in
|
|
X64) MVND_ARCH=amd64 ;;
|
|
ARM64) MVND_ARCH=aarch64 ;;
|
|
*) echo "Unsupported arch: ${{ runner.arch }}"; exit 1 ;;
|
|
esac
|
|
MVND_DIR="maven-mvnd-${MVND_VERSION}-${MVND_OS}-${MVND_ARCH}"
|
|
MVND_ZIP="${MVND_DIR}.zip"
|
|
MVND_URL="${MVND_BASE_URL}/${MVND_VERSION}/${MVND_ZIP}"
|
|
echo "Downloading mvnd ${MVND_VERSION} for ${MVND_OS}/${MVND_ARCH}..."
|
|
echo "Download URL: $MVND_URL"
|
|
curl -fsSL --retry 3 --retry-delay 5 --retry-connrefused "$MVND_URL" -o "$RUNNER_TEMP/mvnd.zip"
|
|
# echo "Checksum URL: ${MVND_URL}.sha256"
|
|
# curl -fsSL --retry 3 --retry-delay 5 --retry-connrefused "${MVND_URL}.sha256" -o "$RUNNER_TEMP/mvnd.zip.sha256"
|
|
RELEASE_API="https://api.github.com/repos/apache/maven-mvnd/releases/tags/${MVND_VERSION}"
|
|
echo "Fetching expected checksum from GitHub API..."
|
|
EXPECTED=$(curl -fsSL --retry 3 --retry-delay 5 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$RELEASE_API" | jq -r --arg name "$MVND_ZIP" '.assets[] | select(.name == $name) | .digest' | sed 's/^sha256://')
|
|
echo "Verifying download..."
|
|
# EXPECTED=$(cut -d' ' -f1 "$RUNNER_TEMP/mvnd.zip.sha256")
|
|
ACTUAL=$(sha256sum "$RUNNER_TEMP/mvnd.zip" | cut -d' ' -f1 | tr -d '\\')
|
|
if [ "$EXPECTED" != "$ACTUAL" ]; then
|
|
echo "Checksum mismatch! Expected: $EXPECTED, got: $ACTUAL"
|
|
exit 1
|
|
fi
|
|
echo "Checksum verified."
|
|
unzip -q "$RUNNER_TEMP/mvnd.zip" -d "$RUNNER_TEMP/mvnd-cache"
|
|
echo "$RUNNER_TEMP/mvnd-cache/${MVND_DIR}/bin" >> "$GITHUB_PATH"
|
|
- name: "Print Maven Daemon version"
|
|
run: mvnd -version
|
|
- name: "Check with Maven Daemon"
|
|
run: mvnd -B clean compile apache-rat:check checkstyle:check spotbugs:check spotless:check -e -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
|
|
- name: "Build and Test with Maven Daemon"
|
|
run: mvnd -B '-Prelease-nacos,!dev' clean install -Drat.skip=true -Dspotbugs.skip=true -DtrimStackTrace=false -U -e -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
|
|
- name: "Upload coverage to Codecov"
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: false
|
|
verbose: true
|
|
files: ./core/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-auth-plugin/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-control-plugin/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-datasource-plugin/nacos-datasource-plugin-base/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-datasource-plugin/nacos-datasource-plugin-mysql/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-datasource-plugin/nacos-datasource-plugin-derby/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-datasource-plugin/nacos-datasource-plugin-postgresql/target/site/jacoco/jacoco.xml,./plugin-default-impl/nacos-default-datasource-plugin/nacos-datasource-plugin-oracle/target/site/jacoco/jacoco.xml,./config/target/site/jacoco/jacoco.xml,./auth/target/site/jacoco/jacoco.xml,./plugin/encryption/target/site/jacoco/jacoco.xml,./plugin/datasource/target/site/jacoco/jacoco.xml,./plugin/trace/target/site/jacoco/jacoco.xml,./plugin/config/target/site/jacoco/jacoco.xml,./plugin/auth/target/site/jacoco/jacoco.xml,./plugin/environment/target/site/jacoco/jacoco.xml,./plugin/control/target/site/jacoco/jacoco.xml,./lock/target/site/jacoco/jacoco.xml,./logger-adapter-impl/log4j2-adapter/target/site/jacoco/jacoco.xml,./logger-adapter-impl/logback-adapter-12/target/site/jacoco/jacoco.xml,./consistency/target/site/jacoco/jacoco.xml,./common/target/site/jacoco/jacoco.xml,./sys/target/site/jacoco/jacoco.xml,./ai/target/site/jacoco/jacoco.xml,./naming/target/site/jacoco/jacoco.xml,./client-basic/target/site/jacoco/jacoco.xml,./address/target/site/jacoco/jacoco.xml,./persistence/target/site/jacoco/jacoco.xml,./api/target/site/jacoco/jacoco.xml,./maintainer-client/target/site/jacoco/jacoco.xml,./prometheus/target/site/jacoco/jacoco.xml,./client/target/site/jacoco/jacoco.xml,./console/target/site/jacoco/jacoco.xml
|