From a34d223d839d9eee1c856be72d2f0ab280257496 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 15 Nov 2023 12:19:08 +0000 Subject: [PATCH] Update the tools requirements Signed-off-by: Pedro Algarvio --- .github/workflows/ci.yml | 54 ++++++++------ .github/workflows/nightly.yml | 54 ++++++++------ .github/workflows/scheduled.yml | 54 ++++++++------ .github/workflows/staging.yml | 49 +++++++------ .github/workflows/templates/ci.yml.jinja | 46 ++++++------ .github/workflows/templates/layout.yml.jinja | 12 ++++ .gitignore | 2 + .pre-commit-config.yaml | 25 ++++--- .../static/ci/py3.10/tools-virustotal.txt | 28 ++++++++ requirements/static/ci/py3.10/tools.txt | 70 ++++++++++++------- .../static/ci/py3.9/tools-virustotal.txt | 28 ++++++++ requirements/static/ci/py3.9/tools.txt | 70 ++++++++++++------- requirements/static/ci/tools-virustotal.in | 3 + requirements/static/ci/tools.in | 5 +- tools/__init__.py | 31 +++++++- tools/pkg/__init__.py | 2 +- tools/pkg/repo/__init__.py | 15 +--- tools/pkg/repo/create.py | 15 +--- tools/pkg/repo/publish.py | 15 +--- tools/release.py | 15 +--- tools/utils/__init__.py | 9 ++- tools/vm.py | 35 ++++------ 22 files changed, 398 insertions(+), 239 deletions(-) create mode 100644 requirements/static/ci/py3.10/tools-virustotal.txt create mode 100644 requirements/static/ci/py3.9/tools-virustotal.txt create mode 100644 requirements/static/ci/tools-virustotal.in diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c93e9bc4a04..d54ce0bbfff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,6 +134,18 @@ jobs: with: python-version: "3.10" + - name: Get Python Version + id: get-python-version + uses: ./.github/actions/get-python-version + with: + python-binary: python3 + + - name: Restore Cached Python Tools Virtualenvs + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts uses: ./.github/actions/setup-python-tools-scripts @@ -269,28 +281,28 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Get Python Version id: get-python-version uses: ./.github/actions/get-python-version with: python-binary: python3 - - name: Setup Python Tools Scripts - id: python-tools-scripts - uses: ./.github/actions/setup-python-tools-scripts - - - name: Cache Python Tools Docs Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/docs - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|docs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/docs.txt') }} - - - name: Cache Python Tools Changelog Virtualenv + - name: Restore Python Tools Virtualenvs Cache uses: actions/cache@v3 with: - path: .tools-venvs/changelog - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|changelog|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/changelog.txt') }} + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts + uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version id: setup-salt-version @@ -412,8 +424,16 @@ jobs: with: python-binary: python3 + - name: Restore Python Tools Virtualenvs Cache + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts - id: python-tools-scripts uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version @@ -422,12 +442,6 @@ jobs: with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - - name: Cache Python Tools Build Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/build - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|build|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/build.txt') }} - - name: Build Source Tarball uses: ./.github/actions/build-source-tarball with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c35b3126e37f..89119b5c61ad 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -178,6 +178,18 @@ jobs: with: python-version: "3.10" + - name: Get Python Version + id: get-python-version + uses: ./.github/actions/get-python-version + with: + python-binary: python3 + + - name: Restore Cached Python Tools Virtualenvs + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts uses: ./.github/actions/setup-python-tools-scripts @@ -313,28 +325,28 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Get Python Version id: get-python-version uses: ./.github/actions/get-python-version with: python-binary: python3 - - name: Setup Python Tools Scripts - id: python-tools-scripts - uses: ./.github/actions/setup-python-tools-scripts - - - name: Cache Python Tools Docs Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/docs - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|docs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/docs.txt') }} - - - name: Cache Python Tools Changelog Virtualenv + - name: Restore Python Tools Virtualenvs Cache uses: actions/cache@v3 with: - path: .tools-venvs/changelog - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|changelog|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/changelog.txt') }} + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts + uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version id: setup-salt-version @@ -461,8 +473,16 @@ jobs: with: python-binary: python3 + - name: Restore Python Tools Virtualenvs Cache + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts - id: python-tools-scripts uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version @@ -471,12 +491,6 @@ jobs: with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - - name: Cache Python Tools Build Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/build - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|build|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/build.txt') }} - - name: Build Source Tarball uses: ./.github/actions/build-source-tarball with: diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 527d224cd74b..3eb379f77720 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -168,6 +168,18 @@ jobs: with: python-version: "3.10" + - name: Get Python Version + id: get-python-version + uses: ./.github/actions/get-python-version + with: + python-binary: python3 + + - name: Restore Cached Python Tools Virtualenvs + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts uses: ./.github/actions/setup-python-tools-scripts @@ -303,28 +315,28 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Get Python Version id: get-python-version uses: ./.github/actions/get-python-version with: python-binary: python3 - - name: Setup Python Tools Scripts - id: python-tools-scripts - uses: ./.github/actions/setup-python-tools-scripts - - - name: Cache Python Tools Docs Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/docs - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|docs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/docs.txt') }} - - - name: Cache Python Tools Changelog Virtualenv + - name: Restore Python Tools Virtualenvs Cache uses: actions/cache@v3 with: - path: .tools-venvs/changelog - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|changelog|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/changelog.txt') }} + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts + uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version id: setup-salt-version @@ -446,8 +458,16 @@ jobs: with: python-binary: python3 + - name: Restore Python Tools Virtualenvs Cache + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts - id: python-tools-scripts uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version @@ -456,12 +476,6 @@ jobs: with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - - name: Cache Python Tools Build Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/build - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|build|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/build.txt') }} - - name: Build Source Tarball uses: ./.github/actions/build-source-tarball with: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index a2ab55dad879..4f7291a334cc 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -164,6 +164,18 @@ jobs: with: python-version: "3.10" + - name: Get Python Version + id: get-python-version + uses: ./.github/actions/get-python-version + with: + python-binary: python3 + + - name: Restore Cached Python Tools Virtualenvs + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts uses: ./.github/actions/setup-python-tools-scripts @@ -318,22 +330,17 @@ jobs: with: python-binary: python3 - - name: Setup Python Tools Scripts - id: python-tools-scripts - uses: ./.github/actions/setup-python-tools-scripts - - - name: Cache Python Tools Docs Virtualenv + - name: Restore Python Tools Virtualenvs Cache uses: actions/cache@v3 with: - path: .tools-venvs/docs - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|docs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/docs.txt') }} - - - name: Cache Python Tools Changelog Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/changelog - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|changelog|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/changelog.txt') }} + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts + uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version id: setup-salt-version @@ -456,8 +463,16 @@ jobs: with: python-binary: python3 + - name: Restore Python Tools Virtualenvs Cache + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts - id: python-tools-scripts uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version @@ -466,12 +481,6 @@ jobs: with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - - name: Cache Python Tools Build Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/build - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|build|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/build.txt') }} - - name: Build Source Tarball uses: ./.github/actions/build-source-tarball with: diff --git a/.github/workflows/templates/ci.yml.jinja b/.github/workflows/templates/ci.yml.jinja index 3ae870563815..ff9f773898c4 100644 --- a/.github/workflows/templates/ci.yml.jinja +++ b/.github/workflows/templates/ci.yml.jinja @@ -59,28 +59,32 @@ steps: - uses: actions/checkout@v4 + <%- if not prepare_actual_release %> + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + <%- endif %> + - name: Get Python Version id: get-python-version uses: ./.github/actions/get-python-version with: python-binary: python3 - - name: Setup Python Tools Scripts - id: python-tools-scripts - uses: ./.github/actions/setup-python-tools-scripts - - - name: Cache Python Tools Docs Virtualenv + - name: Restore Python Tools Virtualenvs Cache uses: actions/cache@v3 with: - path: .tools-venvs/docs - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|docs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/docs.txt') }} - - - name: Cache Python Tools Changelog Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/changelog - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|changelog|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/changelog.txt') }} + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|changelog + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts + uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version id: setup-salt-version @@ -228,8 +232,16 @@ with: python-binary: python3 + - name: Restore Python Tools Virtualenvs Cache + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + restore-keys: | + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }}|build + ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts - id: python-tools-scripts uses: ./.github/actions/setup-python-tools-scripts - name: Setup Salt Version @@ -238,12 +250,6 @@ with: salt-version: "${{ needs.prepare-workflow.outputs.salt-version }}" - - name: Cache Python Tools Build Virtualenv - uses: actions/cache@v3 - with: - path: .tools-venvs/build - key: ${{ needs.prepare-workflow.outputs.cache-seed }}|${{ github.workflow }}|${{ github.job }}|tools-venvs|${{ steps.python-tools-scripts.outputs.version }}|build|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/build.txt') }} - - name: Build Source Tarball uses: ./.github/actions/build-source-tarball with: diff --git a/.github/workflows/templates/layout.yml.jinja b/.github/workflows/templates/layout.yml.jinja index bf98f9c22770..21c46817ad7a 100644 --- a/.github/workflows/templates/layout.yml.jinja +++ b/.github/workflows/templates/layout.yml.jinja @@ -182,6 +182,18 @@ jobs: with: python-version: "3.10" + - name: Get Python Version + id: get-python-version + uses: ./.github/actions/get-python-version + with: + python-binary: python3 + + - name: Restore Cached Python Tools Virtualenvs + uses: actions/cache@v3 + with: + path: .tools-venvs + key: ${{ env.CACHE_SEED }}|${{ github.workflow }}|tools-venvs|${{ steps.get-python-version.outputs.version }}|${{ hashFiles('requirements/**/*.txt', 'tools/**/*.py') }} + - name: Setup Python Tools Scripts uses: ./.github/actions/setup-python-tools-scripts diff --git a/.gitignore b/.gitignore index c933bbf79d21..f4f1babbb7cb 100644 --- a/.gitignore +++ b/.gitignore @@ -145,3 +145,5 @@ nox.*.tar.xz /pkg/debian/salt-ssh /pkg/debian/salt-syndic /pkg/debian/debhelper-build-stamp + +.tools-venvs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7979d8fc593..aee06411e530 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: )$ - repo: https://github.com/s0undt3ch/python-tools-scripts - rev: "0.15.0" + rev: "0.18.3" hooks: - id: tools alias: check-changelog-entries @@ -1078,16 +1078,24 @@ repos: - requirements/static/ci/tools.in - id: pip-tools-compile - alias: compile-ci-tools-3.11-requirements - name: Linux CI Py3.11 Tools Requirements - files: ^requirements/static/ci/(tools\.in|py3.11/(tools|linux)\.txt)$ + alias: compile-ci-tools-virustotal-3.9-requirements + name: Linux CI Py3.9 Tools virustotal Requirements + files: ^requirements/static/ci/(tools(-virustotal)?\.in|py3.9/(tools(-virustotal)?|linux)\.txt)$ pass_filenames: false args: - -v - - --build-isolation - - --py-version=3.11 - - --no-emit-index-url - - requirements/static/ci/tools.in + - --py-version=3.9 + - requirements/static/ci/tools-virustotal.in + + - id: pip-tools-compile + alias: compile-ci-tools-virustotal-3.10-requirements + name: Linux CI Py3.10 Tools virustotal Requirements + files: ^requirements/static/ci/(tools(-virustotal)?\.in|py3.10/(tools(-virustotal)?|linux)\.txt)$ + pass_filenames: false + args: + - -v + - --py-version=3.10 + - requirements/static/ci/tools-virustotal.in # <---- Tools ----------------------------------------------------------------------------------------------------- # ----- Code Formatting -------------------------------------------------------------------------------------------> @@ -1319,6 +1327,7 @@ repos: - types-attrs - types-pyyaml - types-requests + - python-tools-scripts>=0.18.3 - repo: https://github.com/saltstack/mirrors-nox rev: v2021.6.12 diff --git a/requirements/static/ci/py3.10/tools-virustotal.txt b/requirements/static/ci/py3.10/tools-virustotal.txt new file mode 100644 index 000000000000..11aa11ca27b2 --- /dev/null +++ b/requirements/static/ci/py3.10/tools-virustotal.txt @@ -0,0 +1,28 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file=requirements/static/ci/py3.10/tools-virustotal.txt requirements/static/ci/tools-virustotal.in +# +certifi==2023.7.22 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests +idna==3.2 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests +requests==2.31.0 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # virustotal3 +urllib3==1.26.18 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests +virustotal3==1.0.8 + # via -r requirements/static/ci/tools-virustotal.in diff --git a/requirements/static/ci/py3.10/tools.txt b/requirements/static/ci/py3.10/tools.txt index 3cd670b6dfe5..69f0c3896c0b 100644 --- a/requirements/static/ci/py3.10/tools.txt +++ b/requirements/static/ci/py3.10/tools.txt @@ -4,57 +4,77 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.10/tools.txt requirements/static/ci/tools.in # -attrs==22.1.0 +attrs==20.3.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts -boto3==1.21.46 +boto3==1.26.147 # via -r requirements/static/ci/tools.in -botocore==1.24.46 +botocore==1.29.147 # via # boto3 # s3transfer -certifi==2023.07.22 - # via requests -charset-normalizer==3.0.1 - # via requests -commonmark==0.9.1 - # via rich +certifi==2023.7.22 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests idna==3.2 - # via requests + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # requests jinja2==3.1.2 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # -r requirements/static/ci/tools.in jmespath==1.0.1 # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt # boto3 # botocore +markdown-it-py==2.2.0 + # via rich markupsafe==2.1.2 - # via jinja2 -packaging==23.0 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # jinja2 +mdurl==0.1.2 + # via markdown-it-py +packaging==22.0 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # -r requirements/static/ci/tools.in pygments==2.13.0 # via rich -python-dateutil==2.8.2 - # via botocore -python-tools-scripts==0.18.1 +python-dateutil==2.8.1 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # botocore +python-tools-scripts==0.18.3 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # -r requirements/static/ci/tools.in requests==2.31.0 # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt # python-tools-scripts - # virustotal3 -rich==12.5.1 +rich==13.3.5 # via python-tools-scripts -s3transfer==0.5.2 +s3transfer==0.6.1 # via boto3 six==1.16.0 - # via python-dateutil -typing-extensions==4.4.0 + # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt + # python-dateutil +typing-extensions==4.2.0 # via python-tools-scripts urllib3==1.26.18 # via + # -c requirements/static/ci/../pkg/py3.10/linux.txt # botocore # requests -virustotal3==1.0.8 - # via -r requirements/static/ci/tools.in diff --git a/requirements/static/ci/py3.9/tools-virustotal.txt b/requirements/static/ci/py3.9/tools-virustotal.txt new file mode 100644 index 000000000000..6972dd80375e --- /dev/null +++ b/requirements/static/ci/py3.9/tools-virustotal.txt @@ -0,0 +1,28 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file=requirements/static/ci/py3.9/tools-virustotal.txt requirements/static/ci/tools-virustotal.in +# +certifi==2023.7.22 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests +idna==3.2 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests +requests==2.31.0 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # virustotal3 +urllib3==1.26.18 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests +virustotal3==1.0.8 + # via -r requirements/static/ci/tools-virustotal.in diff --git a/requirements/static/ci/py3.9/tools.txt b/requirements/static/ci/py3.9/tools.txt index a5ae88526d4b..018373ce6358 100644 --- a/requirements/static/ci/py3.9/tools.txt +++ b/requirements/static/ci/py3.9/tools.txt @@ -4,57 +4,77 @@ # # pip-compile --no-emit-index-url --output-file=requirements/static/ci/py3.9/tools.txt requirements/static/ci/tools.in # -attrs==22.1.0 +attrs==20.3.0 # via # -r requirements/static/ci/tools.in # python-tools-scripts -boto3==1.21.46 +boto3==1.26.147 # via -r requirements/static/ci/tools.in -botocore==1.24.46 +botocore==1.29.147 # via # boto3 # s3transfer -certifi==2023.07.22 - # via requests -charset-normalizer==3.0.1 - # via requests -commonmark==0.9.1 - # via rich +certifi==2023.7.22 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests +charset-normalizer==3.2.0 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests idna==3.2 - # via requests + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # requests jinja2==3.1.2 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # -r requirements/static/ci/tools.in jmespath==1.0.1 # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt # boto3 # botocore +markdown-it-py==2.2.0 + # via rich markupsafe==2.1.2 - # via jinja2 -packaging==23.0 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # jinja2 +mdurl==0.1.2 + # via markdown-it-py +packaging==22.0 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # -r requirements/static/ci/tools.in pygments==2.13.0 # via rich -python-dateutil==2.8.2 - # via botocore -python-tools-scripts==0.18.1 +python-dateutil==2.8.1 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # botocore +python-tools-scripts==0.18.3 # via -r requirements/static/ci/tools.in pyyaml==6.0.1 - # via -r requirements/static/ci/tools.in + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # -r requirements/static/ci/tools.in requests==2.31.0 # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt # python-tools-scripts - # virustotal3 -rich==12.5.1 +rich==13.3.5 # via python-tools-scripts -s3transfer==0.5.2 +s3transfer==0.6.1 # via boto3 six==1.16.0 - # via python-dateutil -typing-extensions==4.4.0 + # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt + # python-dateutil +typing-extensions==4.2.0 # via python-tools-scripts urllib3==1.26.18 # via + # -c requirements/static/ci/../pkg/py3.9/linux.txt # botocore # requests -virustotal3==1.0.8 - # via -r requirements/static/ci/tools.in diff --git a/requirements/static/ci/tools-virustotal.in b/requirements/static/ci/tools-virustotal.in new file mode 100644 index 000000000000..b7d1a356f4e4 --- /dev/null +++ b/requirements/static/ci/tools-virustotal.in @@ -0,0 +1,3 @@ +--constraint=../pkg/py{py_version}/{platform}.txt + +virustotal3 diff --git a/requirements/static/ci/tools.in b/requirements/static/ci/tools.in index 9066c498fcc4..143cab05113b 100644 --- a/requirements/static/ci/tools.in +++ b/requirements/static/ci/tools.in @@ -1,7 +1,8 @@ -python-tools-scripts >= 0.18.1 +--constraint=../pkg/py{py_version}/{platform}.txt + attrs +python-tools-scripts >= 0.18.3 boto3 pyyaml jinja2 packaging -virustotal3 diff --git a/tools/__init__.py b/tools/__init__.py index db61bd0ba163..22be82c40de1 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -1,7 +1,36 @@ import logging +import pathlib +import sys import ptscripts +from ptscripts.parser import DefaultRequirementsConfig +from ptscripts.virtualenv import VirtualEnvConfig +REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent +REQUIREMENTS_FILES_PATH = REPO_ROOT / "requirements" +STATIC_REQUIREMENTS_PATH = REQUIREMENTS_FILES_PATH / "static" +CI_REQUIREMENTS_FILES_PATH = ( + STATIC_REQUIREMENTS_PATH / "ci" / "py{}.{}".format(*sys.version_info) +) +PKG_REQUIREMENTS_FILES_PATH = ( + STATIC_REQUIREMENTS_PATH / "pkg" / "py{}.{}".format(*sys.version_info) +) +DEFAULT_REQS_CONFIG = DefaultRequirementsConfig( + pip_args=[ + f"--constraint={PKG_REQUIREMENTS_FILES_PATH / 'linux.txt'}", + ], + requirements_files=[ + REQUIREMENTS_FILES_PATH / "base.txt", + CI_REQUIREMENTS_FILES_PATH / "tools.txt", + ], +) +RELEASE_VENV_CONFIG = VirtualEnvConfig( + requirements_files=[ + CI_REQUIREMENTS_FILES_PATH / "tools-virustotal.txt", + ], + add_as_extra_site_packages=True, +) +ptscripts.set_default_requirements_config(DEFAULT_REQS_CONFIG) ptscripts.register_tools_module("tools.changelog") ptscripts.register_tools_module("tools.ci") ptscripts.register_tools_module("tools.docs") @@ -13,9 +42,9 @@ ptscripts.register_tools_module("tools.precommit") ptscripts.register_tools_module("tools.precommit.changelog") ptscripts.register_tools_module("tools.precommit.workflows") -ptscripts.register_tools_module("tools.release") ptscripts.register_tools_module("tools.testsuite") ptscripts.register_tools_module("tools.testsuite.download") +ptscripts.register_tools_module("tools.release", venv_config=RELEASE_VENV_CONFIG) ptscripts.register_tools_module("tools.vm") for name in ("boto3", "botocore", "urllib3"): diff --git a/tools/pkg/__init__.py b/tools/pkg/__init__.py index 5b97eaa6778b..056129966553 100644 --- a/tools/pkg/__init__.py +++ b/tools/pkg/__init__.py @@ -154,7 +154,7 @@ def set_salt_version( ret = venv.run_code(code, capture=True, check=False) if ret.returncode: ctx.error(ret.stderr.decode()) - ctx.exit(ctx.returncode) + ctx.exit(ret.returncode) salt_version = ret.stdout.strip().decode() if not tools.utils.REPO_ROOT.joinpath("salt").is_dir(): diff --git a/tools/pkg/repo/__init__.py b/tools/pkg/repo/__init__.py index 5599bfd57223..e48671051f2a 100644 --- a/tools/pkg/repo/__init__.py +++ b/tools/pkg/repo/__init__.py @@ -8,27 +8,16 @@ import os import pathlib import shutil -import sys from typing import TYPE_CHECKING +import boto3 +from botocore.exceptions import ClientError from ptscripts import Context, command_group import tools.pkg import tools.utils from tools.utils import Version, get_salt_releases -try: - import boto3 - from botocore.exceptions import ClientError -except ImportError: - print( - "\nPlease run 'python -m pip install -r " - "requirements/static/ci/py{}.{}/tools.txt'\n".format(*sys.version_info), - file=sys.stderr, - flush=True, - ) - raise - log = logging.getLogger(__name__) # Define the command group diff --git a/tools/pkg/repo/create.py b/tools/pkg/repo/create.py index 8dfbf9dc459b..a665340098c7 100644 --- a/tools/pkg/repo/create.py +++ b/tools/pkg/repo/create.py @@ -10,11 +10,11 @@ import os import pathlib import shutil -import sys import textwrap from datetime import datetime from typing import TYPE_CHECKING +import boto3 from ptscripts import Context, command_group import tools.pkg @@ -26,17 +26,6 @@ get_repo_json_file_contents, ) -try: - import boto3 -except ImportError: - print( - "\nPlease run 'python -m pip install -r " - "requirements/static/ci/py{}.{}/tools.txt'\n".format(*sys.version_info), - file=sys.stderr, - flush=True, - ) - raise - log = logging.getLogger(__name__) create = command_group( @@ -157,7 +146,7 @@ def debian( distro_details = _deb_distro_info[distro][distro_version] ctx.info("Distribution Details:") - ctx.info(distro_details) + ctx.print(distro_details, soft_wrap=True) if TYPE_CHECKING: assert isinstance(distro_details["label"], str) assert isinstance(distro_details["codename"], str) diff --git a/tools/pkg/repo/publish.py b/tools/pkg/repo/publish.py index 3ad0ec9e428d..2a743ac046bb 100644 --- a/tools/pkg/repo/publish.py +++ b/tools/pkg/repo/publish.py @@ -10,12 +10,13 @@ import os import pathlib import re -import sys import tempfile import textwrap from typing import TYPE_CHECKING, Any +import boto3 import packaging.version +from botocore.exceptions import ClientError from ptscripts import Context, command_group import tools.pkg @@ -24,18 +25,6 @@ from tools.utils import Version, get_salt_releases, parse_versions from tools.utils.repo import create_full_repo_path, get_repo_json_file_contents -try: - import boto3 - from botocore.exceptions import ClientError -except ImportError: - print( - "\nPlease run 'python -m pip install -r " - "requirements/static/ci/py{}.{}/tools.txt'\n".format(*sys.version_info), - file=sys.stderr, - flush=True, - ) - raise - log = logging.getLogger(__name__) publish = command_group( diff --git a/tools/release.py b/tools/release.py index f78e93c07ecf..cc17938d4537 100644 --- a/tools/release.py +++ b/tools/release.py @@ -8,28 +8,17 @@ import logging import os import pathlib -import sys import tempfile import time +import boto3 import virustotal3.core +from botocore.exceptions import ClientError from ptscripts import Context, command_group import tools.utils import tools.utils.repo -try: - import boto3 - from botocore.exceptions import ClientError -except ImportError: - print( - "\nPlease run 'python -m pip install -r " - "requirements/static/ci/py{}.{}/tools.txt'\n".format(*sys.version_info), - file=sys.stderr, - flush=True, - ) - raise - log = logging.getLogger(__name__) # Define the command group diff --git a/tools/utils/__init__.py b/tools/utils/__init__.py index b5dda0ddcb3a..bebc9c98eb34 100644 --- a/tools/utils/__init__.py +++ b/tools/utils/__init__.py @@ -14,7 +14,9 @@ from enum import IntEnum from typing import Any +import boto3 import packaging.version +from botocore.exceptions import ClientError from ptscripts import Context from rich.progress import ( BarColumn, @@ -217,7 +219,7 @@ def download_file( ctx: Context, url: str, dest: pathlib.Path, - auth: str | None = None, + auth: tuple[str, str] | None = None, headers: dict[str, str] | None = None, ) -> pathlib.Path: ctx.info(f"Downloading {dest.name!r} @ {url} ...") @@ -235,7 +237,7 @@ def download_file( return dest wget = shutil.which("wget") if wget is not None: - with ctx.cwd(dest.parent): + with ctx.chdir(dest.parent): command = [wget, "--no-verbose"] if headers: for key, value in headers.items(): @@ -248,7 +250,8 @@ def download_file( return dest # NOTE the stream=True parameter below with ctx.web as web: - web.headers.update(headers) + if headers: + web.headers.update(headers) with web.get(url, stream=True, auth=auth) as r: r.raise_for_status() with dest.open("wb") as f: diff --git a/tools/vm.py b/tools/vm.py index ca3717aa9090..a8fa51ea7486 100644 --- a/tools/vm.py +++ b/tools/vm.py @@ -21,33 +21,22 @@ from functools import lru_cache from typing import TYPE_CHECKING, cast +import attr +import boto3 +from botocore.exceptions import ClientError from ptscripts import Context, command_group from requests.exceptions import ConnectTimeout +from rich.progress import ( + BarColumn, + Column, + Progress, + TaskProgressColumn, + TextColumn, + TimeRemainingColumn, +) import tools.utils -try: - import attr - import boto3 - from botocore.exceptions import ClientError - from rich.progress import ( - BarColumn, - Column, - Progress, - TaskProgressColumn, - TextColumn, - TimeRemainingColumn, - ) -except ImportError: - print( - "\nPlease run 'python -m pip install -r " - "requirements/static/ci/py{}.{}/tools.txt'\n".format(*sys.version_info), - file=sys.stderr, - flush=True, - ) - raise - - if TYPE_CHECKING: # pylint: disable=no-name-in-module from boto3.resources.factory.ec2 import Instance @@ -1313,6 +1302,8 @@ def upload_checkout(self, verbose=True, download=False): "--exclude", ".nox/", "--exclude", + ".tools-venvs/", + "--exclude", ".pytest_cache/", "--exclude", f"{STATE_DIR.relative_to(tools.utils.REPO_ROOT)}{os.path.sep}",