diff --git a/.github/template_gitref b/.github/template_gitref index b11f949e..e6493610 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-265-gbdd41dd +2021.08.26-269-g0b48c81 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41183252..407da5cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,18 +6,23 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Build +name: "Build" on: workflow_call: +defaults: + run: + working-directory: "pulp_gem" + jobs: build: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v4 with: fetch-depth: 1 + path: "pulp_gem" - uses: actions/setup-python@v4 with: python-version: "3.8" @@ -26,12 +31,12 @@ jobs: echo ::group::PYDEPS pip install packaging wheel echo ::endgroup:: - - name: Build package - run: python3 setup.py sdist bdist_wheel --python-tag py3 + - name: "Build package" + run: "python3 setup.py sdist bdist_wheel --python-tag py3" - name: 'Upload Package whl' - uses: actions/upload-artifact@v3 + uses: "actions/upload-artifact@v3" with: - name: plugin_package - path: dist/ - if-no-files-found: error + name: "plugin_package" + path: "pulp_gem/dist/" + if-no-files-found: "error" retention-days: 5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bbebdd0..8f905efa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,6 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} run: sh .github/workflows/scripts/check_commit.sh diff --git a/.github/workflows/create-branch.yml b/.github/workflows/create-branch.yml index 2b747c67..3d10f133 100644 --- a/.github/workflows/create-branch.yml +++ b/.github/workflows/create-branch.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - path: pulp_gem + path: "pulp_gem" - uses: actions/setup-python@v4 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 738b8f71..be839a89 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,10 +6,14 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Lint +name: "Lint" on: workflow_call: +defaults: + run: + working-directory: "pulp_gem" + jobs: lint: runs-on: ubuntu-latest @@ -18,9 +22,12 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 + path: "pulp_gem" + - 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 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f0bdee18..34e31a53 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,7 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Gem Nightly CI +name: "Gem Nightly CI" on: schedule: # * is a special character in YAML so you have to quote this string @@ -14,165 +14,22 @@ on: - cron: '00 3 * * *' workflow_dispatch: +defaults: + run: + working-directory: "pulp_gem" + concurrency: - group: ${{ github.ref_name }}-${{ github.workflow }} + group: "${{ github.ref_name }}-${{ github.workflow }}" cancel-in-progress: true jobs: build: - uses: ./.github/workflows/build.yml + uses: "./.github/workflows/build.yml" test: - runs-on: ubuntu-latest - needs: build - - strategy: - fail-fast: false - matrix: - env: - - TEST: pulp - - TEST: docs - - TEST: azure - - TEST: s3 - - - TEST: generate-bindings - - TEST: lowerbounds - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - uses: actions/download-artifact@v3 - with: - name: plugin_package - path: dist/ - - - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - - name: Install httpie - run: | - echo ::group::HTTPIE - pip install httpie - echo ::endgroup:: - echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV - - - name: Set environment variables - run: | - echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV - - - name: Before Install - run: .github/workflows/scripts/before_install.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - - - uses: ruby/setup-ruby@v1 - if: ${{ env.TEST == 'bindings' || env.TEST == 'generate-bindings' }} - with: - ruby-version: "2.6" - - - name: Install - run: .github/workflows/scripts/install.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - 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_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - REDIS_DISABLED: ${{ contains('', matrix.env.TEST) }} - - - name: Setting secrets - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" - env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} - - - name: Install Python client - run: .github/workflows/scripts/install_python_client.sh - shell: bash - - - name: Install Ruby client - if: ${{ env.TEST == 'bindings' || env.TEST == 'generate-bindings' }} - run: .github/workflows/scripts/install_ruby_client.sh - shell: bash - - - name: Script - run: .github/workflows/scripts/script.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - - - name: Upload python client packages - if: ${{ env.TEST == 'bindings' || env.TEST == 'generate-bindings' }} - uses: actions/upload-artifact@v3 - with: - name: python-client.tar - path: python-client.tar - - - name: Upload python client docs - if: ${{ env.TEST == 'bindings' || env.TEST == 'generate-bindings' }} - uses: actions/upload-artifact@v3 - with: - name: python-client-docs.tar - path: python-client-docs.tar - - - name: Upload ruby client packages - if: ${{ env.TEST == 'bindings' || env.TEST == 'generate-bindings' }} - uses: actions/upload-artifact@v3 - with: - name: ruby-client.tar - path: ruby-client.tar - - name: Upload built docs - if: ${{ env.TEST == 'docs' }} - uses: actions/upload-artifact@v3 - with: - name: docs.tar - path: docs/docs.tar - - - 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" + runs-on: "ubuntu-latest" + needs: "build" + uses: "./.github/workflows/test.yml" changelog: runs-on: ubuntu-latest @@ -180,6 +37,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + path: "pulp_gem" - uses: actions/setup-python@v4 with: @@ -203,116 +61,58 @@ jobs: uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.RELEASE_TOKEN }} - title: 'Update Changelog' - body: '' - branch: 'changelog/update' + title: "Update Changelog" + body: "" + branch: "changelog/update" delete-branch: true + path: "pulp_gem" publish: runs-on: ubuntu-latest needs: test - env: - TEST: publish - steps: - uses: actions/checkout@v4 with: fetch-depth: 1 + path: "pulp_gem" + + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + repository: "pulp/pulp-openapi-generator" + path: "pulp-openapi-generator" - uses: actions/download-artifact@v3 with: - name: plugin_package - path: dist/ + name: "plugin_package" + path: "pulp_gem/dist/" - uses: actions/setup-python@v4 with: python-version: "3.8" - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.6" - - - name: Install httpie - run: | - echo ::group::HTTPIE - pip install httpie - echo ::endgroup:: - echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV - - name: Set environment variables run: | echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV - - name: Install python dependencies - run: | - echo ::group::PYDEPS - pip install wheel - echo ::endgroup:: - - - name: Before Install - run: .github/workflows/scripts/before_install.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - - - name: Install - run: .github/workflows/scripts/install.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - 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: Before Script - run: .github/workflows/scripts/before_script.sh - shell: bash - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} - REDIS_DISABLED: ${{ contains('', matrix.env.TEST) }} - - - name: Setting secrets - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" - env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} - - name: Download built docs uses: actions/download-artifact@v3 with: - name: docs.tar + name: "docs.tar" + path: "pulp_gem/docs.tar" - name: Download Python client docs uses: actions/download-artifact@v3 with: - name: python-client-docs.tar + name: "python-client-docs.tar" + path: "pulp_gem/python-client-docs.tar" + + - name: Setting secrets + run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" + env: + SECRETS_CONTEXT: ${{ toJson(secrets) }} - name: Publish docs to pulpproject.org run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0570a373..7607fddd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,12 +13,13 @@ on: release: description: "Release tag (e.g. 3.2.1)" -env: - RELEASE_WORKFLOW: true +defaults: + run: + working-directory: "pulp_gem" jobs: build-artifacts: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: fail-fast: false @@ -27,6 +28,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + path: "pulp_gem" - uses: actions/setup-python@v4 with: @@ -51,14 +53,15 @@ jobs: - 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: 'Tar files' - run: tar -cvf pulp_gem.tar . + - name: "Tar files" + run: | + tar -cvf pulp_gem.tar . - - name: 'Upload Artifact' + - name: "Upload Artifact" uses: actions/upload-artifact@v3 with: - name: pulp_gem.tar - path: pulp_gem.tar + name: "pulp_gem.tar" + path: "pulp_gem/pulp_gem.tar" build-bindings-docs: @@ -71,7 +74,14 @@ jobs: steps: - uses: actions/download-artifact@v3 with: - name: pulp_gem.tar + name: "pulp_gem.tar" + path: "pulp_gem/" + + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + repository: "pulp/pulp-openapi-generator" + path: "pulp-openapi-generator" - uses: actions/setup-python@v4 with: @@ -80,7 +90,7 @@ jobs: with: ruby-version: "2.6" - - name: Untar repository + - name: "Untar repository" run: | tar -xf pulp_gem.tar @@ -97,7 +107,7 @@ jobs: echo ::group::HTTPIE pip install httpie echo ::endgroup:: - echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV + echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_gem/.ci/assets/httpie/" >> $GITHUB_ENV # Building the bindings and docs requires accessing the OpenAPI specs endpoint, so we need to # setup the Pulp instance. @@ -107,10 +117,6 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} @@ -121,10 +127,6 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} shell: bash @@ -136,22 +138,22 @@ jobs: run: .github/workflows/scripts/install_ruby_client.sh shell: bash - - name: Upload python client packages + - name: "Upload python client packages" uses: actions/upload-artifact@v3 with: - name: python-client.tar - path: python-client.tar + name: "python-client.tar" + path: "pulp_gem/python-client.tar" - - name: Upload python client docs + - name: "Upload python client docs" uses: actions/upload-artifact@v3 with: - name: python-client-docs.tar - path: python-client-docs.tar - - name: Upload ruby client packages + name: "python-client-docs.tar" + path: "pulp_gem/python-client-docs.tar" + - name: "Upload ruby client packages" uses: actions/upload-artifact@v3 with: - name: ruby-client.tar - path: ruby-client.tar + name: "ruby-client.tar" + path: "pulp_gem/ruby-client.tar" - name: Build docs run: | export DJANGO_SETTINGS_MODULE=pulpcore.app.settings @@ -159,11 +161,11 @@ jobs: make -C docs/ PULP_URL="https://pulp" diagrams html tar -cvf docs/docs.tar docs/_build - - name: Upload built docs + - name: "Upload built docs" uses: actions/upload-artifact@v3 with: - name: docs.tar - path: docs/docs.tar + name: "docs.tar" + path: "pulp_gem/docs/docs.tar" - name: Logs if: always() @@ -189,7 +191,8 @@ jobs: steps: - uses: actions/download-artifact@v3 with: - name: pulp_gem.tar + name: "pulp_gem.tar" + path: "pulp_gem/" - uses: actions/setup-python@v4 with: @@ -229,15 +232,17 @@ jobs: - 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 + - name: "Download built docs" uses: actions/download-artifact@v3 with: - name: docs.tar + name: "docs.tar" + path: "pulp_gem/" - - name: Download Python client docs + - name: "Download Python client docs" uses: actions/download-artifact@v3 with: - name: python-client-docs.tar + name: "python-client-docs.tar" + path: "pulp_gem/" - name: Publish docs to pulpproject.org run: | @@ -245,20 +250,22 @@ jobs: .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 }} - - name: Download Python client + - name: "Download Python client" uses: actions/download-artifact@v3 with: - name: python-client.tar + name: "python-client.tar" + path: "pulp_gem/" - name: Untar python client packages run: tar -xvf python-client.tar - name: Publish client to pypi run: bash .github/workflows/scripts/publish_client_pypi.sh - - name: Download Ruby client + - name: "Download Ruby client" uses: actions/download-artifact@v3 with: - name: ruby-client.tar + name: "ruby-client.tar" + path: "pulp_gem/" - name: Untar Ruby client packages run: tar -xvf ruby-client.tar diff --git a/.github/workflows/scripts/before_install.sh b/.github/workflows/scripts/before_install.sh index be2bdaa7..d4219838 100755 --- a/.github/workflows/scripts/before_install.sh +++ b/.github/workflows/scripts/before_install.sh @@ -55,11 +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 - -cd .. - -git clone --depth=1 https://github.com/pulp/pulp-openapi-generator.git - # Intall requirements for ansible playbooks pip install docker netaddr boto3 ansible @@ -73,8 +68,6 @@ then exit $s fi -cd pulp_gem - if [[ "$TEST" = "lowerbounds" ]]; then python3 .ci/scripts/calc_deps_lowerbounds.py > lowerbounds_requirements.txt mv lowerbounds_requirements.txt requirements.txt diff --git a/.github/workflows/scripts/install_python_client.sh b/.github/workflows/scripts/install_python_client.sh index a32dd751..b5ba01d8 100755 --- a/.github/workflows/scripts/install_python_client.sh +++ b/.github/workflows/scripts/install_python_client.sh @@ -9,45 +9,32 @@ set -mveuo pipefail -export PULP_URL="${PULP_URL:-https://pulp}" - # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. +source .github/workflows/scripts/utils.sh + +export PULP_URL="${PULP_URL:-https://pulp}" + pip install twine wheel -export REPORTED_VERSION=$(http $PULP_URL/pulp/api/v3/status/ | jq --arg plugin gem --arg legacy_plugin pulp_gem -r '.versions[] | select(.component == $plugin or .component == $legacy_plugin) | .version') -export DESCRIPTION="$(git describe --all --exact-match `git rev-parse HEAD`)" -if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then - export VERSION=${REPORTED_VERSION} -else - export EPOCH="$(date +%s)" - export VERSION=${REPORTED_VERSION}${EPOCH} -fi - -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-gem-client/$VERSION/) - -if [ "$response" == "200" ]; -then - echo "pulp_gem client $VERSION has already been released. Installing from PyPI." - docker exec pulp pip3 install pulp-gem-client==$VERSION - mkdir -p dist - tar cvf python-client.tar ./dist - exit -fi - -cd ../pulp-openapi-generator +REPORTED_STATUS="$(pulp status)" +REPORTED_VERSION="$(echo "$REPORTED_STATUS" | jq --arg plugin "gem" -r '.versions[] | select(.component == $plugin) | .version')" +VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + +pushd ../pulp-openapi-generator rm -rf pulp_gem-client -./generate.sh pulp_gem python $VERSION -cd pulp_gem-client +./generate.sh pulp_gem python "$VERSION" +pushd pulp_gem-client python setup.py sdist bdist_wheel --python-tag py3 -find . -name "*.whl" -exec docker exec pulp pip3 install /root/pulp-openapi-generator/pulp_gem-client/{} \; -tar cvf ../../pulp_gem/python-client.tar ./dist +cmd_prefix pip3 install "/root/pulp-openapi-generator/pulp_gem-client/dist/pulp_gem_client-${VERSION}-py3-none-any.whl" +tar cvf ../../pulp_gem/gem-python-client.tar ./dist find ./docs/* -exec sed -i 's/Back to README/Back to HOME/g' {} \; 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_gem/python-client-docs.tar ./docs -exit $? +tar cvf ../../pulp_gem/gem-python-client-docs.tar ./docs +popd +popd diff --git a/.github/workflows/scripts/install_ruby_client.sh b/.github/workflows/scripts/install_ruby_client.sh index bff048ca..fc0f35e4 100755 --- a/.github/workflows/scripts/install_ruby_client.sh +++ b/.github/workflows/scripts/install_ruby_client.sh @@ -7,37 +7,26 @@ # # For more info visit https://github.com/pulp/plugin_template -set -euv +set -mveuo pipefail # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. +source .github/workflows/scripts/utils.sh + export PULP_URL="${PULP_URL:-https://pulp}" -export REPORTED_VERSION=$(http $PULP_URL/pulp/api/v3/status/ | jq --arg plugin gem --arg legacy_plugin pulp_gem -r '.versions[] | select(.component == $plugin or .component == $legacy_plugin) | .version') -export DESCRIPTION="$(git describe --all --exact-match `git rev-parse HEAD`)" -if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then - export VERSION=${REPORTED_VERSION} -else - export EPOCH="$(date +%s)" - export VERSION=${REPORTED_VERSION}${EPOCH} -fi - -export response=$(curl --write-out %{http_code} --silent --output /dev/null https://rubygems.org/gems/pulp_gem_client/versions/$VERSION) - -if [ "$response" == "200" ]; -then - echo "pulp_gem client $VERSION has already been released. Installing from RubyGems.org." - gem install pulp_gem_client -v $VERSION - touch pulp_gem_client-$VERSION.gem - tar cvf ruby-client.tar ./pulp_gem_client-$VERSION.gem - exit -fi - -cd ../pulp-openapi-generator + +REPORTED_STATUS="$(pulp status)" +REPORTED_VERSION="$(echo "$REPORTED_STATUS" | jq --arg plugin "gem" -r '.versions[] | select(.component == $plugin) | .version')" +VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')" + +pushd ../pulp-openapi-generator rm -rf pulp_gem-client -./generate.sh pulp_gem ruby $VERSION -cd pulp_gem-client +./generate.sh pulp_gem ruby "$VERSION" +pushd pulp_gem-client gem build pulp_gem_client -gem install --both ./pulp_gem_client-$VERSION.gem -tar cvf ../../pulp_gem/ruby-client.tar ./pulp_gem_client-$VERSION.gem +gem install --both "./pulp_gem_client-$VERSION.gem" +tar cvf ../../pulp_gem/gem-ruby-client.tar "./pulp_gem_client-$VERSION.gem" +popd +popd diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index 22f8a80d..7a46face 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -12,7 +12,6 @@ set -mveuo pipefail # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. -REPO_ROOT="$PWD" source .github/workflows/scripts/utils.sh @@ -38,65 +37,47 @@ if [[ "$TEST" = "docs" ]]; then tar -cvf docs.tar ./_build cd .. - if [ -f $POST_DOCS_TEST ]; then - source $POST_DOCS_TEST + if [ -f "$POST_DOCS_TEST" ]; then + source "$POST_DOCS_TEST" fi exit fi REPORTED_STATUS="$(pulp status)" -if [[ "${RELEASE_WORKFLOW:-false}" == "true" ]]; then - # TODO Move this to prerelease checks - REPORTED_VERSION="$(echo $REPORTED_STATUS | jq --arg plugin gem --arg legacy_plugin pulp_gem -r '.versions[] | select(.component == $plugin or .component == $legacy_plugin) | .version')" - response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-gem/$REPORTED_VERSION/) - if [ "$response" == "200" ]; - then - echo "pulp_gem $REPORTED_VERSION has already been released. Skipping running tests." - exit - fi -fi - echo "machine pulp login admin password password " | cmd_user_stdin_prefix bash -c "cat >> ~pulp/.netrc" # Some commands like ansible-galaxy specifically require 600 -cmd_user_stdin_prefix bash -c "chmod 600 ~pulp/.netrc" +cmd_prefix bash -c "chmod 600 ~pulp/.netrc" -cd ../pulp-openapi-generator -if [ "$(echo "$REPORTED_STATUS" | jq -r '.versions[0].package')" = "null" ] +# Workaround: Domains are not supported by the published bindings. +if [ "$(echo "$REPORTED_STATUS" | jq -r '.domain_enabled')" = "true" ] then - # We are on an old version of pulpcore without package in the status report - for app_label in $(echo "$REPORTED_STATUS" | jq -r '.versions[].component') - do - if [ "$app_label" = "core" ] - then - item=pulpcore - else - item="pulp_${app_label}" - fi - ./generate.sh "${item}" python - cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" - sudo rm -rf "./${item}-client" - done -else + pushd ../pulp-openapi-generator for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[].package|sub("-"; "_")') do ./generate.sh "${item}" python cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" sudo rm -rf "./${item}-client" done + popd + touch bindings_requirements.txt +else + # TODO Workaround us not publishing pulp_file clients currently + echo "$REPORTED_STATUS" | jq -r '.versions[]|(.package|sub("_"; "-")) + "-client==" + .version' | grep -v pulp-file > bindings_requirements.txt + echo "pulp-file-client" >> bindings_requirements.txt + # echo "$REPORTED_STATUS" | jq -r '.versions[]|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_requirements.txt fi -cd $REPO_ROOT - -cat unittest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt" -cat functest_requirements.txt | cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt" -cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt +cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt" < unittest_requirements.txt +cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt" < functest_requirements.txt +cmd_stdin_prefix bash -c "cat > /tmp/bindings_requirements.txt" < bindings_requirements.txt +cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt -r /tmp/bindings_requirements.txt CERTIFI=$(cmd_prefix python3 -c 'import certifi; print(certifi.where())') -cmd_prefix bash -c "cat /etc/pulp/certs/pulp_webserver.crt | tee -a "$CERTIFI" > /dev/null" +cmd_prefix bash -c "cat /etc/pulp/certs/pulp_webserver.crt >> '$CERTIFI'" # check for any uncommitted migrations echo "Checking for uncommitted migrations..." @@ -110,13 +91,13 @@ if [[ "$TEST" == "performance" ]]; then if [[ -z ${PERFORMANCE_TEST+x} ]]; then cmd_user_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_gem.tests.performance" else - cmd_user_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_gem.tests.performance.test_$PERFORMANCE_TEST" + cmd_user_prefix bash -c "pytest -vv -r sx --color=yes --pyargs --capture=no --durations=0 pulp_gem.tests.performance.test_${PERFORMANCE_TEST}" fi exit fi -if [ -f $FUNC_TEST_SCRIPT ]; then - source $FUNC_TEST_SCRIPT +if [ -f "$FUNC_TEST_SCRIPT" ]; then + source "$FUNC_TEST_SCRIPT" else if [[ "$GITHUB_WORKFLOW" == "Gem Nightly CI/CD" ]] then @@ -133,6 +114,6 @@ pip install -r test_requirements.txt pytest -v -m pulp_gem popd -if [ -f $POST_SCRIPT ]; then - source $POST_SCRIPT +if [ -f "$POST_SCRIPT" ]; then + source "$POST_SCRIPT" fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fc1c05d..bf2a6e46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,13 +6,17 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Test +name: "Test" on: workflow_call: +defaults: + run: + working-directory: "pulp_gem" + jobs: test: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: @@ -32,22 +36,29 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 + path: "pulp_gem" + + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + repository: "pulp/pulp-openapi-generator" + path: "pulp-openapi-generator" - uses: actions/setup-python@v4 with: python-version: "3.8" - - uses: actions/download-artifact@v3 + - uses: "actions/download-artifact@v3" with: - name: plugin_package - path: dist/ + name: "plugin_package" + path: "pulp_gem/dist/" - name: Install httpie run: | echo ::group::HTTPIE pip install httpie echo ::endgroup:: - echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV + echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_gem/.ci/assets/httpie/" >> $GITHUB_ENV - name: Set environment variables run: | @@ -59,12 +70,12 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} 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 @@ -72,10 +83,6 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} @@ -85,19 +92,17 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} REDIS_DISABLED: ${{ contains('', matrix.env.TEST) }} - - name: Setting secrets - if: github.event_name != 'pull_request' - run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT" - env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} + - 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 @@ -105,10 +110,6 @@ jobs: env: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - GITHUB_PULL_REQUEST: ${{ github.event.number }} - GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} - GITHUB_BRANCH: ${{ github.head_ref }} - GITHUB_REPO_SLUG: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} @@ -116,6 +117,32 @@ jobs: id: deprecations run: echo deprecations-${{ matrix.env.TEST }}=$(docker logs pulp 2>&1 | grep -i pulpcore.deprecation | base64 -w 0) >> $GITHUB_OUTPUT + - name: Upload python client packages + if: ${{ env.TEST == 'pulp' }} + uses: actions/upload-artifact@v3 + with: + name: "python-client.tar" + path: "pulp_gem/python-client.tar" + + - name: Upload python client docs + if: ${{ env.TEST == 'pulp' }} + uses: actions/upload-artifact@v3 + with: + name: "python-client-docs.tar" + path: "pulp_gem/python-client-docs.tar" + - name: Upload Ruby client + if: ${{ env.TEST == 'pulp' }} + uses: actions/upload-artifact@v3 + with: + name: "ruby-client.tar" + path: "pulp_gem/ruby-client.tar" + - name: Upload built docs + if: ${{ env.TEST == 'docs' }} + uses: actions/upload-artifact@v3 + with: + name: "docs.tar" + path: "pulp_gem/docs/docs.tar" + - name: Logs if: always() run: | diff --git a/template_config.yml b/template_config.yml index 44f465e5..97a1585d 100644 --- a/template_config.yml +++ b/template_config.yml @@ -1,7 +1,7 @@ # This config represents the latest values used when running the plugin-template. Any settings that # were not present before running plugin-template have been added with their default values. -# generated with plugin_template@2021.08.26-265-gbdd41dd +# generated with plugin_template@2021.08.26-269-gaa9c44a additional_repos: [] api_root: /pulp/ @@ -39,6 +39,9 @@ parallel_test_workers: 8 plugin_app_label: gem plugin_default_branch: main plugin_name: pulp_gem +plugins: +- app_label: gem + name: pulp_gem post_job_template: null pre_job_template: null publish_docs_to_pulpprojectdotorg: true @@ -64,7 +67,6 @@ pypi_username: None python_version: '3.8' release_email: pulp-infra@redhat.com release_user: pulpbot -single_commit_check: true stalebot: true stalebot_days_until_close: 30 stalebot_days_until_stale: 90