From 79569a4b275ce3d8934fba1048f146ee9cb516e4 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Thu, 2 Jan 2025 19:02:17 -0800 Subject: [PATCH] Use docker CI image for Linux build (#15) Signed-off-by: Daniel Widdis --- .github/workflows/CI.yml | 78 +++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8bf3bfa..30d8d47 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -7,22 +7,57 @@ on: pull_request: branches: - "*" +env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: - build: + Get-CI-Image-Tag: + uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main + with: + product: opensearch + spotless: + if: github.repository == 'opensearch-project/opensearch-remote-metadata-sdk' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + - name: Spotless Check + run: ./gradlew spotlessCheck + javadoc: + if: github.repository == 'opensearch-project/opensearch-remote-metadata-sdk' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + - name: Javadoc CheckStyle + run: ./gradlew checkstyleMain + - name: Javadoc Check + run: ./gradlew javadoc + + build-linux: + needs: [Get-CI-Image-Tag, spotless, javadoc] strategy: matrix: - os: - - ubuntu-latest - - macOS-latest - - windows-latest java: - 21 - 23 - name: Build and Test - runs-on: ${{ matrix.os }} + name: Linux JDK ${{ matrix.java }} + runs-on: ubuntu-latest + container: + # using the same image which is used by opensearch-build team to build the OpenSearch Distribution + # this image tag is subject to change as more dependencies and updates will arrive over time + image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} steps: + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 @@ -30,12 +65,37 @@ jobs: java-version: ${{ matrix.java }} distribution: temurin - name: Build and Run Tests + id: step-build-test-linux run: | - ./gradlew build + chown -R 1000:1000 `pwd` + su `id -un 1000` -c 'whoami && java -version && + echo "build and run tests" && ./gradlew build && + echo "Publish to Maven Local" && ./gradlew publishToMavenLocal' - name: Upload Coverage Report - if: contains(matrix.os, 'ubuntu') && contains(matrix.java, '21') + if: contains(matrix.java, '21') uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: file: ./build/reports/jacoco/test/jacocoTestReport.xml + + build-windows: + needs: [spotless, javadoc] + strategy: + matrix: + java: + - 21 + - 23 + name: Windows JDK ${{ matrix.java }} + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - name: Build and Run Tests + run: | + ./gradlew build