diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 00000000..746bd845 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,48 @@ +name: publish + +on: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + project: + - "ksoup-engine-common:" + + - "ksoup-engine-kotlinx:kotlinx" + - "ksoup:kotlinx" + - "ksoup-network:kotlinx" + + - "ksoup-engine-korlibs:korlibs" + - "ksoup:korlibs" + - "ksoup-network-korlibs:korlibs" + + - "ksoup-engine-ktor2:ktor2" + - "ksoup:ktor2" + - "ksoup-network-ktor2:ktor2" + + - "ksoup-engine-okio:okio" + - "ksoup:okio" + + runs-on: macos-latest + name: Publish ${{ matrix.project }} + steps: + - uses: actions/checkout@v3 + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish ${{ matrix.project }} + run: | + chmod +x ./publishToMaven.sh + ./publishToMaven.sh --remote ${{ matrix.project }} + working-directory: ${{ github.workspace }} + + - name: Success message + run: echo "Publishing of ${{ matrix.project }} completed successfully." \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/test.yml similarity index 99% rename from .github/workflows/deploy.yml rename to .github/workflows/test.yml index 8e9d80e6..0b0cf0c1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build +name: test on: push: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e3b2df4f..4e31e231 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ agp = "8.2.2" #kmp max gradle support 8.2 right now kotlin = "2.0.10" compileSdk = "34" minSdk = "21" -libraryVersion = "0.1.6-alpha1" +libraryVersion = "0.1.6" ktor = "3.0.0-beta-2" ktor2 = "2.3.12" coroutines = "1.8.1" diff --git a/ksoup-test/test/com/fleeksoft/ksoup/nodes/ElementTest.kt b/ksoup-test/test/com/fleeksoft/ksoup/nodes/ElementTest.kt index 944fc0fb..601de724 100644 --- a/ksoup-test/test/com/fleeksoft/ksoup/nodes/ElementTest.kt +++ b/ksoup-test/test/com/fleeksoft/ksoup/nodes/ElementTest.kt @@ -9,6 +9,7 @@ import com.fleeksoft.ksoup.select.Elements import com.fleeksoft.ksoup.select.NodeFilter import com.fleeksoft.ksoup.select.NodeVisitor import com.fleeksoft.ksoup.select.QueryParser +import com.fleeksoft.ksoup.select.SelectorTest.Companion.assertSelectedOwnText import kotlin.test.* /** @@ -2673,7 +2674,7 @@ Three } @Test - fun cssSelectorWithAstrix() { + fun cssSelectorWithAsterisk() { val doc = Ksoup.parse("
One
Two
") val div = doc.expectFirst("div") val selector = div.cssSelector() @@ -2684,6 +2685,16 @@ Three assertEquals(selected.first(), div) } + @Test + fun cssSelectorWithPipe() { + val doc: Document = Ksoup.parse("
One
") + val span: Element = doc.expectFirst("div span") + val selector: String = span.cssSelector() + assertEquals("html > body > div > span.\\|", selector) + val selected = doc.select(selector) + assertSelectedOwnText(selected, "One") + } + @Test fun orphanSiblings() { val el = Element("div") diff --git a/publishToMaven.sh b/publishToMaven.sh index a0c046f5..49b6d523 100755 --- a/publishToMaven.sh +++ b/publishToMaven.sh @@ -15,21 +15,32 @@ if [ "$1" == "--remote" ]; then fi # projectModule:libBuildType -projects=( +default_projects=( "ksoup-engine-common:" - "ksoup-engine-kotlinx:" - "ksoup-engine-korlibs:" - "ksoup-engine-ktor2:" - "ksoup-engine-okio:" + + "ksoup-engine-kotlinx:kotlinx" "ksoup:kotlinx" "ksoup-network:kotlinx" + + "ksoup-engine-korlibs:korlibs" "ksoup:korlibs" "ksoup-network-korlibs:korlibs" + + "ksoup-engine-ktor2:ktor2" "ksoup:ktor2" "ksoup-network-ktor2:ktor2" + + "ksoup-engine-okio:okio" "ksoup:okio" ) + # Check if projects were passed as arguments + if [ "$#" -ne 0 ]; then + projects=("$@") + else + projects=("${default_projects[@]}") + fi + # Function to add wasm to platforms list if not already present add_wasm_platform() { local module_file="$1/module.yaml" @@ -62,6 +73,14 @@ error_handler() { exit 1 } +# Function to safely remove a directory if it exists +safe_remove_dir() { + local dir="$1" + if [ -d "$dir" ]; then + rm -rf "$dir" + fi +} + # Set trap to catch any errors and call the error_handler function trap 'error_handler' ERR @@ -85,6 +104,14 @@ for project in "${projects[@]}"; do fi if [ -n "$buildType" ]; then + + # Remove build directories if they exist + echo "remove build dirs if exists" + safe_remove_dir ".kotlin" + safe_remove_dir "build" + safe_remove_dir ".gradle" + safe_remove_dir "kotlin-js-store" + ./gradlew clean -PlibBuildType="$buildType" --quiet --warning-mode=none echo "Publishing $projectName with libBuildType=$buildType" ./gradlew ":$projectName:$PUBLISH_TASK" -PlibBuildType="$buildType" --quiet --warning-mode=none diff --git a/runTests.sh b/runTests.sh index cdd1847c..97125666 100755 --- a/runTests.sh +++ b/runTests.sh @@ -6,22 +6,39 @@ set -e # Function to add wasm to platforms list if not already present add_wasm_platform() { local module_file="ksoup/module.yaml" + local test_module_file="ksoup-test/module.yaml" + + wasm_added=0 + if grep -q 'platforms: \[.*wasm' "$module_file"; then echo "wasm is already in the platforms list in $module_file" - return 0 else echo "Adding wasm to platforms list in $module_file" cp "$module_file" "$module_file.bak" sed -i.bak 's/\(platforms: \[\)/\1wasm, /' "$module_file" - return 1 + wasm_added=1 + fi + + if grep -q 'platforms: \[.*wasm' "$test_module_file"; then + echo "wasm is already in the platforms list in $test_module_file" + else + echo "Adding wasm to platforms list in $test_module_file" + cp "$test_module_file" "$test_module_file.bak" + sed -i.bak 's/\(platforms: \[\)/\1wasm, /' "$test_module_file" + wasm_added=1 fi } -# Function to restore the original module.yaml file +# Function to restore the original module.yaml files restore_module_yaml() { - echo "Restoring original module.yaml..." - mv "ksoup/module.yaml.bak" "ksoup/module.yaml" + echo "Restoring original module.yaml files..." + if [ -f "ksoup/module.yaml.bak" ]; then + mv "ksoup/module.yaml.bak" "ksoup/module.yaml" + fi + if [ -f "ksoup-test/module.yaml.bak" ]; then + mv "ksoup-test/module.yaml.bak" "ksoup-test/module.yaml" + fi } # Error handler function to restore module.yaml on failure @@ -60,12 +77,12 @@ run_tests() { # Only add/remove wasm for kotlinx and korlibs local wasm_added=0 if [[ "$libBuildType" == "kotlinx" || "$libBuildType" == "korlibs" ]]; then - trap - ERR # Temporarily disable the trap - set +e # Disable exit on error +# trap - ERR # Temporarily disable the trap +# set +e # Disable exit on error add_wasm_platform - wasm_added=$? - set -e # Re-enable exit on error - trap 'error_handler' ERR # Re-enable the trap +# wasm_added=$? +# set -e # Re-enable exit on error +# trap 'error_handler' ERR # Re-enable the trap fi # Remove build directories if they exist