-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v0.2.1 * ci for windows * platform specefic test
- Loading branch information
Showing
12 changed files
with
332 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Build Linux | ||
|
||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
env: | ||
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3g" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: JDK setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: | | ||
11 | ||
17 | ||
distribution: corretto | ||
|
||
- name: Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
./build | ||
./.gradle | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
~/.m2/repository | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Tests | ||
run: ./gradlew allTest --parallel --no-daemon --stacktrace | ||
|
||
- name: Build Artifacts | ||
run: ./gradlew publishToMavenLocal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...orm-paths/src/androidUnitTest/kotlin/me/sujanpoudel/utils/paths/AndroidDirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ApplicationProvider | ||
import kotlinx.io.files.Path | ||
import me.sujanpoudel.utils.paths.utils.toPath | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import kotlin.test.assertEquals | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class AndroidDirectoriesTest { | ||
private val appId: String = "me.sujanpoudel.utils.paths.test" | ||
|
||
private fun exceptedCacheDir(appId: String): Path { | ||
val applicationContext = ApplicationProvider.getApplicationContext<Context>() | ||
return applicationContext.cacheDir.absolutePath.toPath() | ||
} | ||
|
||
private fun exceptedDataDir(appId: String): Path { | ||
val applicationContext = ApplicationProvider.getApplicationContext<Context>() | ||
return applicationContext.dataDir.absolutePath.toPath() | ||
} | ||
|
||
@Test | ||
fun testCacheDirectory() { | ||
assertEquals(exceptedCacheDir(appId), cacheDirectory(appId)) | ||
} | ||
|
||
@Test | ||
fun testDataDirectory() { | ||
assertEquals(exceptedDataDir(appId), dataDirectory(appId)) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
multiplatform-paths/src/commonTest/kotlin/me/sujanpoudel/utils/paths/DirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import kotlinx.io.files.Path | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
abstract class DirectoriesTest { | ||
private val appId: String = "me.sujanpoudel.utils.paths.test" | ||
|
||
abstract fun exceptedCacheDir(appId: String): Path | ||
|
||
abstract fun exceptedDataDir(appId: String): Path | ||
|
||
@Test | ||
fun testCacheDirectory() { | ||
assertEquals(exceptedCacheDir(appId), cacheDirectory(appId)) | ||
} | ||
|
||
@Test | ||
fun testDataDirectory() { | ||
assertEquals(exceptedDataDir(appId), dataDirectory(appId)) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...latform-paths/src/desktopTest/kotlin/me/sujanpoudel/utils/paths/DesktopDirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import kotlinx.io.files.Path | ||
import me.sujanpoudel.utils.paths.utils.div | ||
import me.sujanpoudel.utils.paths.utils.toPath | ||
import me.sujanpoudel.utils.platformIdentifier.Platform | ||
import me.sujanpoudel.utils.platformIdentifier.hostOs | ||
|
||
class DesktopDirectoriesTest : DirectoriesTest() { | ||
private fun getEnv(key: String) = System.getenv(key) as String | ||
|
||
override fun exceptedCacheDir(appId: String): Path { | ||
return when (hostOs) { | ||
is Platform.OS.Linux -> getEnv("HOME").toPath() / ".cache" / appId | ||
is Platform.OS.MacOs -> getEnv("HOME").toPath() / "Library/Caches" / appId | ||
is Platform.OS.Windows -> getEnv("APPDATA").toPath() / "Caches" / appId | ||
else -> error("not supported") | ||
} | ||
} | ||
|
||
override fun exceptedDataDir(appId: String): Path { | ||
return when (hostOs) { | ||
is Platform.OS.Linux -> getEnv("HOME").toPath() / ".local/share" / appId | ||
is Platform.OS.MacOs -> getEnv("HOME").toPath() / "Library/Application Support" / appId | ||
is Platform.OS.Windows -> getEnv("APPDATA").toPath() / appId | ||
else -> error("not supported") | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
multiplatform-paths/src/iosTest/kotlin/me/sujanpoudel/utils/paths/IosDirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import kotlinx.io.files.Path | ||
import me.sujanpoudel.utils.paths.utils.div | ||
import me.sujanpoudel.utils.paths.utils.toPath | ||
import platform.Foundation.NSApplicationSupportDirectory | ||
import platform.Foundation.NSCachesDirectory | ||
import platform.Foundation.NSSearchPathForDirectoriesInDomains | ||
import platform.Foundation.NSUserDomainMask | ||
|
||
class IosDirectoriesTest : DirectoriesTest() { | ||
override fun exceptedCacheDir(appId: String): Path { | ||
return NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true) | ||
.firstOrNull()?.toString()?.toPath() ?: error("Unable to get 'NSCachesDirectory'") | ||
} | ||
|
||
override fun exceptedDataDir(appId: String): Path { | ||
return NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true) | ||
.firstOrNull()?.toString()?.toPath() | ||
?.let { it / appId } ?: error("Unable to get 'NSApplicationSupportDirectory'") | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
multiplatform-paths/src/jsTest/kotlin/me/sujanpoudel/utils/paths/NodeDirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import kotlinx.io.files.Path | ||
import me.sujanpoudel.utils.paths.utils.div | ||
import me.sujanpoudel.utils.paths.utils.toPath | ||
import me.sujanpoudel.utils.platformIdentifier.Platform | ||
import me.sujanpoudel.utils.platformIdentifier.platform | ||
|
||
class NodeDirectoriesTest : DirectoriesTest() { | ||
private fun getEnv(key: String) = eval("""process.env["$key"]""") as String | ||
|
||
override fun exceptedCacheDir(appId: String): Path { | ||
val platform = platform() as? Platform.JS.Node ?: error("not supported") | ||
|
||
return when (platform.os) { | ||
is Platform.OS.Linux -> getEnv("HOME").toPath() / ".cache" / appId | ||
is Platform.OS.MacOs -> getEnv("HOME").toPath() / "Library/Caches" / appId | ||
is Platform.OS.Windows -> getEnv("APPDATA").toPath() / "Caches" / appId | ||
|
||
else -> error("not supported") | ||
} | ||
} | ||
|
||
override fun exceptedDataDir(appId: String): Path { | ||
val platform = platform() as? Platform.JS.Node ?: error("not supported") | ||
|
||
return when (platform.os) { | ||
is Platform.OS.Linux -> getEnv("HOME").toPath() / ".local/share" / appId | ||
is Platform.OS.MacOs -> getEnv("HOME").toPath() / "Library/Application Support" / appId | ||
is Platform.OS.Windows -> getEnv("APPDATA").toPath() / appId | ||
else -> error("not supported") | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
multiplatform-paths/src/macosTest/kotlin/me/sujanpoudel/utils/paths/MacosDirectoriesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2024 Sujan Poudel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.sujanpoudel.utils.paths | ||
|
||
import kotlinx.io.files.Path | ||
import me.sujanpoudel.utils.paths.utils.div | ||
import me.sujanpoudel.utils.paths.utils.toPath | ||
import platform.Foundation.NSApplicationSupportDirectory | ||
import platform.Foundation.NSCachesDirectory | ||
import platform.Foundation.NSSearchPathForDirectoriesInDomains | ||
import platform.Foundation.NSUserDomainMask | ||
|
||
class MacosDirectoriesTest : DirectoriesTest() { | ||
override fun exceptedCacheDir(appId: String): Path { | ||
return NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true) | ||
.firstOrNull()?.toString()?.toPath()?.let { it / appId } ?: error("Unable to get 'NSCachesDirectory'") | ||
} | ||
|
||
override fun exceptedDataDir(appId: String): Path { | ||
return NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true) | ||
.firstOrNull()?.toString()?.toPath()?.let { it / appId } ?: error("Unable to get 'NSApplicationSupportDirectory'") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters