From c3ab102c40a3965ed346e9abec9884bb268d9227 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Wed, 6 Dec 2023 11:13:06 +0000 Subject: [PATCH] Update CI files [noissue] --- .github/template_gitref | 2 +- .github/workflows/build.yml | 14 +- .github/workflows/changelog.yml | 30 +- .github/workflows/ci.yml | 85 +++-- .github/workflows/create-branch.yml | 15 +- .github/workflows/lint.yml | 12 +- .github/workflows/nightly.yml | 37 +- .github/workflows/pr_checks.yml | 2 +- .github/workflows/release.yml | 318 +++++++++++++----- .github/workflows/scripts/before_install.sh | 3 - .github/workflows/scripts/check_commit.sh | 13 +- .../scripts/install_python_client.sh | 24 +- .../workflows/scripts/publish_client_gem.sh | 25 +- .../workflows/scripts/publish_client_pypi.sh | 8 +- .github/workflows/scripts/publish_docs.sh | 17 - .../workflows/scripts/publish_plugin_pypi.sh | 28 +- .github/workflows/scripts/release.py | 2 +- .github/workflows/scripts/script.sh | 3 +- .github/workflows/test.yml | 121 ++++--- .github/workflows/update-labels.yml | 10 +- .github/workflows/update_ci.yml | 46 +-- CHANGES/.TEMPLATE.rst | 14 +- 22 files changed, 489 insertions(+), 340 deletions(-) diff --git a/.github/template_gitref b/.github/template_gitref index 99cbe100..5234c9a9 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-278-g22c5b00 +2021.08.26-293-gde76e9f diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ccd3db5..5f4affb8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,21 +19,23 @@ jobs: runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install packaging wheel + pip install packaging twine wheel echo ::endgroup:: - name: "Build package" - run: "python3 setup.py sdist bdist_wheel --python-tag py3" - - name: 'Upload Package whl' + run: | + python3 setup.py sdist bdist_wheel --python-tag py3 + twine check dist/* + - name: "Upload Package whl" uses: "actions/upload-artifact@v3" with: name: "plugin_package" diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 621ff732..0c79f7b4 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -6,53 +6,53 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Python changelog update +name: "Python changelog update" on: push: branches: - - main + - "main" paths: - - CHANGES.rst - - CHANGES.md + - "CHANGES.rst" + - "CHANGES.md" workflow_dispatch: jobs: update-changelog: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS pip install -r doc_requirements.txt echo ::endgroup:: - - name: Fake api schema + - name: "Fake api schema" run: | mkdir -p docs/_build/html echo "{}" > docs/_build/html/api.json mkdir -p docs/_static echo "{}" > docs/_static/api.json - - name: + - name: "Build Docs" run: | - pip install "Jinja2<3.1" make diagrams html - working-directory: ./docs + working-directory: "./docs" env: PULP_CONTENT_ORIGIN: "http://localhost/" - - name: Publish changlog to pulpproject.org - run: .github/workflows/scripts/publish_docs.sh changelog ${GITHUB_REF##*/} + - name: "Publish changlog to pulpproject.org" + run: | + .github/workflows/scripts/publish_docs.sh changelog ${GITHUB_REF##*/} env: - PULP_DOCS_KEY: ${{ secrets.PULP_DOCS_KEY }} + PULP_DOCS_KEY: "${{ secrets.PULP_DOCS_KEY }}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af223049..51a41bdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Python CI +name: "Python CI" on: {pull_request: {branches: ['*']}} concurrency: @@ -18,59 +18,76 @@ defaults: working-directory: "pulp_python" jobs: - - ready-to-ship: - runs-on: ubuntu-latest + check-commits: + runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 0 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install requirements - run: pip3 install github - - name: Check commit message + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install requests pygithub + echo ::endgroup:: + - name: "Check commit message" if: github.event_name == 'pull_request' env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - run: sh .github/workflows/scripts/check_commit.sh - - name: Verify requirements files - run: python .ci/scripts/check_requirements.py + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + run: | + .github/workflows/scripts/check_commit.sh + - name: "Verify requirements files" + run: | + python .ci/scripts/check_requirements.py lint: uses: "./.github/workflows/lint.yml" build: - needs: lint + needs: "lint" uses: "./.github/workflows/build.yml" test: - needs: build + needs: "build" uses: "./.github/workflows/test.yml" deprecations: - defaults: - run: - working-directory: "." - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" if: github.base_ref == 'main' - needs: test + needs: "test" steps: - - name: Fail on deprecations + - name: "Create working directory" + run: | + mkdir -p "pulp_python" + working-directory: "." + - name: "Download Deprecations" + uses: actions/download-artifact@v3 + with: + name: "deprecations" + path: "pulp_python" + - name: "Print deprecations" run: | - test -z "${{ needs.test.outputs.deprecations-pulp }}" - test -z "${{ needs.test.outputs.deprecations-azure }}" - test -z "${{ needs.test.outputs.deprecations-s3 }}" - test -z "${{ needs.test.outputs.deprecations-lowerbounds }}" - - name: Print deprecations - if: failure() + cat deprecations-*.txt | sort -u + ! cat deprecations-*.txt | grep '[^[:space:]]' + + ready-to-ship: + # This is a dummy dependent task to have a single entry for the branch protection rules. + runs-on: "ubuntu-latest" + needs: + - "check-commits" + - "lint" + - "test" + if: "always()" + steps: + - name: "Collect needed jobs results" + working-directory: "." run: | - echo "${{ needs.test.outputs.deprecations-pulp }}" | base64 -d - echo "${{ needs.test.outputs.deprecations-azure }}" | base64 -d - echo "${{ needs.test.outputs.deprecations-s3 }}" | base64 -d - echo "${{ needs.test.outputs.deprecations-lowerbounds }}" | base64 -d + 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' + echo "CI says: Looks good!" diff --git a/.github/workflows/create-branch.yml b/.github/workflows/create-branch.yml index c9edd270..8862a3af 100644 --- a/.github/workflows/create-branch.yml +++ b/.github/workflows/create-branch.yml @@ -21,26 +21,27 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 0 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS pip install bump2version jinja2 pyyaml echo ::endgroup:: - - name: Setting secrets - working-directory: pulp_python - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + - name: "Setting secrets" + working-directory: "pulp_python" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - name: Determine new branch name working-directory: pulp_python diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bffc593a..5a8c0247 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,18 +19,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - # lint_requirements contains tools needed for flake8, etc. - - name: Install requirements - run: pip3 install -r lint_requirements.txt + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install -r lint_requirements.txt + echo ::endgroup:: - name: Lint workflow files run: | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6268d316..d6637317 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,22 +33,22 @@ jobs: changelog: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 0 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.11" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS pip install gitpython toml echo ::endgroup:: - - name: Configure Git with pulpbot name and email + - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' @@ -71,7 +71,7 @@ jobs: needs: test steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 path: "pulp_python" @@ -81,17 +81,17 @@ jobs: name: "plugin_package" path: "pulp_python/dist/" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install requests + pip install requests 'packaging~=21.3' mkdocs pymdown-extensions 'Jinja2<3.1' echo ::endgroup:: - - name: Set environment variables + - name: "Set environment variables" run: | echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV @@ -107,24 +107,13 @@ jobs: name: "python-client-docs.tar" path: "pulp_python" - - name: Setting secrets - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - name: Publish docs to pulpproject.org run: | tar -xvf docs.tar -C ./docs .github/workflows/scripts/publish_docs.sh nightly ${GITHUB_REF##*/} - - - name: Logs - if: always() - run: | - echo "Need to debug? Please check: https://github.com/marketplace/actions/debugging-with-tmate" - http --timeout 30 --check-status --pretty format --print hb "https://pulp${PULP_API_ROOT}api/v3/status/" || true - docker images || true - docker ps -a || true - docker logs pulp || true - docker exec pulp ls -latr /etc/yum.repos.d/ || true - docker exec pulp cat /etc/yum.repos.d/* || true - docker exec pulp bash -c "pip3 list && pip3 install pipdeptree && pipdeptree" diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index 05e1c62c..f2a44ab6 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -26,7 +26,7 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 0 - name: Commit Count Check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f05ef5a2..7b0bcbe0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,65 +25,75 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 0 path: "pulp_python" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install packaging~=21.3 bump2version gitpython towncrier==19.9.0 wheel requests + pip install 'packaging~=21.3' bump2version gitpython towncrier wheel requests echo ::endgroup:: - - name: Configure Git with pulpbot name and email + - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - name: Setting secrets - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + + - name: "Create the release commit, tag it, create a post-release commit, and build plugin package" + run: | + python .github/workflows/scripts/release.py ${{ github.event.inputs.release }} - - name: Create the release commit, tag it, create a post-release commit, and build plugin package - run: python .github/workflows/scripts/release.py ${{ github.event.inputs.release }} + - name: "Upload Package whl" + uses: "actions/upload-artifact@v3" + with: + name: "plugin_package" + path: "pulp_python/dist/" + if-no-files-found: "error" - name: "Tar files" run: | tar -cvf pulp_python.tar . - name: "Upload Artifact" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "pulp_python.tar" path: "pulp_python/pulp_python.tar" build-bindings-docs: - needs: build-artifacts - runs-on: ubuntu-latest + needs: + - "build-artifacts" + runs-on: "ubuntu-latest" # Install scripts expect TEST to be set, 'docs' is most appropriate even though we don't run tests env: - TEST: docs + TEST: "docs" steps: - - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: name: "pulp_python.tar" path: "pulp_python/" - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 repository: "pulp/pulp-openapi-generator" path: "pulp-openapi-generator" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - uses: ruby/setup-ruby@v1 @@ -94,56 +104,58 @@ jobs: run: | tar -xf pulp_python.tar - - name: Install httpie + - name: "Install python dependencies" run: | - echo ::group::HTTPIE - pip install httpie - echo ::endgroup:: + echo ::group::PYDEPS + pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_python/.ci/assets/httpie/" >> $GITHUB_ENV + echo ::endgroup:: # Building the bindings and docs requires accessing the OpenAPI specs endpoint, so we need to # setup the Pulp instance. - - name: Before Install - run: .github/workflows/scripts/before_install.sh - shell: bash + - name: "Before Install" + run: | + .github/workflows/scripts/before_install.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" - - name: Install + - name: "Install" run: | - export PLUGIN_VERSION=${{ github.event.inputs.release }} .github/workflows/scripts/install.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - shell: bash - - - name: Install Python client - run: .github/workflows/scripts/install_python_client.sh - shell: bash - - name: Install Ruby client - run: .github/workflows/scripts/install_ruby_client.sh - shell: bash + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + + - name: "Install Python client" + run: | + .github/workflows/scripts/install_python_client.sh + shell: "bash" + - name: "Install Ruby client" + run: | + .github/workflows/scripts/install_ruby_client.sh + shell: "bash" - name: "Upload python client packages" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "python-client.tar" path: "pulp_python/python-python-client.tar" if-no-files-found: "error" - name: "Upload python client docs" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "python-client-docs.tar" path: "pulp_python/python-python-client-docs.tar" if-no-files-found: "error" - name: "Upload ruby client packages" - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: name: "ruby-client.tar" path: "pulp_python/python-ruby-client.tar" @@ -161,7 +173,7 @@ jobs: name: "docs.tar" path: "pulp_python/docs/docs.tar" - - name: Logs + - name: "Logs" if: always() run: | echo "Need to debug? Please check: https://github.com/marketplace/actions/debugging-with-tmate" @@ -174,70 +186,93 @@ jobs: docker exec pulp bash -c "pip3 list && pip3 install pipdeptree && pipdeptree" - publish: - runs-on: ubuntu-latest - needs: build-bindings-docs + publish-tag: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" env: - TEST: publish - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" steps: - - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: name: "pulp_python.tar" path: "pulp_python/" - - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.6" + - name: "Untar repository" + run: | + tar -xf pulp_python.tar - - name: Configure Git with pulpbot name and email + - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - name: Untar repository + - name: "Setting secrets" run: | - tar -xf pulp_python.tar - - - name: Setting secrets - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - - name: Install python dependencies + - name: "Push branch and tag to GitHub" run: | - echo ::group::PYDEPS - pip install gitpython requests packaging~=21.3 - echo ::endgroup:: + bash .github/workflows/scripts/push_branch_and_tag_to_github.sh ${{ github.event.inputs.release }} + publish-package: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" - - name: Push branch and tag to GitHub - run: bash .github/workflows/scripts/push_branch_and_tag_to_github.sh ${{ github.event.inputs.release }} - - name: "Download built docs" - uses: actions/download-artifact@v3 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" with: - name: "docs.tar" - path: "pulp_python/" + fetch-depth: 1 + path: "pulp_python" - - name: "Download Python client docs" - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: - name: "python-client-docs.tar" - path: "pulp_python/" + name: "plugin_package" + path: "pulp_python/dist/" - - name: Publish docs to pulpproject.org + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + + - name: "Install python dependencies" run: | - tar -xvf docs.tar - .github/workflows/scripts/publish_docs.sh tag ${{ github.event.inputs.release }} - - name: Deploy plugin to pypi - run: bash .github/workflows/scripts/publish_plugin_pypi.sh ${{ github.event.inputs.release }} + echo ::group::PYDEPS + pip install twine + echo ::endgroup:: + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + + - name: "Deploy plugin to pypi" + run: | + .github/workflows/scripts/publish_plugin_pypi.sh ${{ github.event.inputs.release }} + publish-python-bindings: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_python" + - name: "Download Python client" - uses: actions/download-artifact@v3 + uses: "actions/download-artifact@v3" with: name: "python-client.tar" path: "pulp_python/" @@ -246,11 +281,42 @@ jobs: run: | tar -xvf python-python-client.tar + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install twine + echo ::endgroup:: + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + - name: "Publish client to pypi" run: | - bash .github/workflows/scripts/publish_client_pypi.sh + bash .github/workflows/scripts/publish_client_pypi.sh ${{ github.event.inputs.release }} + publish-ruby-bindings: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_python" + - name: "Download Ruby client" - uses: actions/download-artifact@v3 + uses: "actions/download-artifact@v3" with: name: "ruby-client.tar" path: "pulp_python/" @@ -259,14 +325,82 @@ jobs: run: | tar -xvf python-ruby-client.tar + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.6" + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" + - name: "Publish client to rubygems" run: | - bash .github/workflows/scripts/publish_client_gem.sh + bash .github/workflows/scripts/publish_client_gem.sh ${{ github.event.inputs.release }} + publish-docs: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + steps: + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + path: "pulp_python" + + - uses: "actions/setup-python@v4" + with: + python-version: "3.8" + + - name: "Install python dependencies" + run: | + echo ::group::PYDEPS + pip install 'packaging~=21.3' requests + echo ::endgroup:: + + - name: "Setting secrets" + run: | + python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: "${{ toJson(secrets) }}" - - name: Create release on GitHub - uses: actions/github-script@v7 + - name: "Download built docs" + uses: "actions/download-artifact@v3" + with: + name: "docs.tar" + path: "pulp_python/" + + - name: "Download Python client docs" + uses: "actions/download-artifact@v3" + with: + name: "python-client-docs.tar" + path: "pulp_python/" + + - name: "Publish docs to pulpproject.org" + run: | + tar -xvf docs.tar + .github/workflows/scripts/publish_docs.sh tag ${{ github.event.inputs.release }} + + create-gh-release: + runs-on: "ubuntu-latest" + needs: + - "build-bindings-docs" + - "publish-tag" + - "publish-package" + - "publish-python-bindings" + - "publish-ruby-bindings" + - "publish-docs" + + steps: + - name: "Create release on GitHub" + uses: "actions/github-script@v7" env: - TAG_NAME: ${{ inputs.release }} + TAG_NAME: "${{ inputs.release }}" with: script: | const { TAG_NAME } = process.env; diff --git a/.github/workflows/scripts/before_install.sh b/.github/workflows/scripts/before_install.sh index c8e5f11e..f6f314c7 100755 --- a/.github/workflows/scripts/before_install.sh +++ b/.github/workflows/scripts/before_install.sh @@ -55,9 +55,6 @@ then echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml fi -# Intall requirements for ansible playbooks -pip install docker netaddr boto3 ansible - for i in {1..3} do ansible-galaxy collection install "amazon.aws:1.5.0" && s=0 && break || s=$? && sleep 3 diff --git a/.github/workflows/scripts/check_commit.sh b/.github/workflows/scripts/check_commit.sh index 7780e8be..e6b6d5e3 100755 --- a/.github/workflows/scripts/check_commit.sh +++ b/.github/workflows/scripts/check_commit.sh @@ -8,20 +8,13 @@ # For more info visit https://github.com/pulp/plugin_template # make sure this script runs at the repo root -cd "$(dirname "$(realpath -e "$0")")"/../../.. +cd "$(dirname "$(realpath -e "$0")")/../../.." set -euv -echo ::group::REQUESTS -pip3 install requests - -pip3 install pygithub - -echo ::endgroup:: - -for sha in $(curl -H "Authorization: token $GITHUB_TOKEN" $GITHUB_CONTEXT | jq '.[].sha' | sed 's/"//g') +for SHA in $(curl -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_CONTEXT" | jq -r '.[].sha') do - python3 .ci/scripts/validate_commit_message.py $sha + python3 .ci/scripts/validate_commit_message.py "$SHA" VALUE=$? if [ "$VALUE" -gt 0 ]; then exit $VALUE diff --git a/.github/workflows/scripts/install_python_client.sh b/.github/workflows/scripts/install_python_client.sh index 4e96fd8f..12170e8a 100755 --- a/.github/workflows/scripts/install_python_client.sh +++ b/.github/workflows/scripts/install_python_client.sh @@ -16,8 +16,6 @@ source .github/workflows/scripts/utils.sh export PULP_URL="${PULP_URL:-https://pulp}" -pip install twine wheel - REPORTED_STATUS="$(pulp status)" REPORTED_VERSION="$(echo "$REPORTED_STATUS" | jq --arg plugin "python" -r '.versions[] | select(.component == $plugin) | .version')" VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" @@ -28,8 +26,8 @@ rm -rf pulp_python-client pushd pulp_python-client python setup.py sdist bdist_wheel --python-tag py3 -twine check "dist/pulp_python_client-$VERSION-py3-none-any.whl" || exit 1 -twine check "dist/pulp_python-client-$VERSION.tar.gz" || exit 1 +twine check "dist/pulp_python_client-$VERSION-py3-none-any.whl" +twine check "dist/pulp_python-client-$VERSION.tar.gz" cmd_prefix pip3 install "/root/pulp-openapi-generator/pulp_python-client/dist/pulp_python_client-${VERSION}-py3-none-any.whl" tar cvf ../../pulp_python/python-python-client.tar ./dist @@ -39,6 +37,22 @@ find ./docs/* -exec sed -i 's/README//g' {} \; cp README.md docs/index.md sed -i 's/docs\///g' docs/index.md find ./docs/* -exec sed -i 's/\.md//g' {} \; -tar cvf ../../pulp_python/python-python-client-docs.tar ./docs + +cat >> mkdocs.yml << DOCSYAML +--- +site_name: PulpPython Client +site_description: Python bindings +site_author: Pulp Team +site_url: https://docs.pulpproject.org/pulp_python_client/ +repo_name: pulp/pulp_python +repo_url: https://github.com/pulp/pulp_python +theme: readthedocs +DOCSYAML + +# Building the bindings docs +mkdocs build + +# Pack the built site. +tar cvf ../../pulp_python/python-python-client-docs.tar ./site popd popd diff --git a/.github/workflows/scripts/publish_client_gem.sh b/.github/workflows/scripts/publish_client_gem.sh index 2cd1d052..bd367010 100755 --- a/.github/workflows/scripts/publish_client_gem.sh +++ b/.github/workflows/scripts/publish_client_gem.sh @@ -12,27 +12,24 @@ set -euv # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. - -mkdir ~/.gem || true -touch ~/.gem/credentials -echo "--- -:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials -sudo chmod 600 ~/.gem/credentials - -export VERSION=$(ls pulp_python_client* | sed -rn 's/pulp_python_client-(.*)\.gem/\1/p') +VERSION="$1" if [[ -z "$VERSION" ]]; then - echo "No client package found." - exit + echo "No version specified." + exit 1 fi -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://rubygems.org/gems/pulp_python_client/versions/$VERSION) +RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://rubygems.org/gems/pulp_python_client/versions/$VERSION")" -if [ "$response" == "200" ]; +if [ "$RESPONSE" == "200" ]; then echo "pulp_python client $VERSION has already been released. Skipping." exit fi -GEM_FILE="$(ls pulp_python_client-*)" -gem push ${GEM_FILE} +mkdir -p ~/.gem +touch ~/.gem/credentials +echo "--- +:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials +sudo chmod 600 ~/.gem/credentials +gem push "pulp_python_client-${VERSION}.gem" diff --git a/.github/workflows/scripts/publish_client_pypi.sh b/.github/workflows/scripts/publish_client_pypi.sh index 61d94795..4341d7a5 100755 --- a/.github/workflows/scripts/publish_client_pypi.sh +++ b/.github/workflows/scripts/publish_client_pypi.sh @@ -12,13 +12,11 @@ set -euv # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")/../../.." -pip install twine - -VERSION="$(ls dist | sed -rn 's/pulp_python-client-(.*)\.tar.gz/\1/p')" +VERSION="$1" if [[ -z "$VERSION" ]]; then - echo "No client package found." - exit + echo "No version specified." + exit 1 fi RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://pypi.org/project/pulp-python-client/$VERSION/")" diff --git a/.github/workflows/scripts/publish_docs.sh b/.github/workflows/scripts/publish_docs.sh index 8795aa55..db944810 100755 --- a/.github/workflows/scripts/publish_docs.sh +++ b/.github/workflows/scripts/publish_docs.sh @@ -20,8 +20,6 @@ echo "$PULP_DOCS_KEY" > ~/.ssh/pulp-infra echo "docs.pulpproject.org,8.43.85.236 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGXG+8vjSQvnAkq33i0XWgpSrbco3rRqNZr0SfVeiqFI7RN/VznwXMioDDhc+hQtgVhd6TYBOrV07IMcKj+FAzg=" >> ~/.ssh/known_hosts chmod 644 ~/.ssh/known_hosts -pip3 install packaging - export PYTHONUNBUFFERED=1 export DJANGO_SETTINGS_MODULE=pulpcore.app.settings export PULP_SETTINGS=$PWD/.ci/ansible/settings/settings.py @@ -38,24 +36,9 @@ if [[ "$GITHUB_WORKFLOW" == "Python changelog update" ]]; then exit fi -pip install mkdocs pymdown-extensions "Jinja2<3.1" - mkdir -p ../python-bindings tar -xvf python-python-client-docs.tar --directory ../python-bindings pushd ../python-bindings -cat >> mkdocs.yml << DOCSYAML ---- -site_name: PulpPython Client -site_description: Python bindings -site_author: Pulp Team -site_url: https://docs.pulpproject.org/pulp_python_client/ -repo_name: pulp/pulp_python -repo_url: https://github.com/pulp/pulp_python -theme: readthedocs -DOCSYAML - -# Building the bindings docs -mkdocs build # publish to docs.pulpproject.org/pulp_python_client rsync -avzh site/ doc_builder_pulp_python@docs.pulpproject.org:/var/www/docs.pulpproject.org/pulp_python_client/ diff --git a/.github/workflows/scripts/publish_plugin_pypi.sh b/.github/workflows/scripts/publish_plugin_pypi.sh index 981f7707..58dfbe20 100755 --- a/.github/workflows/scripts/publish_plugin_pypi.sh +++ b/.github/workflows/scripts/publish_plugin_pypi.sh @@ -7,23 +7,27 @@ # # For more info visit https://github.com/pulp/plugin_template +set -euv + # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. -set -euv +VERSION="$1" -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-python/$1/) -if [ "$response" == "200" ]; -then - echo "pulp_python $1 has already been released. Skipping." - exit +if [[ -z "$VERSION" ]]; then + echo "No version specified." + exit 1 fi -pip install twine +RESPONSE="$(curl --write-out '%{http_code}' --silent --output /dev/null "https://pypi.org/project/pulp-python/$VERSION/")" -twine check dist/pulp_python-$1-py3-none-any.whl || exit 1 -twine check dist/pulp-python-$1.tar.gz || exit 1 -twine upload dist/pulp_python-$1-py3-none-any.whl -u pulp -p $PYPI_PASSWORD -twine upload dist/pulp-python-$1.tar.gz -u pulp -p $PYPI_PASSWORD +if [ "$RESPONSE" == "200" ]; +then + echo "pulp_python $VERSION has already been released. Skipping." + exit +fi -exit $? +twine upload -u pulp -p "$PYPI_PASSWORD" \ +"dist/pulp_python-$VERSION-py3-none-any.whl" \ +"dist/pulp-python-$VERSION.tar.gz" \ +; diff --git a/.github/workflows/scripts/release.py b/.github/workflows/scripts/release.py index d6d7dd88..fe5611e3 100755 --- a/.github/workflows/scripts/release.py +++ b/.github/workflows/scripts/release.py @@ -48,7 +48,7 @@ def create_release_commits(repo, release_version, plugin_path): issues = ",".join(issues_to_close) # First commit: changelog - os.system(f"towncrier --yes --version {release_version}") + os.system(f"towncrier build --yes --version {release_version}") git = repo.git git.add("CHANGES.rst") git.add("CHANGES/*") diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index d7edf246..711cf8d6 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -29,8 +29,7 @@ export PULP_URL="https://pulp" if [[ "$TEST" = "docs" ]]; then if [[ "$GITHUB_WORKFLOW" == "Python CI" ]]; then - pip install towncrier==19.9.0 - towncrier --yes --version 4.0.0.ci + towncrier build --yes --version 4.0.0.ci fi cd docs make PULP_URL="$PULP_URL" diagrams html diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb15ab2c..50cd4bec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,25 +26,20 @@ jobs: - TEST: azure - TEST: s3 - TEST: lowerbounds - outputs: - deprecations-pulp: ${{ steps.deprecations.outputs.deprecations-pulp }} - deprecations-azure: ${{ steps.deprecations.outputs.deprecations-azure }} - deprecations-s3: ${{ steps.deprecations.outputs.deprecations-s3 }} - deprecations-lowerbounds: ${{ steps.deprecations.outputs.deprecations-lowerbounds }} steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 path: "pulp_python" - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" with: fetch-depth: 1 repository: "pulp/pulp-openapi-generator" path: "pulp-openapi-generator" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" @@ -53,69 +48,83 @@ jobs: name: "plugin_package" path: "pulp_python/dist/" - - name: Install httpie + - name: "Install python dependencies" run: | - echo ::group::HTTPIE - pip install httpie - echo ::endgroup:: + echo ::group::PYDEPS + pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_python/.ci/assets/httpie/" >> $GITHUB_ENV + echo ::endgroup:: - - name: Set environment variables + - name: "Set environment variables" run: | echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV - - name: Before Install - run: .github/workflows/scripts/before_install.sh - shell: bash + - name: "Before Install" + run: | + .github/workflows/scripts/before_install.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" - uses: ruby/setup-ruby@v1 if: ${{ env.TEST == 'pulp' }} with: ruby-version: "2.6" - - name: Install - run: .github/workflows/scripts/install.sh - shell: bash + - name: "Install" + run: | + .github/workflows/scripts/install.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - - - name: Before Script - run: .github/workflows/scripts/before_script.sh - shell: bash + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + + - name: "Before Script" + run: | + .github/workflows/scripts/before_script.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - REDIS_DISABLED: ${{ contains('', matrix.env.TEST) }} - - - name: Install Python client - run: .github/workflows/scripts/install_python_client.sh - shell: bash - - name: Install Ruby client - if: ${{ env.TEST == 'pulp' }} - run: .github/workflows/scripts/install_ruby_client.sh - shell: bash + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + REDIS_DISABLED: "${{ contains('', matrix.env.TEST) }}" + + - name: "Install Python client" + run: | + .github/workflows/scripts/install_python_client.sh + shell: "bash" + - name: "Install Ruby client" + if: "${{ env.TEST == 'pulp' }}" + run: | + .github/workflows/scripts/install_ruby_client.sh + shell: "bash" - - name: Script - run: .github/workflows/scripts/script.sh - shell: bash + - name: "Script" + run: | + .github/workflows/scripts/script.sh + shell: "bash" env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - - - name: Extract Deprecations from Logs - id: deprecations - run: echo deprecations-${{ matrix.env.TEST }}=$(docker logs pulp 2>&1 | grep -i pulpcore.deprecation | base64 -w 0) >> $GITHUB_OUTPUT + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + + - name: "Extract Deprecations from Logs" + run: | + docker logs pulp 2>&1 | grep -i pulpcore.deprecation | tee deprecations-${{ matrix.env.TEST }}.txt + + - name: "Upload Deprecations" + uses: actions/upload-artifact@v3 + with: + name: "deprecations" + path: "pulp_python/deprecations-${{ matrix.env.TEST }}.txt" + if-no-files-found: "error" + retention-days: 5 - name: Upload python client packages if: ${{ env.TEST == 'pulp' }} uses: actions/upload-artifact@v3 @@ -148,7 +157,7 @@ jobs: name: "docs.tar" path: "pulp_python/docs/docs.tar" - - name: Logs + - name: "Logs" if: always() run: | echo "Need to debug? Please check: https://github.com/marketplace/actions/debugging-with-tmate" diff --git a/.github/workflows/update-labels.yml b/.github/workflows/update-labels.yml index 2c493c4d..a79cada7 100644 --- a/.github/workflows/update-labels.yml +++ b/.github/workflows/update-labels.yml @@ -17,16 +17,16 @@ on: jobs: update_backport_labels: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Configure Git with pulpbot name and email + - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS pip install requests pyyaml @@ -36,4 +36,4 @@ jobs: run: | python3 .github/workflows/scripts/update_backport_labels.py env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" diff --git a/.github/workflows/update_ci.yml b/.github/workflows/update_ci.yml index e5dd1eec..64e4dd97 100644 --- a/.github/workflows/update_ci.yml +++ b/.github/workflows/update_ci.yml @@ -7,7 +7,7 @@ --- -name: Python CI Update +name: "Python CI Update" on: schedule: # * is a special character in YAML so you have to quote this string @@ -17,54 +17,54 @@ on: jobs: update: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: "actions/checkout@v4" with: - repository: pulp/plugin_template - path: plugin_template fetch-depth: 0 + repository: "pulp/plugin_template" + path: "plugin_template" - - uses: actions/setup-python@v4 + - uses: "actions/setup-python@v4" with: python-version: "3.8" - - name: Install python dependencies + - name: "Install python dependencies" run: | echo ::group::PYDEPS pip install gitpython requests packaging jinja2 pyyaml echo ::endgroup:: - - name: Configure Git with pulpbot name and email + - name: "Configure Git with pulpbot name and email" run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - uses: actions/checkout@v3 + - uses: "actions/checkout@v4" with: - path: pulp_python - ref: 'main' fetch-depth: 0 + path: "pulp_python" + ref: "main" - - name: Run update - working-directory: pulp_python + - name: "Run update" + working-directory: "pulp_python" run: | ../plugin_template/scripts/update_ci.sh - - name: Create Pull Request for CI files - uses: peter-evans/create-pull-request@v4 + - name: "Create Pull Request for CI files" + uses: "peter-evans/create-pull-request@v4" with: - token: ${{ secrets.RELEASE_TOKEN }} - path: pulp_python - committer: pulpbot - author: pulpbot - title: 'Update CI files for branch main' - body: '[noissue]' - branch: 'update-ci/main' - base: 'main' + token: "${{ secrets.RELEASE_TOKEN }}" + path: "pulp_python" + committer: "pulpbot " + author: "pulpbot " + title: "Update CI files for branch main" + body: "" + branch: "update-ci/main" + base: "main" commit-message: | Update CI files diff --git a/CHANGES/.TEMPLATE.rst b/CHANGES/.TEMPLATE.rst index ab3826e7..49c2305d 100644 --- a/CHANGES/.TEMPLATE.rst +++ b/CHANGES/.TEMPLATE.rst @@ -1,5 +1,12 @@ - -{# TOWNCRIER TEMPLATE #} +{% if render_title %} +{% if versiondata.name %} +{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.name + versiondata.version + versiondata.date)|length + 4)}} +{% else %} +{{ versiondata.version }} ({{ versiondata.date }}) +{{ top_underline * ((versiondata.version + versiondata.date)|length + 3)}} +{% endif %} +{% endif %} {% for section, _ in sections.items() %} {% set underline = underlines[0] %}{% if section %}{{section}} {{ underline * section|length }}{% set underline = underlines[1] %} @@ -35,3 +42,6 @@ No significant changes. {% endif %} {% endfor %} ---- + + +