From 3833ed0bc3406ea082d9080a3106cdcfafa3c76e Mon Sep 17 00:00:00 2001 From: Kevin Mas Ruiz Date: Mon, 23 Sep 2024 16:29:55 +0200 Subject: [PATCH] chore: instead of running the whole pipeline again, only allow drafts when main is green already (#55) --- .github/workflows/draft-release.yaml | 41 ++-------------------------- build.gradle.kts | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/draft-release.yaml b/.github/workflows/draft-release.yaml index 89d79b91..2b172151 100644 --- a/.github/workflows/draft-release.yaml +++ b/.github/workflows/draft-release.yaml @@ -68,47 +68,10 @@ jobs: echo "If this version has already been release consider using a different one." exit 1 fi - - name: Setup Docker (for Test Containers) + - name: Verify Checks in main run: | - sudo apt update -y - sudo apt install -y docker docker-compose - - name: Run Unit and Integration Tests - run: | - ./gradlew "unitTest" ":packages:jetbrains-plugin:test" + ./gradlew "mainStatus" - - name: Prepare License Key - env: - JB_TEST_KEY: ${{ secrets.JB_TEST_KEY }} - run: | - mkdir -p packages/jetbrains-plugin/build/idea-sandbox/config-uiTest - echo "$JB_TEST_KEY" | base64 -d > packages/jetbrains-plugin/build/idea-sandbox/config-uiTest/idea.key - - name: Start UI Test Environment - run: | - export DISPLAY=:99.0 - Xvfb -ac :99 -screen 0 1920x1080x24 & - sleep 10 - mkdir -p packages/jetbrains-plugin/build/reports - ./gradlew :packages:jetbrains-plugin:runIdeForUiTests > packages/jetbrains-plugin/build/reports/idea.log & - IDEA_PID=$! - echo $IDEA_PID > idea.pid - - name: Wait for IDE to start - uses: jtalk/url-health-check-action@v3 - with: - url: "http://127.0.0.1:8082" - max-attempts: 15 - retry-delay: 30s - - name: Run UI Tests - uses: nick-fields/retry@v3 - env: - DISPLAY: ":99.0" - with: - timeout_minutes: 30 - max_attempts: 3 - command: ./gradlew --quiet --console=plain :packages:jetbrains-plugin:uiTest - - name: Stop IDEA - run: | - IDEA_PID=$(cat idea.pid) - kill -9 $IDEA_PID - name: Patch Plugin XML run: | ./gradlew ":packages:jetbrains-plugin:patchPluginXml" diff --git a/build.gradle.kts b/build.gradle.kts index d786213d..f724a411 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,6 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask +import groovy.json.JsonSlurper +import java.net.URL group = "com.mongodb" // This should be bumped when releasing a new version using the versionBump task: @@ -164,4 +166,30 @@ tasks { println(rootProject.version) } } + + register("mainStatus") { + group = "environment" + + doLast { + val checks = JsonSlurper().parse(URL("https://api.github.com/repos/mongodb-js/intellij/commits/main/check-runs")) as Map + val check_runs = checks["check_runs"] as List> + var success: Boolean = true + for (check in check_runs) { + if (check["name"] == "Prepare Release") { + continue + } + + if (check["conclusion"] != "success") { + System.err.println("[❌] Check ${check["name"]} is still with status ${check["status"]} and conclusion ${check["conclusion"]}: ${check["html_url"]}") + success = false + } else { + println("[✅] Check ${check["name"]} has finished successfully: ${check["html_url"]}") + } + } + + if (!success) { + throw GradleException("Checks in main must be successful.") + } + } + } } \ No newline at end of file