Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into release
Browse files Browse the repository at this point in the history
# Conflicts:
#	publishToMaven.sh
#	runTests.sh
  • Loading branch information
itboy87 committed Aug 31, 2024
2 parents 33be625 + 36a731e commit 4e46666
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 18 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -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."
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: test

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion ksoup-test/test/com/fleeksoft/ksoup/nodes/ElementTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

/**
Expand Down Expand Up @@ -2673,7 +2674,7 @@ Three
}

@Test
fun cssSelectorWithAstrix() {
fun cssSelectorWithAsterisk() {
val doc = Ksoup.parse("<div class='vds-items_flex-end [&amp;_>_*:first-child]:vds-pt_0'>One</div><div class='vds-items_flex-end'>Two</div>")
val div = doc.expectFirst("div")
val selector = div.cssSelector()
Expand All @@ -2684,6 +2685,16 @@ Three
assertEquals(selected.first(), div)
}

@Test
fun cssSelectorWithPipe() {
val doc: Document = Ksoup.parse("<div><span class='|'>One</div>")
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")
Expand Down
37 changes: 32 additions & 5 deletions publishToMaven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
37 changes: 27 additions & 10 deletions runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4e46666

Please sign in to comment.