Skip to content

Commit

Permalink
add feature flag for auditAndExit support
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolij committed Nov 12, 2024
1 parent c36b647 commit 2a5d880
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: :build
run: ./gradlew build --stacktrace --no-daemon
run: ./gradlew build --stacktrace --no-daemon -PwithAuditAndExit=true

- name: Upload artifacts
if: always()
Expand All @@ -44,7 +44,7 @@ jobs:
id: smokeTest
uses: coactions/setup-xvfb@v1
with:
run: ./gradlew :smokeTest --no-daemon
run: ./gradlew :smokeTest --no-daemon -PwithAuditAndExit=true

- name: Upload test results
if: failure()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY_PR }}
cache-read-only: true
- name: :build
run: ./gradlew build --no-daemon
run: ./gradlew build --no-daemon -PwithAuditAndExit=true
- name: :smokeTest
uses: coactions/setup-xvfb@v1
with:
run: ./gradlew :smokeTest --no-daemon
run: ./gradlew :smokeTest --no-daemon -PwithAuditAndExit=true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: true
- name: :build
run: ./gradlew :build
run: ./gradlew :build -PwithAuditAndExit=true
- name: :smokeTest
uses: coactions/setup-xvfb@v1
with:
run: ./gradlew :smokeTest
run: ./gradlew :smokeTest -PwithAuditAndExit=true
- name: :publishMods
run: ./gradlew publishMods -Prelease_channel=RELEASE --no-daemon
env:
Expand Down
1 change: 1 addition & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildConfig {
buildConfigField("MOD_NAME", "mod_name"())
buildConfigField("ARCHAIC_VERSION_RANGE", "archaic_minecraft_range"())
buildConfigField("VINTAGE_VERSION_RANGE", "vintage_minecraft_range"())
buildConfigField("AUDIT_AND_EXIT_ENABLED", Zume.auditAndExitEnabled)
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/dev/nolij/zume/impl/Zume.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.io.IOException;
import java.nio.file.Path;

import static dev.nolij.zume.impl.ZumeConstants.MOD_ID;
import static dev.nolij.zume.impl.ZumeConstants.*;

public class Zume {

Expand Down Expand Up @@ -68,7 +68,7 @@ public static void registerImplementation(final IZumeImplementation implementati
}

public static void postInit() {
if (Boolean.getBoolean("zumeGradle.auditAndExit")) {
if (AUDIT_AND_EXIT_ENABLED && Boolean.getBoolean("zumeGradle.auditAndExit")) {
try {
MixinUtil.audit();
LOGGER.info("ZumeGradle audit passed");
Expand Down
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ plugins {

operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found")

Zume.auditAndExitEnabled = (rootProject.properties["withAuditAndExit"] as String?).toBoolean()

enum class ReleaseChannel(
val suffix: String? = null,
val releaseType: ReleaseType? = null,
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Zume.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ object Zume {
if (value.isNotEmpty())
_version = value
}

var auditAndExitEnabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ abstract class SmokeTestTask : DefaultTask() {

@TaskAction
fun runSmokeTest() {
if (!Zume.auditAndExitEnabled)
error("Smoke testing requires `auditAndExit` support!")

SmokeTest(
project,
portableMCBinary.get(),
Expand Down

0 comments on commit 2a5d880

Please sign in to comment.