diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75de166dec..260a8050ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,38 @@ name: CI +run-name: "${{ github.event_name == 'workflow_dispatch' && format('Dispatch : Run integration test with JDK {0} ({1})', inputs.INT_TEST_JAVA_RUNTIME_VERSION, inputs.INT_TEST_JAVA_RUNTIME_VENDOR) || '' }}" on: pull_request: workflow_dispatch: + inputs: + INT_TEST_JAVA_RUNTIME_VERSION: + description: JDK version used to run the integration test + type: choice + required: false + default: '8' + options: + - '8' + - '11' + - '17' + - '21' + INT_TEST_JAVA_RUNTIME_VENDOR: + description: Vendor of the JDK used to run the integration test + type: choice + required: false + default: 'temurin' + options: + - 'corretto' + - 'microsoft' + - 'oracle' + - 'temurin' env: TERM: dumb + JAVA_VERSION: '8' + JAVA_VENDOR: 'temurin' + INT_TEST_JAVA_RUNTIME_VERSION: "${{ github.event_name != 'workflow_dispatch' && '8' || inputs.INT_TEST_JAVA_RUNTIME_VERSION }}" + INT_TEST_JAVA_RUNTIME_VENDOR: "${{ github.event_name != 'workflow_dispatch' && 'temurin' || inputs.INT_TEST_JAVA_RUNTIME_VENDOR }}" + jobs: check: name: Gradle check @@ -13,16 +40,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} - name: Setup and execute Gradle 'check' task uses: gradle/gradle-build-action@v3 with: - arguments: check + arguments: check buildSrc:check -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} - name: Save Gradle test reports if: always() @@ -67,11 +94,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} - name: Dockerfile Lint for ScalarDB Server uses: gradle/gradle-build-action@v3 @@ -100,16 +127,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestCassandra' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestCassandra + arguments: integrationTestCassandra -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -134,16 +168,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestCassandra' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestCassandra + arguments: integrationTestCassandra -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -159,11 +200,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Generate unique prefix using the epoch run: | @@ -172,7 +220,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestCosmos' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestCosmos -Dscalardb.cosmos.uri=${{ secrets.COSMOS_URI }} -Dscalardb.cosmos.password=${{ secrets.COSMOS_PASSWORD }} -Dscalardb.cosmos.database_prefix=${{ env.db_prefix }}_ + arguments: integrationTestCosmos -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.cosmos.uri=${{ secrets.COSMOS_URI }} -Dscalardb.cosmos.password=${{ secrets.COSMOS_PASSWORD }} -Dscalardb.cosmos.database_prefix=${{ env.db_prefix }}_ - name : Delete gradle daemon log files if: always() @@ -200,16 +248,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestDynamo' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestDynamo + arguments: integrationTestDynamo -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -229,16 +284,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -258,16 +320,24 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} + - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -287,16 +357,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -321,16 +398,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -355,16 +439,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -389,16 +480,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -423,16 +521,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -463,16 +568,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Upload Gradle test reports if: always() @@ -503,16 +615,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Upload Gradle test reports if: always() @@ -557,16 +676,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/FREEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/FREEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Stop Oracle 23 container if: always() @@ -597,11 +723,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver17 SqlServer17 10 3 @@ -610,7 +743,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -637,11 +770,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver19 SqlServer19 10 3 @@ -650,7 +790,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -677,11 +817,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver22 SqlServer22 10 3 @@ -690,7 +837,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -706,11 +853,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Set up SQLite3 run: sudo apt-get install -y sqlite3 @@ -718,7 +872,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlite:integration.sqlite3?busy_timeout=50000 + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlite:integration.sqlite3?busy_timeout=50000 - name: Upload Gradle test reports if: always() @@ -738,16 +892,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -767,16 +928,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:yugabytedb://localhost:5433/ -Dscalardb.jdbc.username=yugabyte -Dscalardb.jdbc.password=yugabyte -Dscalar.db.jdbc.connection_pool.max_total=12 -Dscalar.db.jdbc.table_metadata.connection_pool.max_total=4 -Dscalar.db.jdbc.admin.connection_pool.max_total=4 + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:yugabytedb://localhost:5433/ -Dscalardb.jdbc.username=yugabyte -Dscalardb.jdbc.password=yugabyte -Dscalar.db.jdbc.connection_pool.max_total=12 -Dscalar.db.jdbc.table_metadata.connection_pool.max_total=4 -Dscalar.db.jdbc.admin.connection_pool.max_total=4 - name: Upload Gradle test reports if: always() @@ -805,16 +973,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestMultiStorage' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestMultiStorage + arguments: integrationTestMultiStorage -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports uses: actions/upload-artifact@v4 @@ -834,16 +1009,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestScalarDbServer' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestScalarDbServer + arguments: integrationTestScalarDbServer -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports uses: actions/upload-artifact@v4 @@ -868,16 +1050,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v3 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres -Dscalar.db.consensus_commit.coordinator.group_commit.enabled=true -Dscalar.db.consensus_commit.coordinator.group_commit.old_group_abort_timeout_millis=15000 --tests "**ConsensusCommit**" + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres -Dscalar.db.consensus_commit.coordinator.group_commit.enabled=true -Dscalar.db.consensus_commit.coordinator.group_commit.old_group_abort_timeout_millis=15000 --tests "**ConsensusCommit**" - name: Upload Gradle test reports if: always() diff --git a/build.gradle b/build.gradle index 3c1e9702ef..094ba17ce5 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ subprojects { // apply plugin: 'jacoco' apply plugin: 'java-library-distribution' apply plugin: 'com.diffplug.spotless' + apply plugin: 'com.scalar.db.jdk-configuration' project.version = '4.0.0-SNAPSHOT' @@ -54,10 +55,9 @@ subprojects { log4jVersion = '2.23.1' stefanbirknerSystemLambdaVersion = '1.2.1' spotbugsPluginVersion = '5.2.5' - errorpronePluginVersion = '2.0.2' + errorpronePluginVersion = '3.1.0' protobufPluginVersion = '0.8.19' shadowPluginVersion = '7.1.2' - dockerPluginVersion = '0.34.0' // Make JDK11+ use the same version as JDK8 uses googleJavaFormatVersion = '1.7' } @@ -71,9 +71,6 @@ subprojects { testLogging.showStandardStreams = true } - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - group = "com.scalar-labs" java { @@ -99,3 +96,4 @@ subprojects { duplicatesStrategy DuplicatesStrategy.EXCLUDE } } + diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000000..756d4b74ee --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'java-gradle-plugin' + id 'com.diffplug.spotless' version '6.13.0' +} + +repositories { + mavenCentral() +} + +gradlePlugin { + plugins { + jdkConfiguration { + id = 'com.scalar.db.jdk-configuration' + implementationClass = 'com.scalar.db.JdkConfigurationPlugin' + } + } +} + +spotless { + java { + target 'src/*/java/**/*.java' + importOrder() + removeUnusedImports() + googleJavaFormat("1.7") + } +} diff --git a/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java b/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java new file mode 100644 index 0000000000..3d46261c6a --- /dev/null +++ b/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java @@ -0,0 +1,152 @@ +package com.scalar.db; + +import java.util.Objects; +import java.util.function.Consumer; +import javax.annotation.Nullable; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.tasks.testing.Test; +import org.gradle.jvm.toolchain.JavaLanguageVersion; +import org.gradle.jvm.toolchain.JavaToolchainService; +import org.gradle.jvm.toolchain.JvmVendorSpec; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Plugin configuring all tasks and integration test tasks to use a given JDK defined by the + * following Gradle properties: + * + * + * + *

Usage example using the CLI: + * + *

1. To use JDK 11 (amazon) for all Java tasks including integration tests + * + *


+ *   gradle integrationTestJdbc -PjavaVersion=11 -PjavaVendor=amazon
+ * 
+ * + * 2. To use JDK 11 (amazon) for all Java tasks while having integration test use JDK 17 (microsoft) + * + *

+ *   gradle integrationTestJdbc -PjavaVersion=11 -PjavaVendor=amazon -PintegrationTestJavaRuntimeVersion=17 -PintegrationTestJavaRuntimeVendor=microsoft
+ * 
+ */ +public class JdkConfigurationPlugin implements Plugin { + + private static final Logger logger = LoggerFactory.getLogger(JdkConfigurationPlugin.class); + // JDK 8 (temurin) is used as default for all tasks (compilation, tests, etc.) + private static final JavaLanguageVersion DEFAULT_JAVA_VERSION = JavaLanguageVersion.of(8); + private static final JvmVendorSpec DEFAULT_JAVA_VENDOR = JvmVendorSpec.ADOPTIUM; + + private static final String JAVA_VERSION_PROP = "javaVersion"; + private static final String JAVA_VENDOR_PROP = "javaVendor"; + private static final String INTEGRATION_TEST_JAVA_RUNTIME_VERSION_PROP = + "integrationTestJavaRuntimeVersion"; + private static final String INTEGRATION_TEST_JAVA_RUNTIME_VENDOR_PROP = + "integrationTestJavaRuntimeVendor"; + + private JavaLanguageVersion javaVersion = DEFAULT_JAVA_VERSION; + private JvmVendorSpec javaVendor = DEFAULT_JAVA_VENDOR; + @Nullable private JavaLanguageVersion integrationTestJavaVersion; + @Nullable private JvmVendorSpec integrationTestJavaVendor; + + @Override + public void apply(@NotNull Project project) { + parseIntegrationTestInputProperties(project); + configureJdkForAllJavaTasks(project); + configureJdkForIntegrationTestTasks(project); + } + + private void configureJdkForAllJavaTasks(Project project) { + JavaPluginExtension javaPlugin = project.getExtensions().getByType(JavaPluginExtension.class); + javaPlugin.getToolchain().getLanguageVersion().set(javaVersion); + javaPlugin.getToolchain().getVendor().set(javaVendor); + logger.debug("Configure JDK {} ({}) for Java tasks", javaVersion, javaVendor); + } + + private void configureJdkForIntegrationTestTasks(Project project) { + if (integrationTestJavaVersion == null) { + return; + } + project + .getTasks() + .withType(Test.class) + .matching(testTask -> testTask.getName().startsWith("integrationTest")) + .configureEach( + integrationTestTask -> + integrationTestTask + .getJavaLauncher() + .set( + getJavaToolchainService(project) + .launcherFor( + config -> { + config.getLanguageVersion().set(integrationTestJavaVersion); + logger.debug( + "Configure task '{}' to use JDK version {}", + integrationTestTask.getName(), + integrationTestJavaVersion); + if (integrationTestJavaVendor != null) { + config.getVendor().set(integrationTestJavaVendor); + logger.debug( + "Configure task '{}' to use {} JDK vendor", + integrationTestTask.getName(), + integrationTestJavaVendor); + } + }))); + } + + private void parseIntegrationTestInputProperties(Project project) { + parseVersionInputProperty(project, JAVA_VERSION_PROP, (version) -> javaVersion = version); + parseVendorInputProperty(project, JAVA_VENDOR_PROP, (vendor) -> javaVendor = vendor); + parseVersionInputProperty( + project, + INTEGRATION_TEST_JAVA_RUNTIME_VERSION_PROP, + (version) -> integrationTestJavaVersion = version); + parseVendorInputProperty( + project, + INTEGRATION_TEST_JAVA_RUNTIME_VENDOR_PROP, + (vendor) -> integrationTestJavaVendor = vendor); + } + + private void parseVersionInputProperty( + Project project, String property, Consumer attributeSetter) { + if (project.hasProperty(property)) { + attributeSetter.accept(JavaLanguageVersion.of(Objects.toString(project.property(property)))); + } + } + + private void parseVendorInputProperty( + Project project, String property, Consumer attributeSetter) { + if (!project.getRootProject().hasProperty(property)) { + return; + } + String propertyValue = Objects.toString(project.property(property)); + switch (propertyValue) { + case "corretto": + attributeSetter.accept(JvmVendorSpec.AMAZON); + break; + case "temurin": + attributeSetter.accept(JvmVendorSpec.ADOPTIUM); + break; + default: + attributeSetter.accept(JvmVendorSpec.matching(propertyValue)); + } + } + + private @NotNull JavaToolchainService getJavaToolchainService(Project project) { + return project.getExtensions().getByType(JavaToolchainService.class); + } +} diff --git a/core/build.gradle b/core/build.gradle index e767dc6327..b418fd192a 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ plugins { id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } sourceSets { @@ -128,7 +129,6 @@ javadoc { title = "ScalarDB" } - task integrationTestCassandra(type: Test) { description = 'Runs the integration tests for Cassandra.' group = 'verification' @@ -136,7 +136,7 @@ task integrationTestCassandra(type: Test) { classpath = sourceSets.integrationTestCassandra.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -147,7 +147,7 @@ task integrationTestCosmos(type: Test) { classpath = sourceSets.integrationTestCosmos.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } maxParallelForks = 3 jvmArgs '-XX:MaxDirectMemorySize=4g', '-Xmx4g' @@ -160,7 +160,7 @@ task integrationTestDynamo(type: Test) { classpath = sourceSets.integrationTestDynamo.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } maxParallelForks = 10 } @@ -172,7 +172,7 @@ task integrationTestJdbc(type: Test) { classpath = sourceSets.integrationTestJdbc.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -183,7 +183,7 @@ task integrationTestMultiStorage(type: Test) { classpath = sourceSets.integrationTestMultiStorage.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -229,7 +229,9 @@ check.dependsOn += spotbugsMain check.dependsOn += spotbugsTest check.dependsOn += spotbugsIntegrationTest -archivesBaseName = "scalardb" +base { + archivesName = "scalardb" +} // for archiving and uploading to maven central publishing { diff --git a/docs/getting-started/build.gradle b/docs/getting-started/build.gradle index b001324eb4..8e775aa17a 100644 --- a/docs/getting-started/build.gradle +++ b/docs/getting-started/build.gradle @@ -6,7 +6,7 @@ repositories { mavenCentral() } -mainClassName = "sample.ElectronicMoneyMain" +mainClass = "sample.ElectronicMoneyMain" dependencies { implementation 'com.scalar-labs:scalardb:3.12.2' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cc4fdc293d..e708b1c023 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf516..48c0a02ca4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7d95..4f906e0c81 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 24467a141f..ac1b06f938 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/integration-test/build.gradle b/integration-test/build.gradle index 6290ac6b57..3567f531c4 100644 --- a/integration-test/build.gradle +++ b/integration-test/build.gradle @@ -3,6 +3,7 @@ plugins { id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } dependencies { @@ -52,7 +53,9 @@ spotbugsTest.reports { } spotbugsTest.excludeFilter = file("${project.rootDir}/gradle/spotbugs-exclude.xml") -archivesBaseName = "scalardb-integration-test" +base { + archivesName = "scalardb-integration-test" +} // for archiving and uploading to maven central publishing { diff --git a/rpc/build.gradle b/rpc/build.gradle index f80193e89f..b1fba2e1e7 100644 --- a/rpc/build.gradle +++ b/rpc/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.google.protobuf' version "${protobufPluginVersion}" id 'maven-publish' id 'signing' + id 'base' } dependencies { @@ -27,7 +28,9 @@ protobuf { generatedFilesBaseDir = "$projectDir/src" } -archivesBaseName = "scalardb-rpc" +base { + archivesName = "scalardb-rpc" +} // plugin com.google.protobuf generates tasks in runtime so that we have do declare dependencies dynamically tasks.whenTaskAdded { t -> diff --git a/schema-loader/build.gradle b/schema-loader/build.gradle index a673b15da5..97523de479 100644 --- a/schema-loader/build.gradle +++ b/schema-loader/build.gradle @@ -1,13 +1,16 @@ plugins { - id 'com.palantir.docker' version "${dockerPluginVersion}" id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'com.github.johnrengelman.shadow' version "${shadowPluginVersion}" id 'com.github.spotbugs' version "${spotbugsPluginVersion}" id 'maven-publish' id 'signing' + id 'base' +} + +base { + archivesName = "scalardb-schema-loader" } -archivesBaseName = "scalardb-schema-loader" dependencies { implementation project(':core') @@ -34,17 +37,26 @@ javadoc { title = "ScalarDB Schema Loader" } -docker { - dependsOn shadowJar - name "ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}" - files tasks.shadowJar.outputs -} - task dockerfileLint(type: Exec) { description 'Lint the Dockerfile' commandLine "${project.rootDir}/ci/dockerfile_lint.sh" } +task copyFilesToDockerBuildContextDir(type: Copy) { + description 'Copy files to a temporary folder to build the Docker image' + dependsOn shadowJar + from("Dockerfile") + from(tasks.shadowJar.archiveFile) + into('build/docker') +} + +task docker(type: Exec) { + description 'Build ScalarDB Schema Loader Docker image' + dependsOn copyFilesToDockerBuildContextDir + workingDir 'build/docker' + commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}", "." +} + // Build a fat jar shadowJar { archiveClassifier.set("") diff --git a/server/build.gradle b/server/build.gradle index 1fbf0a815b..6929b17765 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,10 +1,10 @@ plugins { id 'application' - id 'com.palantir.docker' version "${dockerPluginVersion}" id 'com.github.spotbugs' version "${spotbugsPluginVersion}" id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } sourceSets { @@ -65,20 +65,35 @@ javadoc { } application { - mainClassName = 'com.scalar.db.server.ScalarDbServer' + mainClass = 'com.scalar.db.server.ScalarDbServer' startScripts.applicationName = 'scalardb-server' } -docker { - name "ghcr.io/scalar-labs/scalardb-server:${project.version}" - files tasks.distTar.outputs, 'conf/log4j2.properties', 'conf/database.properties', 'docker-entrypoint.sh' -} - task dockerfileLint(type: Exec) { description 'Lint the Dockerfile' commandLine "${project.rootDir}/ci/dockerfile_lint.sh" } +task copyFilesToDockerBuildContextDir(type: Copy) { + description 'Copy files to a temporary folder to build the Docker image' + dependsOn distTar + from('Dockerfile') + from('conf') { + include 'log4j2.properties' + include 'database.properties' + } + from('docker-entrypoint.sh') + from(tasks.distTar.archiveFile) + into('build/docker') +} + +task docker(type: Exec) { + description 'Build ScalarDB Server Docker image' + dependsOn copyFilesToDockerBuildContextDir + workingDir 'build/docker' + commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-server:${project.version}", "." +} + task integrationTestScalarDbServer(type: Test) { useJUnitPlatform() description = 'Runs the integration tests for the ScalarDB Server.' @@ -87,7 +102,7 @@ task integrationTestScalarDbServer(type: Test) { classpath = sourceSets.integrationTestScalarDbServer.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -115,11 +130,13 @@ spotbugsIntegrationTestScalarDbServer.reports { } spotbugsIntegrationTestScalarDbServer.excludeFilter = file("${project.rootDir}/gradle/spotbugs-exclude.xml") -archivesBaseName = "scalardb-server" +base { + archivesName = "scalardb-server" +} // for release distZip { - archiveFileName = "${archivesBaseName}-${project.version}.zip" + archiveFileName = "${base.archivesName.get()}-${project.version}.zip" } // for docker