From e75df285f040abe7fcafbacf96f37da1114ad031 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Mon, 6 Oct 2025 08:20:10 +0200 Subject: [PATCH 01/15] Mark 1.19 as stable version Signed-off-by: Uilian Ries --- patch_ng.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patch_ng.py b/patch_ng.py index 7312ba1..c6efb8c 100755 --- a/patch_ng.py +++ b/patch_ng.py @@ -29,7 +29,7 @@ SOFTWARE. """ __author__ = "Conan.io " -__version__ = "1.19.0-dev" +__version__ = "1.19.0" __license__ = "MIT" __url__ = "https://github.com/conan-io/python-patch" From 62e6c5f1ad9dc5ca722c79e611c7461268eb4d98 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 08:13:28 +0200 Subject: [PATCH 02/15] Add workflow to validate patch-ng with Conan Signed-off-by: Uilian Ries --- .github/workflows/conan.yml | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/conan.yml diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 0000000..ba8ee7d --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,45 @@ +name: Validate Conan client + +on: + push: + paths-ignore: + - 'doc/**' + - '**/*.md' + - 'LICENSE' + - 'example/**' + - '.gitignore' + - 'tests/**' + workflow_dispatch: + pull_request: + paths-ignore: + - 'doc/**' + - '**/*.md' + - 'LICENSE' + - 'example/**' + - '.gitignore' + - 'tests/**' + +jobs: + conan-client-validate: + name: "Validate Conan client" + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v5 + + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: 3.12 + architecture: x64 + + - name: Clone conan client + run: git clone --depth 1 https://github.com/conan-io/conan.git + + - name: Run Conan client tests involving patch-ng + run: | + cd conan/ + pip install -r conans/requirements_dev.txt + pytest -v test/functional/test_third_party_patch_flow.py + pytest -v test/functional/tools/test_files.py + pytest -v test/unittests/tools/files/test_patches.py + From 7017512620d708de79837b1a24484b6618a0b802 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 08:16:05 +0200 Subject: [PATCH 03/15] Install Conan requirements for testing Signed-off-by: Uilian Ries --- .github/workflows/conan.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml index ba8ee7d..e952949 100644 --- a/.github/workflows/conan.yml +++ b/.github/workflows/conan.yml @@ -33,13 +33,16 @@ jobs: architecture: x64 - name: Clone conan client - run: git clone --depth 1 https://github.com/conan-io/conan.git + run: | + git clone --depth 1 https://github.com/conan-io/conan.git + cd conan/ + pip install -r conans/requirements_dev.txt + pip install -r conans/requirements.txt - name: Run Conan client tests involving patch-ng run: | + pip install -e . cd conan/ - pip install -r conans/requirements_dev.txt pytest -v test/functional/test_third_party_patch_flow.py pytest -v test/functional/tools/test_files.py pytest -v test/unittests/tools/files/test_patches.py - From b2f05c24b490b4f61a54c66839d9b25b28ae97d0 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 09:39:21 +0200 Subject: [PATCH 04/15] Add CCI validation Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 35 ++++++++++++++++++ .github/workflows/conan-center-index.yml | 45 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/scripts/validate-cci-patch-ng.sh create mode 100644 .github/workflows/conan-center-index.yml diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh new file mode 100644 index 0000000..7050f01 --- /dev/null +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SAMPLE_RECIPES_NUM=10 + +# Find all conanfile.py files that use apply_conandata_patches +RECIPES=$(find . -type f -name "conanfile.py" -exec grep "apply_conandata_patches(self)" {} + | sort | uniq | cut -d':' -f1) + +echo "Found $(echo "$RECIPES" | wc -l) recipes using apply_conandata_patches." + +# Pick 10 random recipes +SAMPLE_RECIPES=$(shuf -e ${RECIPES[@]} -n $SAMPLE_RECIPES_NUM) + +echo "Pick $SAMPLE_RECIPES_NUM random recipes to test:" +echo "$SAMPLE_RECIPES" + +# Run conan create for each sampled recipe +for it in $SAMPLE_RECIPES; do + recipe_dir=$(dirname "${it}") + pushd "$recipe_dir" + echo "Testing recipe in directory: ${recipe_dir}" + # Get a version from conandata.yml that uses a patch + version=$(yq '.patches | keys | .[0]' conandata.yml 2>/dev/null) + if [ -z "$version" ]; then + echo "ERROR: No patches found in conandata.yml for $recipe_dir, skipping." + continue + fi + version=$(echo ${version} | tr -d '"') + # Replace apply_conandata_patches to exit just after applying patches + sed -i -e 's/apply_conandata_patches(self)/apply_conandata_patches(self); import sys; sys.exit(0)/g' conanfile.py + # Create the package with the specified version + conan create . --version=${version} --build=missing + popd +done \ No newline at end of file diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml new file mode 100644 index 0000000..c58c7dc --- /dev/null +++ b/.github/workflows/conan-center-index.yml @@ -0,0 +1,45 @@ +name: Validate Applying Patch in Conan Center Index + +on: + push: + paths-ignore: + - 'doc/**' + - '**/*.md' + - 'LICENSE' + - 'example/**' + - '.gitignore' + - 'tests/**' + workflow_dispatch: + pull_request: + paths-ignore: + - 'doc/**' + - '**/*.md' + - 'LICENSE' + - 'example/**' + - '.gitignore' + - 'tests/**' + +jobs: + conan-center-index-validate: + name: "Validate Patche-NG in Conan Center Index" + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Conan client + uses: conan-io/setup-conan@v1 + + - name: Setup Python NG + run: pip install -e . + + - name: Checkout conan-center-index + uses: actions/checkout@v5 + with: + repository: conan-io/conan-center-index + path: conan-center-index + ref: 'd8efbb6f3c51b134205f01d3f8d90bdad1a67fe6' + + - name: Validate Python-NG patch application + working-directory: conan-center-index/recipes + run: bash .github/scripts/validate-cci-patch-ng.sh \ No newline at end of file From 3a1db14283da2670a84c85ee94ed7323c0318744 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 09:43:24 +0200 Subject: [PATCH 05/15] Refer repo in a separte folder Signed-off-by: Uilian Ries --- .github/workflows/conan-center-index.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml index c58c7dc..37d5dbf 100644 --- a/.github/workflows/conan-center-index.yml +++ b/.github/workflows/conan-center-index.yml @@ -26,12 +26,14 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v5 + with: + path: patch-ng-repo - name: Setup Conan client uses: conan-io/setup-conan@v1 - name: Setup Python NG - run: pip install -e . + run: pip install -e patch-ng-repo - name: Checkout conan-center-index uses: actions/checkout@v5 @@ -42,4 +44,4 @@ jobs: - name: Validate Python-NG patch application working-directory: conan-center-index/recipes - run: bash .github/scripts/validate-cci-patch-ng.sh \ No newline at end of file + run: bash scripts-repo/.github/scripts/validate-cci-patch-ng.sh \ No newline at end of file From e9986ed470ffea19898101a4c8914f150a98ef7d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 09:45:54 +0200 Subject: [PATCH 06/15] Move test script Signed-off-by: Uilian Ries --- .github/workflows/conan-center-index.yml | 6 ++---- {.github => tests}/scripts/validate-cci-patch-ng.sh | 0 2 files changed, 2 insertions(+), 4 deletions(-) rename {.github => tests}/scripts/validate-cci-patch-ng.sh (100%) diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml index 37d5dbf..13b3827 100644 --- a/.github/workflows/conan-center-index.yml +++ b/.github/workflows/conan-center-index.yml @@ -26,14 +26,12 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v5 - with: - path: patch-ng-repo - name: Setup Conan client uses: conan-io/setup-conan@v1 - name: Setup Python NG - run: pip install -e patch-ng-repo + run: pip install -e . - name: Checkout conan-center-index uses: actions/checkout@v5 @@ -44,4 +42,4 @@ jobs: - name: Validate Python-NG patch application working-directory: conan-center-index/recipes - run: bash scripts-repo/.github/scripts/validate-cci-patch-ng.sh \ No newline at end of file + run: bash tests/scripts/validate-cci-patch-ng.sh \ No newline at end of file diff --git a/.github/scripts/validate-cci-patch-ng.sh b/tests/scripts/validate-cci-patch-ng.sh similarity index 100% rename from .github/scripts/validate-cci-patch-ng.sh rename to tests/scripts/validate-cci-patch-ng.sh From 3ee94b792366d7ef93c33c83a84c0376b92f02a0 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 09:49:24 +0200 Subject: [PATCH 07/15] Try to fix test script path Signed-off-by: Uilian Ries --- .github/workflows/conan-center-index.yml | 6 ++++-- .github/workflows/workflow.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml index 13b3827..ee1f2de 100644 --- a/.github/workflows/conan-center-index.yml +++ b/.github/workflows/conan-center-index.yml @@ -26,12 +26,14 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v5 + with: + path: python-ng - name: Setup Conan client uses: conan-io/setup-conan@v1 - name: Setup Python NG - run: pip install -e . + run: pip install -e ./python-ng - name: Checkout conan-center-index uses: actions/checkout@v5 @@ -42,4 +44,4 @@ jobs: - name: Validate Python-NG patch application working-directory: conan-center-index/recipes - run: bash tests/scripts/validate-cci-patch-ng.sh \ No newline at end of file + run: bash "${GITHUB_WORKSPACE}/python-ng/tests/scripts/validate-cci-patch-ng.sh" \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b5cac3a..1d9bb40 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,4 @@ -name: Main workflow +name: Python Patch-NG Tests on: push: From 173c5d53814e767e62e1d657d3f41eb21f5aae18 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 10:10:08 +0200 Subject: [PATCH 08/15] Exclude recipe with system requirements Signed-off-by: Uilian Ries --- tests/scripts/validate-cci-patch-ng.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/scripts/validate-cci-patch-ng.sh b/tests/scripts/validate-cci-patch-ng.sh index 7050f01..ce1dd43 100644 --- a/tests/scripts/validate-cci-patch-ng.sh +++ b/tests/scripts/validate-cci-patch-ng.sh @@ -5,11 +5,12 @@ set -euo pipefail SAMPLE_RECIPES_NUM=10 # Find all conanfile.py files that use apply_conandata_patches -RECIPES=$(find . -type f -name "conanfile.py" -exec grep "apply_conandata_patches(self)" {} + | sort | uniq | cut -d':' -f1) +RECIPES=$(find . -type f -name "conanfile.py" -exec grep -l "apply_conandata_patches(self)" {} + | sort | uniq) +# And does not need system requirement +RECIPES=$(grep -L "/system" $RECIPES) echo "Found $(echo "$RECIPES" | wc -l) recipes using apply_conandata_patches." -# Pick 10 random recipes SAMPLE_RECIPES=$(shuf -e ${RECIPES[@]} -n $SAMPLE_RECIPES_NUM) echo "Pick $SAMPLE_RECIPES_NUM random recipes to test:" From 6f1d4cb43cfe418ac4ce9e02b59b00d2829cc91f Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 10:11:55 +0200 Subject: [PATCH 09/15] Trigger CI Signed-off-by: Uilian Ries --- .github/workflows/conan-center-index.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml index ee1f2de..230be5b 100644 --- a/.github/workflows/conan-center-index.yml +++ b/.github/workflows/conan-center-index.yml @@ -44,4 +44,4 @@ jobs: - name: Validate Python-NG patch application working-directory: conan-center-index/recipes - run: bash "${GITHUB_WORKSPACE}/python-ng/tests/scripts/validate-cci-patch-ng.sh" \ No newline at end of file + run: bash "${GITHUB_WORKSPACE}/python-ng/tests/scripts/validate-cci-patch-ng.sh" From ff7b15c1b8949bf86dce10c323d1a40e9842a243 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 10:21:21 +0200 Subject: [PATCH 10/15] Support a few non patch related errors Signed-off-by: Uilian Ries --- .../scripts/validate-cci-patch-ng.sh | 33 +++++++++++++++++-- .github/workflows/conan-center-index.yml | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) rename {tests => .github}/scripts/validate-cci-patch-ng.sh (52%) diff --git a/tests/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh similarity index 52% rename from tests/scripts/validate-cci-patch-ng.sh rename to .github/scripts/validate-cci-patch-ng.sh index ce1dd43..eb13c2c 100644 --- a/tests/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -2,7 +2,9 @@ set -euo pipefail -SAMPLE_RECIPES_NUM=10 +SAMPLE_RECIPES_NUM=30 +RECIPES_BUILD_NUM=10 +RECIPES_BUILT_COUNT=0 # Find all conanfile.py files that use apply_conandata_patches RECIPES=$(find . -type f -name "conanfile.py" -exec grep -l "apply_conandata_patches(self)" {} + | sort | uniq) @@ -18,6 +20,12 @@ echo "$SAMPLE_RECIPES" # Run conan create for each sampled recipe for it in $SAMPLE_RECIPES; do + + if [ $RECIPES_BUILT_COUNT -ge $RECIPES_BUILD_NUM ]; then + echo "Reached the limit of $RECIPES_BUILD_NUM recipes built, stopping. All done." + break + fi + recipe_dir=$(dirname "${it}") pushd "$recipe_dir" echo "Testing recipe in directory: ${recipe_dir}" @@ -30,7 +38,28 @@ for it in $SAMPLE_RECIPES; do version=$(echo ${version} | tr -d '"') # Replace apply_conandata_patches to exit just after applying patches sed -i -e 's/apply_conandata_patches(self)/apply_conandata_patches(self); import sys; sys.exit(0)/g' conanfile.py + + # Allow conan create to fail without stopping the script, we will handle errors manually + set +e + # Create the package with the specified version - conan create . --version=${version} --build=missing + output=$(conan create . --version=${version} --build=missing 2>&1) + # Accept some errors as non-fatal + if [ $? -ne 0 ]; then + echo "WARNING: conan create failed for $recipe_dir" + if echo "$output" | grep -q "ERROR: There are invalid packages"; then + echo "WARNING: Invalid packages found, skipping the build." + elfi echo "$output" | grep -q "ERROR: Version conflict"; then + echo "WARNING: Version conflict, skipping the build." + else + echo "ERROR: Fatal error during conan create command execution:" + echo "$output" + popd + exit 1 + fi + else + echo "INFO: conan create succeeded for $recipe_dir." + RECIPES_BUILT_COUNT=$((RECIPES_BUILT_COUNT + 1)) + fi popd done \ No newline at end of file diff --git a/.github/workflows/conan-center-index.yml b/.github/workflows/conan-center-index.yml index 230be5b..0b9c5c0 100644 --- a/.github/workflows/conan-center-index.yml +++ b/.github/workflows/conan-center-index.yml @@ -44,4 +44,4 @@ jobs: - name: Validate Python-NG patch application working-directory: conan-center-index/recipes - run: bash "${GITHUB_WORKSPACE}/python-ng/tests/scripts/validate-cci-patch-ng.sh" + run: bash "${GITHUB_WORKSPACE}/python-ng/.github/scripts/validate-cci-patch-ng.sh" From a1a060e234c8d0652df4e846f91a92e51ed59e56 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 10:23:54 +0200 Subject: [PATCH 11/15] Allow missing binaries as an error Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh index eb13c2c..7be89ac 100644 --- a/.github/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -43,7 +43,7 @@ for it in $SAMPLE_RECIPES; do set +e # Create the package with the specified version - output=$(conan create . --version=${version} --build=missing 2>&1) + output=$(conan create . --version=${version} 2>&1) # Accept some errors as non-fatal if [ $? -ne 0 ]; then echo "WARNING: conan create failed for $recipe_dir" @@ -51,6 +51,8 @@ for it in $SAMPLE_RECIPES; do echo "WARNING: Invalid packages found, skipping the build." elfi echo "$output" | grep -q "ERROR: Version conflict"; then echo "WARNING: Version conflict, skipping the build." + elfi echo "$output" | grep -q "ERROR: Missing binary"; then + echo "WARNING: Missing binary, skipping the build." else echo "ERROR: Fatal error during conan create command execution:" echo "$output" From 1cac875ea06f9c3bfdd5e64b91d057f4ef9b30ca Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 10:32:15 +0200 Subject: [PATCH 12/15] Fix condition Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh index 7be89ac..28e3025 100644 --- a/.github/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -49,9 +49,9 @@ for it in $SAMPLE_RECIPES; do echo "WARNING: conan create failed for $recipe_dir" if echo "$output" | grep -q "ERROR: There are invalid packages"; then echo "WARNING: Invalid packages found, skipping the build." - elfi echo "$output" | grep -q "ERROR: Version conflict"; then + elif echo "$output" | grep -q "ERROR: Version conflict"; then echo "WARNING: Version conflict, skipping the build." - elfi echo "$output" | grep -q "ERROR: Missing binary"; then + elif echo "$output" | grep -q "ERROR: Missing binary"; then echo "WARNING: Missing binary, skipping the build." else echo "ERROR: Fatal error during conan create command execution:" @@ -60,7 +60,9 @@ for it in $SAMPLE_RECIPES; do exit 1 fi else - echo "INFO: conan create succeeded for $recipe_dir." + echo "INFO: Successfully patched $recipe_dir." + echo "$output" | tail -n 10 + echo "-------------------------------------------------------" RECIPES_BUILT_COUNT=$((RECIPES_BUILT_COUNT + 1)) fi popd From 274c01e3fe99e0792d2ba7f5ae49df3c8cd701a6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 11:46:05 +0200 Subject: [PATCH 13/15] Exclude conans import Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 36 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh index 28e3025..767fa62 100644 --- a/.github/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -2,24 +2,43 @@ set -euo pipefail +# Get TEST_ALL_RECIPES from environment variable, default to 0 (false) +PYTHON_NG_TEST_ALL_RECIPES=${PYTHON_NG_TEST_ALL_RECIPES:-0} + SAMPLE_RECIPES_NUM=30 RECIPES_BUILD_NUM=10 RECIPES_BUILT_COUNT=0 +# Ensure required tools are installed +COMMANDS=("conan" "yq" "jq") +for cmd in "${COMMANDS[@]}"; do + if ! which $cmd &> /dev/null; then + echo "ERROR: $cmd is not installed. Please install $cmd to proceed." + exit 1 + fi +done + # Find all conanfile.py files that use apply_conandata_patches RECIPES=$(find . -type f -name "conanfile.py" -exec grep -l "apply_conandata_patches(self)" {} + | sort | uniq) # And does not need system requirement RECIPES=$(grep -L "/system" $RECIPES) +# And does not contain Conan 1 imports +RECIPES=$(grep -L "from conans" $RECIPES) echo "Found $(echo "$RECIPES" | wc -l) recipes using apply_conandata_patches." -SAMPLE_RECIPES=$(shuf -e ${RECIPES[@]} -n $SAMPLE_RECIPES_NUM) - -echo "Pick $SAMPLE_RECIPES_NUM random recipes to test:" -echo "$SAMPLE_RECIPES" +if [ "${PYTHON_NG_TEST_ALL_RECIPES}" -eq "1" ]; then + SAMPLE_RECIPES_NUM=$(echo "$RECIPES" | wc -l) + RECIPES_BUILD_NUM=$SAMPLE_RECIPES_NUM + echo "PYTHON_NG_TEST_ALL_RECIPES is set to 1, testing all $SAMPLE_RECIPES_NUM recipes." +else + RECIPES=$(shuf -e ${RECIPES[@]} -n $SAMPLE_RECIPES_NUM) + echo "Pick $SAMPLE_RECIPES_NUM random recipes to test:" + echo "$RECIPES" +fi # Run conan create for each sampled recipe -for it in $SAMPLE_RECIPES; do +for it in $RECIPES; do if [ $RECIPES_BUILT_COUNT -ge $RECIPES_BUILD_NUM ]; then echo "Reached the limit of $RECIPES_BUILD_NUM recipes built, stopping. All done." @@ -27,12 +46,13 @@ for it in $SAMPLE_RECIPES; do fi recipe_dir=$(dirname "${it}") - pushd "$recipe_dir" + pushd "$recipe_dir" > /dev/null echo "Testing recipe in directory: ${recipe_dir}" # Get a version from conandata.yml that uses a patch version=$(yq '.patches | keys | .[0]' conandata.yml 2>/dev/null) if [ -z "$version" ]; then echo "ERROR: No patches found in conandata.yml for $recipe_dir, skipping." + popd > /dev/null continue fi version=$(echo ${version} | tr -d '"') @@ -56,7 +76,7 @@ for it in $SAMPLE_RECIPES; do else echo "ERROR: Fatal error during conan create command execution:" echo "$output" - popd + popd > /dev/null exit 1 fi else @@ -65,5 +85,5 @@ for it in $SAMPLE_RECIPES; do echo "-------------------------------------------------------" RECIPES_BUILT_COUNT=$((RECIPES_BUILT_COUNT + 1)) fi - popd + popd > /dev/null done \ No newline at end of file From e07cb8b48c714a80f7c30b2bd96a106f9c4117d6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 12:49:38 +0200 Subject: [PATCH 14/15] Update allowed errors Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh index 767fa62..d5322e8 100644 --- a/.github/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -67,12 +67,19 @@ for it in $RECIPES; do # Accept some errors as non-fatal if [ $? -ne 0 ]; then echo "WARNING: conan create failed for $recipe_dir" - if echo "$output" | grep -q "ERROR: There are invalid packages"; then - echo "WARNING: Invalid packages found, skipping the build." - elif echo "$output" | grep -q "ERROR: Version conflict"; then - echo "WARNING: Version conflict, skipping the build." - elif echo "$output" | grep -q "ERROR: Missing binary"; then - echo "WARNING: Missing binary, skipping the build." + allowed_errors=( + "ERROR: There are invalid packages" + "ERROR: Version conflict" + "ERROR: Missing binary" + "Failed to establish a new connection" + "ConanException: sha256 signature failed" + "NotFoundException: Not found" + ) + # check if any allowed error is in the output + if printf '%s\n' "${allowed_errors[@]}" | grep -q -f - <(echo "$output"); then + echo "WARNING: Could not apply patches, skipping build:" + echo "$output" | tail -n 10 + echo "-------------------------------------------------------" else echo "ERROR: Fatal error during conan create command execution:" echo "$output" From 50fcd3bcd957edf3a439a26ca16b01ad3db5946d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 8 Oct 2025 16:28:08 +0200 Subject: [PATCH 15/15] Fix quoted file paths Signed-off-by: Uilian Ries --- .github/scripts/validate-cci-patch-ng.sh | 3 +++ patch_ng.py | 3 +++ tests/filewithspace/0001-quote.diff | 6 +++++ tests/run_tests.py | 34 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 tests/filewithspace/0001-quote.diff diff --git a/.github/scripts/validate-cci-patch-ng.sh b/.github/scripts/validate-cci-patch-ng.sh index d5322e8..85abefe 100644 --- a/.github/scripts/validate-cci-patch-ng.sh +++ b/.github/scripts/validate-cci-patch-ng.sh @@ -73,6 +73,9 @@ for it in $RECIPES; do "ERROR: Missing binary" "Failed to establish a new connection" "ConanException: sha256 signature failed" + "ConanException: Error downloading file" + "ConanException: Cannot find" + "certificate verify failed: certificate has expired" "NotFoundException: Not found" ) # check if any allowed error is in the output diff --git a/patch_ng.py b/patch_ng.py index c6efb8c..334e238 100755 --- a/patch_ng.py +++ b/patch_ng.py @@ -900,6 +900,9 @@ def _normalize_filenames(self): p.source = xnormpath(p.source) p.target = xnormpath(p.target) + p.source = p.source.strip(b'"') + p.target = p.target.strip(b'"') + sep = b'/' # sep value can be hardcoded, but it looks nice this way # references to parent are not allowed diff --git a/tests/filewithspace/0001-quote.diff b/tests/filewithspace/0001-quote.diff new file mode 100644 index 0000000..c7d51e0 --- /dev/null +++ b/tests/filewithspace/0001-quote.diff @@ -0,0 +1,6 @@ +diff '--color=auto' -ruN "b/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs" "a/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs" +--- "b/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs" 2025-10-08 15:56:02.302486070 +0200 ++++ "a/Wrapper/FreeImage.NET/cs/Samples/Sample 01 - Loading and saving/Program.cs" 2025-10-08 15:21:46.283174211 +0200 +@@ -1 +1 @@ +-feriunt summos, fulmina montes. ++lux oculorum laetificat animam. diff --git a/tests/run_tests.py b/tests/run_tests.py index 38f5e3c..b942a09 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -589,6 +589,40 @@ def test_add_move_and_update_file(self): content = f.read() self.assertTrue(b'dum tempus habemus, operemur bonum' in content) +class TestPatchFileWithSpaces(unittest.TestCase): + + def setUp(self): + self.save_cwd = os.getcwd() + self.tmpdir = mkdtemp(prefix=self.__class__.__name__) + shutil.copytree(join(TESTS, 'filewithspace'), join(self.tmpdir, 'filewithspace')) + patch_folder = join(self.tmpdir, "a", "Wrapper", "FreeImage.NET", "cs", "Samples", "Sample 01 - Loading and saving") + os.makedirs(patch_folder, exist_ok=True) + self.program_cs = join(patch_folder, "Program.cs") + with open(self.program_cs, 'w') as fd: + fd.write("feriunt summos, fulmina montes.") + + def tearDown(self): + os.chdir(self.save_cwd) + remove_tree_force(self.tmpdir) + + def test_patch_with_white_space(self): + """When a patch file is generated using `diff -ruN b/ a/` command, and + contains white spaces in the file path, the patch should be applied correctly. + + Reported by https://github.com/conan-io/conan/issues/16727 + """ + + os.chdir(self.tmpdir) + print("TMPDIR:", self.tmpdir) + pto = patch_ng.fromfile(join(self.tmpdir, 'filewithspace', '0001-quote.diff')) + self.assertEqual(len(pto), 1) + self.assertEqual(pto.items[0].type, patch_ng.PLAIN) + self.assertTrue(pto.apply()) + with open(self.program_cs, 'rb') as f: + content = f.read() + self.assertTrue(b'lux oculorum laetificat animam.' in content) + + class TestHelpers(unittest.TestCase): # unittest setting longMessage = True