From d3fb2166025239fbc85e93a92e677a93ce6c8b85 Mon Sep 17 00:00:00 2001 From: Konstantin Chukharev Date: Thu, 16 Jan 2025 15:19:26 +0300 Subject: [PATCH 1/3] Split CI workflow into multiple jobs per language --- .github/workflows/build-and-run-tests.yml | 83 ------------ .github/workflows/ci.yml | 157 ++++++++++++++++++++++ 2 files changed, 157 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/build-and-run-tests.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml deleted file mode 100644 index ada025afd..000000000 --- a/.github/workflows/build-and-run-tests.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build and Run Tests [gradle] - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - java: [ '11' ] - runs-on: ubuntu-20.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: "true" - - - name: Setup Java JDK - uses: actions/setup-java@v3.5.0 - with: - distribution: "zulu" - java-version: ${{ matrix.java }} - cache: "gradle" - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Set up ArkAnalyzer - run: | - REPO_URL="https://gitee.com/Lipenx/arkanalyzer.git" - DEST_DIR="arkanalyzer" - MAX_RETRIES=10 - RETRY_DELAY=3 # Delay between retries in seconds - BRANCH="neo/2024-12-04" - - for ((i=1; i<=MAX_RETRIES; i++)); do - git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break - echo "Clone failed, retrying in $RETRY_DELAY seconds..." - sleep "$RETRY_DELAY" - done - - if [[ $i -gt $MAX_RETRIES ]]; then - echo "Failed to clone the repository after $MAX_RETRIES attempts." - exit 1 - else - echo "Repository cloned successfully." - fi - - echo "ARKANALYZER_DIR=$(realpath $DEST_DIR)" >> $GITHUB_ENV - cd $DEST_DIR - - npm install - npm run build - - - name: Install CPython optional dependencies - run: | - sudo apt-get update - sudo apt-get install -yq\ - libssl-dev \ - libffi-dev - - - name: Build and run tests - run: | - ./gradlew build --no-daemon -PcpythonActivated=true - - - name: Run Detekt - run: | - ./gradlew detektMain detektTest --no-daemon - - - name: Upload SARIF to GitHub - uses: github/codeql-action/upload-sarif@v3 - if: success() || failure() - with: - sarif_file: build/reports/detekt/detekt.sarif diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..efac3e7ae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,157 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +env: + JAVA: 11 + JAVA_DISTRIBUTION: zulu + +jobs: + ci-core: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run core tests + run: | + ./gradlew :usvm-core:check :usvm-dataflow:check :usvm-util:check :usvm-sample-language:check + + ci-jvm: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run JVM tests + run: ./gradlew :usvm-jvm:check :usvm-jvm-dataflow:check :usvm-jvm-instrumentation:check + + ci-python: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # 'usvm-python/cpythonadapter/cpython' is a submodule + submodules: true + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Install CPython optional dependencies + run: | + sudo apt-get update + sudo apt-get install -y -q \ + libssl-dev \ + libffi-dev + + - name: Run Python tests + run: ./gradlew -PcpythonActivated=true :usvm-python:check + + ci-ts: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Set up ArkAnalyzer + run: | + REPO_URL="https://gitee.com/Lipenx/arkanalyzer.git" + DEST_DIR="arkanalyzer" + MAX_RETRIES=10 + RETRY_DELAY=3 # Delay between retries in seconds + BRANCH="neo/2024-12-04" + + for ((i=1; i<=MAX_RETRIES; i++)); do + git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break + echo "Clone failed, retrying in $RETRY_DELAY seconds..." + sleep "$RETRY_DELAY" + done + + if [[ $i -gt $MAX_RETRIES ]]; then + echo "Failed to clone the repository after $MAX_RETRIES attempts." + exit 1 + else + echo "Repository cloned successfully." + fi + + echo "ARKANALYZER_DIR=$(realpath $DEST_DIR)" >> $GITHUB_ENV + cd $DEST_DIR + + npm install + npm run build + + - name: Run TS tests + run: ./gradlew :usvm-ts:check :usvm-ts-dataflow:check + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Java JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run Detekt + run: ./gradlew detektMain detektTest + + - name: Upload Detekt SARIF report + uses: github/codeql-action/upload-sarif@v3 + if: success() || failure() + with: + sarif_file: build/reports/detekt/detekt.sarif From a228a8c9c7ec0dbde1e9ae3e1370a2865596be5d Mon Sep 17 00:00:00 2001 From: Konstantin Chukharev Date: Fri, 17 Jan 2025 02:15:26 +0300 Subject: [PATCH 2/3] Add validateProjectList task --- .github/workflows/ci.yml | 3 +++ build.gradle.kts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efac3e7ae..1c028e228 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,6 +147,9 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Validate Project List + run: ./gradlew validateProjectList + - name: Run Detekt run: ./gradlew detektMain detektTest diff --git a/build.gradle.kts b/build.gradle.kts index d2e8d1144..5daeb61dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,38 @@ plugins { id("usvm.kotlin-conventions") } + +tasks.register("validateProjectList") { + group = "verification" + description = "Checks that the list of subprojects is exactly the expected." + + doLast { + // Define the expected subprojects here. + val expectedProjects = setOf( + project(":usvm-core"), + project(":usvm-util"), + project(":usvm-dataflow"), + project(":usvm-sample-language"), + project(":usvm-jvm"), + project(":usvm-jvm-dataflow"), + project(":usvm-jvm-instrumentation"), + project(":usvm-python"), + project(":usvm-ts"), + project(":usvm-ts-dataflow"), + ) + + // Gather the actual subprojects from the current root project. + // Note: 'project.subprojects' is recursive! + val actualProjects = project.subprojects - project(":usvm-python").subprojects + + // Compare and throw an error if something is missing or unexpected. + val missingProjects = expectedProjects - actualProjects + if (missingProjects.isNotEmpty()) { + throw GradleException("Missing subprojects (${missingProjects.size}): $missingProjects") + } + val unexpectedProjects = actualProjects - expectedProjects + if (unexpectedProjects.isNotEmpty()) { + throw GradleException("Unexpected subprojects (${unexpectedProjects.size}): $unexpectedProjects") + } + } +} From c1ef3a5ea8c64dd12ebd1e626b56db4cdfb7013f Mon Sep 17 00:00:00 2001 From: Konstantin Chukharev Date: Fri, 17 Jan 2025 02:29:38 +0300 Subject: [PATCH 3/3] Do not use cache from 'setup-java' `gradle/actions/setup-gradle` already provides better cache --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c028e228..c177a4df3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,6 @@ jobs: with: java-version: ${{ env.JAVA }} distribution: ${{ env.JAVA_DISTRIBUTION }} - cache: gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -43,7 +42,6 @@ jobs: with: java-version: ${{ env.JAVA }} distribution: ${{ env.JAVA_DISTRIBUTION }} - cache: gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -65,7 +63,6 @@ jobs: with: java-version: ${{ env.JAVA }} distribution: ${{ env.JAVA_DISTRIBUTION }} - cache: gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -91,7 +88,6 @@ jobs: with: java-version: ${{ env.JAVA }} distribution: ${{ env.JAVA_DISTRIBUTION }} - cache: gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -142,7 +138,6 @@ jobs: with: distribution: temurin java-version: 21 - cache: gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4