Skip to content

Commit

Permalink
fix wasm tests, uploaded to github packages
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjenx committed Jul 24, 2024
1 parent a54d7d1 commit a2a7b42
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 6 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ android.nonTransitiveRClass=true

#KMM
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.apple.xcodeCompatibility.nowarn=true

#Compose
org.jetbrains.compose.experimental.jscanvas.enabled=true
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 0 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#!/bin/sh

#
Expand Down
1 change: 0 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

@rem
@rem Copyright 2015 the original author or authors.
@rem
Expand Down
48 changes: 47 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ kotlin {
}
}
}
//binaries.executable()
}

wasmJs {
browser {
//https://youtrack.jetbrains.com/issue/CMP-5792/Wasm-has-wrong-absolute-dir-when-testing-library
testTask {
useKarma {
useChromeHeadless()
useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm"))
}
}
}
Expand Down Expand Up @@ -142,3 +143,48 @@ android {
compose = true
}
}

publishing {
repositories {
maven {
name = "githubPackages"
url = uri("https://maven.pkg.github.com/chrisjenx/yakcov")
credentials(PasswordCredentials::class) {
username = project.findProperty("githubPackagesUsername") as String
password = project.findProperty("githubPackagesPassword") as String
}
}
}
}

mavenPublishing {
coordinates("com.chrisjenx.yakcov", "library", "1.0.0-SNAPSHOT")

// the following is optional

pom {
name.set("Yakcov")
description.set("Yet Another Kotlin COmpose Validation library")
inceptionYear.set("2024")
url.set("https://github.com/chrisjenx/yakcov/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("chrisjenx")
name.set("Chris Jenkins ")
url.set("https://github.com/chrisjenx/")
}
}
scm {
url.set("https://github.com/chrisjenx/yakcov/")
connection.set("scm:git:git://github.com/chrisjenx/yakcov.git")
developerConnection.set("scm:git:ssh://[email protected]/chrisjenx/yakcov.git")
}
}
}
55 changes: 55 additions & 0 deletions library/karma.config.d/wasm/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
// This controller is instantiated and set during the preprocessor phase.
const controller = config.__karmaWebpackController;

// only if webpack has instantiated its controller
if (!controller) {
console.warn(
"Webpack has not instantiated controller yet.\n" +
"Check if you have enabled webpack preprocessor and framework before this framework"
)
return
}

config.files.push({
pattern: `${controller.outputPath}/**/*`,
included: false,
served: true,
watched: false
})
}

const KarmaWebpackOutputPlugin = {
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");
14 changes: 13 additions & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ android {
}

dependencies {
implementation(project(":library"))
//implementation(project(":library"))
implementation("com.chrisjenx.yakcov:library:1.0.0-SNAPSHOT")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activityCompose)
Expand All @@ -64,4 +65,15 @@ dependencies {
androidTestImplementation(libs.androidx.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.testManifest)
}

repositories {
mavenCentral()
google()
maven {
url = uri("https://maven.pkg.github.com/chrisjenx/yakcov")
content {
includeGroup("com.chrisjenx.yakcov")
}
}
}

0 comments on commit a2a7b42

Please sign in to comment.