From 3767c9961523777b53ddf40bebbc5d2ee1ff9b1d Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Wed, 10 Jul 2024 19:54:47 +0200 Subject: [PATCH] do not test class_map files + auto sipify_all on branches --- .../{pr-fixer-bot.yml => sipify-bot.yml} | 15 +++++--- python/CMakeLists.txt | 6 +-- scripts/sipify_all.sh | 38 +++++++++++-------- tests/code_layout/sipify/test_sipfiles.sh | 9 +---- 4 files changed, 36 insertions(+), 32 deletions(-) rename .github/workflows/{pr-fixer-bot.yml => sipify-bot.yml} (72%) diff --git a/.github/workflows/pr-fixer-bot.yml b/.github/workflows/sipify-bot.yml similarity index 72% rename from .github/workflows/pr-fixer-bot.yml rename to .github/workflows/sipify-bot.yml index 58372ebc14e9..f1aa84a1dfd4 100644 --- a/.github/workflows/pr-fixer-bot.yml +++ b/.github/workflows/sipify-bot.yml @@ -1,23 +1,28 @@ -name: Run sipify on PR +name: Run sipify on: issue_comment: types: [created] + push: + branches: + - master + - release-* jobs: sipify: - if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify') + if: github.event_name == 'push' || (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify')) runs-on: [ubuntu-latest] steps: - name: Get PR branch uses: alessbell/pull-request-comment-branch@v2.1.0 + if: ${{ github.event_name == 'issue_comment' }} id: comment-branch - uses: actions/checkout@v4 with: - ref: ${{ steps.comment-branch.outputs.head_ref }} - repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }} + ref: ${{ steps.comment-branch.outputs.head_ref || github.ref_name }} + repository: ${{ steps.comment-branch.outputs.head_owner || 'qgis' }}/${{ steps.comment-branch.outputs.head_repo || 'QGIS' }} token: ${{ secrets.GH_TOKEN_BOT }} - name: Install Requirements @@ -39,7 +44,7 @@ jobs: libtry-tiny-perl - name: run sipify - run: ./scripts/sipify_all.sh + run: ./scripts/sipify_all.sh -m - name: commit run: | diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d9e00655f6ad..8deaac29ec47 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -442,9 +442,6 @@ foreach(module ${PY_MODULES}) endforeach(pyfile) PY_COMPILE(py${module} "${QGIS_PYTHON_OUTPUT_DIRECTORY}/${module}") - # install class map file - install(FILES ${BINDING_FILES_ROOT_DIR}/class_map.yaml DESTINATION "${QGIS_PYTHON_DIR}/${module}") - # install source sip files if(SIP_GLOBAL_INSTALL) file(GLOB sip_files ${CMAKE_CURRENT_BINARY_DIR}/${module}/*.sip) @@ -452,3 +449,6 @@ foreach(module ${PY_MODULES}) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${module}/auto_generated DESTINATION ${SIP_DEFAULT_SIP_DIR}/qgis/${module}) endif() endforeach(module) + +# install sipify config +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sipify.yaml DESTINATION "${QGIS_PYTHON_DIR}") diff --git a/scripts/sipify_all.sh b/scripts/sipify_all.sh index 31d1d325d74a..dadc4c9eb45c 100755 --- a/scripts/sipify_all.sh +++ b/scripts/sipify_all.sh @@ -15,15 +15,15 @@ ########################################################################### set -e -# TEMPLATE_DOC="" -# while :; do -# case $1 in -# -t|--template-doc) TEMPLATE_DOC="-template-doc" -# ;; -# *) break -# esac -# shift -# done +CLASS_MAP=0 +while getopts "m" opt; do + case $opt in + m) + CLASS_MAP=1 + ;; + esac +done +shift $(expr $OPTIND - 1) DIR=$(git rev-parse --show-toplevel) @@ -73,7 +73,11 @@ It is not aimed to be manually edited else path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile) mkdir -p python/$path - ./scripts/sipify.pl $IS_QT6 -s ${root_dir}/$sipfile.in -p ${module_dir}/auto_additions/${pyfile} -c ${module_dir}/class_map.yaml $header & + CLASS_MAP_CALL= + if [[ ${CLASS_MAP} -eq 1 ]]; then + CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml" + fi + ./scripts/sipify.pl $IS_QT6 -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} & fi count=$((count+1)) done < <( ${GP}sed -n -r "s@^%Include auto_generated/(.*\.sip)@${module}/auto_generated/\1@p" python/${module}/${module}_auto.sip ) @@ -81,13 +85,15 @@ It is not aimed to be manually edited done wait # wait for sipify processes to finish -for root_dir in python python/PyQt6; do - for module in "${modules[@]}"; do - module_dir=${root_dir}/${module} - echo "sorting ${module_dir}/class_map.yaml" - sort -n -o ${module_dir}/class_map.yaml ${module_dir}/class_map.yaml +if [[ ${CLASS_MAP} -eq 1 ]]; then + for root_dir in python python/PyQt6; do + for module in "${modules[@]}"; do + module_dir=${root_dir}/${module} + echo "sorting ${module_dir}/class_map.yaml" + sort -n -o ${module_dir}/class_map.yaml ${module_dir}/class_map.yaml + done done -done +fi echo " => $count files sipified! 🍺" diff --git a/tests/code_layout/sipify/test_sipfiles.sh b/tests/code_layout/sipify/test_sipfiles.sh index acf209ef7b57..c6ef19bdb35f 100755 --- a/tests/code_layout/sipify/test_sipfiles.sh +++ b/tests/code_layout/sipify/test_sipfiles.sh @@ -30,7 +30,7 @@ for root_dir in python python/PyQt6; do if [ ! -f $header ]; then echo "*** Missing header: $header for sipfile $sipfile" else - outdiff=$(./scripts/sipify.pl $IS_QT6 -p $root_dir/${module}/auto_additions/${pyfile}.temp -c $root_dir/${module}/class_map.yaml.test $header | diff $root_dir/$sipfile.in -) + outdiff=$(./scripts/sipify.pl $IS_QT6 -p $root_dir/${module}/auto_additions/${pyfile}.temp $header | diff $root_dir/$sipfile.in -) if [[ -n "$outdiff" ]]; then echo " *** SIP file not up to date: $root_dir/$sipfile" echo " $outdiff " @@ -48,13 +48,6 @@ for root_dir in python python/PyQt6; do done < <( ${GP}sed -n -r "s@^%Include auto_generated/(.*\.sip)@${module}/auto_generated/\1@p" $root_dir/${module}/${module}_auto.sip ) - sort -n -o ${module_dir}/class_map.dat.test ${module_dir}/class_map.dat.test - outdiff3=$($root_dir/${module}/class_map.yaml $root_dir/${module}/class_map.yaml.test) - if [[ -n "$outdiff3" ]]; then - echo " *** Class map not up to date: $root_dir/${module}/class_map.yaml. Run sipify_all.sh to fix this." - echo " $outdiff3 " - code=1 - fi done done