From 7d64aa893c7268a14a7e9889bf7b9c1efa21c617 Mon Sep 17 00:00:00 2001 From: lexluo09 <39718951+lexluo09@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:08:56 +0800 Subject: [PATCH] (improvement)(build) Support CI for both JDK 8 and JDK 11 versions simultaneously. (#1437) --- .github/workflows/centos-ci.yml | 25 ++++++++++++++++--- .github/workflows/mac-ci.yml | 8 ++++-- .github/workflows/ubuntu-ci.yml | 42 +++++++++++++++++++------------- .github/workflows/windows-ci.yml | 8 ++++-- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/.github/workflows/centos-ci.yml b/.github/workflows/centos-ci.yml index 09c3fa474..3ee02579b 100644 --- a/.github/workflows/centos-ci.yml +++ b/.github/workflows/centos-ci.yml @@ -1,4 +1,4 @@ -name: supersonic RHEL/CentOS CI +name: supersonic CentOS CI on: push: @@ -14,31 +14,48 @@ jobs: container: image: quay.io/centos/centos:stream8 # 使用 CentOS Stream 8 容器 + strategy: + matrix: + java-version: [8, 11] # 定义要测试的JDK版本 + steps: - uses: actions/checkout@v2 + - name: Reset DNF repositories run: | cd /etc/yum.repos.d/ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + - name: Update DNF package index run: dnf makecache + - name: Install Java and Maven with retry run: | - for i in {1..5}; do - dnf install -y java-1.8.0-openjdk-devel maven && break || sleep 15 - done + if [ ${{ matrix.java-version }} -eq 8 ]; then + for i in {1..5}; do + dnf install -y java-1.8.0-openjdk-devel maven && break || sleep 15 + done + else + for i in {1..5}; do + dnf install -y java-11-openjdk-devel maven && break || sleep 15 + done + fi + - name: Verify Java and Maven installation run: | java -version mvn -version + - name: Cache Maven packages uses: actions/cache@v2 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven run: mvn -B package --file pom.xml + - name: Test with Maven run: mvn test \ No newline at end of file diff --git a/.github/workflows/mac-ci.yml b/.github/workflows/mac-ci.yml index c729323b0..f5d4546ab 100644 --- a/.github/workflows/mac-ci.yml +++ b/.github/workflows/mac-ci.yml @@ -12,13 +12,17 @@ jobs: build: runs-on: macos-latest # Specify a macOS runner + strategy: + matrix: + java-version: [8, 11] # Define the JDK versions to test + steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK ${{ matrix.java-version }} uses: actions/setup-java@v2 with: - java-version: '8' + java-version: ${{ matrix.java-version }} distribution: 'adopt' - name: Cache Maven packages diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml index 7d2b9c657..702226788 100644 --- a/.github/workflows/ubuntu-ci.yml +++ b/.github/workflows/ubuntu-ci.yml @@ -7,25 +7,33 @@ on: pull_request: branches: - master + jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + java-version: [8, 11] # 定义要测试的JDK版本 + steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - name: Cache Maven packages - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build with Maven - run: mvn -B package --file pom.xml - - name: Test with Maven - run: mvn test + - uses: actions/checkout@v2 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.java-version }} + distribution: 'adopt' + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Test with Maven + run: mvn test \ No newline at end of file diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 98c0de61c..22e016efa 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -12,13 +12,17 @@ jobs: build: runs-on: windows-latest # Specify a Windows runner + strategy: + matrix: + java-version: [8, 11] + steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK ${{ matrix.java-version }} uses: actions/setup-java@v2 with: - java-version: '8' + java-version: ${{ matrix.java-version }} distribution: 'adopt' - name: Cache Maven packages