From de8eca052fc127e01238865a160a565714fbf78b Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 26 Oct 2025 15:34:42 +0000 Subject: [PATCH] Update CI files --- .ci/scripts/skip_tests.py | 1 - .github/workflows/ci.yml | 41 +++++++++++++++---- .github/workflows/docs.yml | 15 +++---- .github/workflows/publish.yml | 5 ++- .../workflows/scripts/build_python_client.sh | 4 +- .../workflows/scripts/publish_client_pypi.sh | 2 +- .github/workflows/scripts/script.sh | 2 +- .github/workflows/test.yml | 2 +- 8 files changed, 48 insertions(+), 24 deletions(-) diff --git a/.ci/scripts/skip_tests.py b/.ci/scripts/skip_tests.py index 2a21a72..a68d000 100755 --- a/.ci/scripts/skip_tests.py +++ b/.ci/scripts/skip_tests.py @@ -25,7 +25,6 @@ DOC_PATTERNS = [ r"^docs/", r"\.md$", - r"\.txt$", r"LICENSE.*", r"CHANGELOG.*", r"CHANGES.*", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48c64ae..e9a961d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: runs-on: ubuntu-latest outputs: run_tests: ${{ steps.check.outputs.run_tests }} + run_docs: ${{ steps.check.outputs.run_docs }} steps: - uses: "actions/checkout@v4" with: @@ -67,6 +68,13 @@ jobs: shell: bash id: check run: | + # We only test docs on the default branch (usually main) + if [[ "${{ github.base_ref }}" == *"main" ]]; then + echo "run_docs=1" >> $GITHUB_OUTPUT + else + echo "run_docs=0" >> $GITHUB_OUTPUT + fi + set +e BASE_REF=${{ github.event.pull_request.base.sha }} echo "Checking against:" @@ -129,13 +137,30 @@ jobs: - name: "Collect needed jobs results" working-directory: "." run: | - if [ ${{ needs.check-changes.outputs.run_tests }} == "1" ]; then - # Full test run - check all jobs - echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result' - echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0' - else - # Docs-only run - check only required jobs (exclude lint and test) - echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.key != "lint" and .key != "test")|select(.value.result!="success")|.key + ": " + .value.result' - echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.key != "lint" and .key != "test"))|map(select(.value.result!="success"))|length == 0' + RUN_TESTS=${{ needs.check-changes.outputs.run_tests }} + RUN_DOCS=${{ needs.check-changes.outputs.run_docs }} + + check_jobs() { + local filter="$1" + local needs_json='${{toJson(needs)}}' + # output failed jobs after filter + echo "$needs_json" | jq -r "to_entries[]|select($filter)|select(.value.result!=\"success\")|.key + \": \" + .value.result" + # fails if not all selected jobs passed + echo "$needs_json" | jq -e "to_entries|map(select($filter))|map(select(.value.result!=\"success\"))|length == 0" + } + + if [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "1" ]; then + FILTERS="true" # check all jobs + elif [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "0" ]; then + echo "Skipping docs: running on non-default branch" + FILTERS='.key != "docs"' + elif [ "$RUN_TESTS" == "0" ] && [ "$RUN_DOCS" == "1" ]; then + echo "Skipping tests: only doc changes" + FILTERS='.key != "lint" and .key != "test"' + else # RUN_TESTS=0, RUN_DOCS=0 + echo "What is this PR doing??" + FILTERS='.key != "lint" and .key != "test" and .key != "docs"' fi + + check_jobs "$FILTERS" echo "CI says: Looks good!" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7a9e4f9..ea6f06e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,10 +9,14 @@ name: "Docs CI" on: workflow_call: + inputs: + run_docs: + description: "Whether to run docs jobs" + required: true + type: string jobs: changelog: - if: "endsWith(github.base_ref, 'main')" runs-on: "ubuntu-latest" defaults: run: @@ -34,14 +38,7 @@ jobs: run: | towncrier build --yes --version 4.0.0.ci docs: - if: "endsWith(github.base_ref, 'main')" + if: ${{ inputs.run_docs == '1' }} uses: 'pulp/pulp-docs/.github/workflows/docs-ci.yml@main' with: pulpdocs_ref: 'main' - - no-test: - if: "!endsWith(github.base_ref, 'main')" - runs-on: "ubuntu-latest" - steps: - - run: | - echo "Skip docs testing on non-default branches." diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5a2a145..b5e8b94 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -167,8 +167,11 @@ jobs: pip install towncrier - name: "Get release notes" - id: get_release_notes + id: "get_release_notes" + shell: "bash" run: | + # The last commit before the release commit contains the release CHANGES fragments + git checkout "${TAG_NAME}~" NOTES=$(towncrier build --draft --version $TAG_NAME) echo "body<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT diff --git a/.github/workflows/scripts/build_python_client.sh b/.github/workflows/scripts/build_python_client.sh index ae326b5..b084f71 100755 --- a/.github/workflows/scripts/build_python_client.sh +++ b/.github/workflows/scripts/build_python_client.sh @@ -21,10 +21,10 @@ rm -rf "pulp_hugging_face-client" ./gen-client.sh "../pulp_hugging_face/hugging_face-api.json" "hugging_face" python "pulp_hugging_face" pushd pulp_hugging_face-client -python setup.py sdist bdist_wheel --python-tag py3 +python -m build twine check "dist/pulp_hugging_face_client-"*"-py3-none-any.whl" -twine check "dist/pulp_hugging_face-client-"*".tar.gz" +twine check "dist/pulp_hugging_face_client-"*".tar.gz" tar cvf "../../pulp_hugging_face/hugging_face-python-client.tar" ./dist diff --git a/.github/workflows/scripts/publish_client_pypi.sh b/.github/workflows/scripts/publish_client_pypi.sh index 87bfd22..0a422ad 100755 --- a/.github/workflows/scripts/publish_client_pypi.sh +++ b/.github/workflows/scripts/publish_client_pypi.sh @@ -22,5 +22,5 @@ fi twine upload -u __token__ -p "${PYPI_API_TOKEN}" \ "dist/pulp_hugging_face_client-${VERSION}-py3-none-any.whl" \ -"dist/pulp_hugging_face-client-${VERSION}.tar.gz" \ +"dist/pulp_hugging_face_client-${VERSION}.tar.gz" \ ; diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index f458e8d..db7266b 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -72,7 +72,7 @@ pushd ../pulp-openapi-generator rm -rf "./${PACKAGE}-client" ./gen-client.sh "${COMPONENT}-api.json" "${COMPONENT}" python "${PACKAGE}" pushd "${PACKAGE}-client" - python setup.py sdist bdist_wheel --python-tag py3 + python -m build popd else if [ ! -f "${PACKAGE}-client/dist/${PACKAGE}_client-${VERSION}-py3-none-any.whl" ] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96240ad..fdd5749 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version 'click<8.3' + pip install build towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version 'click<8.3' echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_hugging_face/.ci/assets/httpie/" >> $GITHUB_ENV echo ::endgroup::