diff --git a/.github/workflows/deployment-ci.yml b/.github/workflows/deployment-ci.yml index a7c817adcd7..44567004d1d 100644 --- a/.github/workflows/deployment-ci.yml +++ b/.github/workflows/deployment-ci.yml @@ -4,6 +4,8 @@ name: Kotlin CI on: push: + tags-ignore: + - '**' # We don't want this to run on tags pushes pull_request: release: types: [published] @@ -39,11 +41,10 @@ jobs: if: | !contains(github.event.head_commit.message, '[publish skip]') && !contains(github.event.pull_request.title, '[publish skip]') && github.event_name != 'pull_request' && github.ref != 'refs/heads/master' + needs: build env: KORD_TEST_TOKEN: ${{ secrets.KORD_TEST_TOKEN }} - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} - BINTRAY_USER: ${{ secrets.BINTRAY_USER }} NEXUS_USER: ${{ secrets.NEXUS_USER }} NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.signingKey }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ed1dcb891c..651945c08e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.7.0-RC3 + +## Fixes + +* Unhandled missing access when trying to get vanity url with the feature disabled. #264 + # 0.7.0-RC2 ## Additions diff --git a/core/src/main/kotlin/behavior/GuildBehavior.kt b/core/src/main/kotlin/behavior/GuildBehavior.kt index fa275de9d7d..6dc3911efbf 100644 --- a/core/src/main/kotlin/behavior/GuildBehavior.kt +++ b/core/src/main/kotlin/behavior/GuildBehavior.kt @@ -494,7 +494,7 @@ interface GuildBehavior : KordEntity, Strategizable { * @throws [RestRequestException] if something went wrong during the request. */ suspend fun getVanityUrl(): String? { - val identifier = catchDiscordError(JsonErrorCode.InviteCodeInvalidOrTaken) { + val identifier = catchDiscordError(JsonErrorCode.InviteCodeInvalidOrTaken, JsonErrorCode.MissingAccess) { kord.rest.guild.getVanityInvite(id).code } ?: return null return "https://discord.gg/$identifier" @@ -935,8 +935,8 @@ suspend inline fun GuildBehavior.bulkEditSlashCommandPermissions(noinline builde } kord.slashCommands.bulkEditApplicationCommandPermissions( - kord.selfId, - id, - builder + kord.selfId, + id, + builder ) } diff --git a/core/src/test/kotlin/KordTest.kt b/core/src/test/kotlin/KordTest.kt index 9ff57104170..a82ed4423b0 100644 --- a/core/src/test/kotlin/KordTest.kt +++ b/core/src/test/kotlin/KordTest.kt @@ -5,8 +5,10 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onCompletion import org.junit.jupiter.api.Test +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable import java.util.concurrent.CountDownLatch +@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") internal class KordTest { @Test diff --git a/core/src/test/kotlin/StrategyTest.kt b/core/src/test/kotlin/StrategyTest.kt index 3ba98ca9c55..2175d45597b 100644 --- a/core/src/test/kotlin/StrategyTest.kt +++ b/core/src/test/kotlin/StrategyTest.kt @@ -2,17 +2,14 @@ import dev.kord.cache.api.put import dev.kord.core.Kord import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.* import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Disabled +@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") class StrategyTest { lateinit var kord: Kord @@ -23,28 +20,27 @@ class StrategyTest { } @Test - @EnabledIfEnvironmentVariable(named = "TARGET_BRANCH", matches = "master") + @Order(1) fun `rest only`() = runBlocking { - kord.with(EntitySupplyStrategy.rest).getSelf() + val fromRest = kord.with(EntitySupplyStrategy.rest).getSelfOrNull() val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() assertNull(inCache) + assertNotNull(fromRest) } @Test - @Disabled + @Order(3) fun `cache only`() = runBlocking { - val self = kord.with(EntitySupplyStrategy.rest).getSelf() - kord.cache.put(self.data) - val inCache = kord.with(EntitySupplyStrategy.cache).getSelf() - assertEquals(self, inCache) + val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() + assertNotNull(inCache) } @Test - @EnabledIfEnvironmentVariable(named = "TARGET_BRANCH", matches = "master") + @Order(2) fun `cache falls back to rest`() = runBlocking { val cache = kord.with(EntitySupplyStrategy.cache) - val inCache = cache.getSelf() + val inCache = cache.getSelfOrNull() assertNull(inCache) diff --git a/core/src/test/kotlin/regression/CacheMissRegression.kt b/core/src/test/kotlin/regression/CacheMissRegression.kt index 1868d1e3df7..01a8bd89f40 100644 --- a/core/src/test/kotlin/regression/CacheMissRegression.kt +++ b/core/src/test/kotlin/regression/CacheMissRegression.kt @@ -114,7 +114,7 @@ class CrashingHandler(val client: HttpClient) : RequestHandler { } } -@EnabledIfEnvironmentVariable(named = "TARGET_BRANCH", matches = "master") +@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") class CacheMissingRegressions { lateinit var kord: Kord diff --git a/core/src/test/kotlin/rest/RestTest.kt b/core/src/test/kotlin/rest/RestTest.kt index 31ffe02f15f..dee1dae8500 100644 --- a/core/src/test/kotlin/rest/RestTest.kt +++ b/core/src/test/kotlin/rest/RestTest.kt @@ -33,7 +33,7 @@ fun imageBinary(path: String): Image { @TestMethodOrder(MethodOrderer.OrderAnnotation::class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@EnabledIfEnvironmentVariable(named = "TARGET_BRANCH", matches = "master") +@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") class RestServiceTest { private val publicGuildId = Snowflake(322850917248663552)