From 9c0fa5662ac3aa621790fe4ab0990d5cb6e31864 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 17 Oct 2024 09:43:40 -0500 Subject: [PATCH] chore(ci): move Python version into a file (#230) We were already specifying a Python version for setup-python actions in this repo, but this moves the Python version declaration to an external file. This isn't urgent but it does make it easier to keep the Python version coordinated across CI workflows and it also enables developers to know what version of Python is recommended for local development. To come out of draft, this PR needs to include README updates that document the existence and potential usage of the `.python-version` file. --- .github/workflows/docs-generation-test-pr.yml | 9 ++++++--- .github/workflows/integration-tests.yml | 9 ++++++--- .github/workflows/release.yml | 10 +++++++--- .gitignore | 4 ---- .python-version | 1 + DEVELOPMENT.md | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .python-version diff --git a/.github/workflows/docs-generation-test-pr.yml b/.github/workflows/docs-generation-test-pr.yml index c342983..b920486 100644 --- a/.github/workflows/docs-generation-test-pr.yml +++ b/.github/workflows/docs-generation-test-pr.yml @@ -12,16 +12,19 @@ permissions: pull-requests: read contents: read +env: + COLLECTION_PATH: .ansible/collections/ansible_collections/equinix/cloud + jobs: integration-test-pr: runs-on: ubuntu-latest defaults: run: - working-directory: .ansible/collections/ansible_collections/equinix/cloud + working-directory: ${{ env.COLLECTION_PATH }} steps: - uses: actions/checkout@v4 with: - path: .ansible/collections/ansible_collections/equinix/cloud + path: ${{ env.COLLECTION_PATH }} ref: ${{ github.event.pull_request.head.sha || github.ref }} - name: update packages @@ -33,7 +36,7 @@ jobs: - name: setup python 3 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version-file: ${{ env.COLLECTION_PATH }}/.python-version - name: install dependencies run: pip3 install -r requirements-dev.txt -r requirements.txt diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index ed6f7c7..c87707b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -22,6 +22,9 @@ permissions: pull-requests: read contents: read +env: + COLLECTION_PATH: .ansible/collections/ansible_collections/equinix/cloud + jobs: authorize: environment: @@ -41,11 +44,11 @@ jobs: concurrency: 'e2e-test' defaults: run: - working-directory: .ansible/collections/ansible_collections/equinix/cloud + working-directory: ${{ env.COLLECTION_PATH }} steps: - uses: actions/checkout@v4 with: - path: .ansible/collections/ansible_collections/equinix/cloud + path: ${{ env.COLLECTION_PATH }} ref: ${{ github.event.pull_request.head.sha || github.ref }} - name: update packages @@ -57,7 +60,7 @@ jobs: - name: setup python 3 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version-file: ${{ env.COLLECTION_PATH }}/.python-version - name: install dependencies run: pip3 install -r requirements-dev.txt -r requirements.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a76a44..881100b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ name: Semantic Release to GitHub and Ansible Galaxy on: workflow_dispatch: null +env: + COLLECTION_PATH: .ansible/collections/ansible_collections/equinix/cloud + + jobs: build: runs-on: ubuntu-latest @@ -15,7 +19,7 @@ jobs: - name: checkout repo uses: actions/checkout@v4 with: - path: .ansible/collections/ansible_collections/equinix/cloud + path: ${{ env.COLLECTION_PATH }} fetch-depth: 0 ssh-key: ${{ secrets.DEPLOY_KEY }} @@ -28,7 +32,7 @@ jobs: - name: setup python 3 uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version-file: ${{ env.COLLECTION_PATH }}/.python-version - name: install dependencies run: pip3 install -r requirements-dev.txt -r requirements.txt @@ -36,7 +40,7 @@ jobs: - name: Do GitHub release uses: cycjimmy/semantic-release-action@v4 with: - working_directory: .ansible/collections/ansible_collections/equinix/cloud + working_directory: ${{ env.COLLECTION_PATH }} semantic_version: 19.0.5 extra_plugins: | @semantic-release/exec@6.0.3 diff --git a/.gitignore b/.gitignore index 3e51490..ffbb64a 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,6 @@ flycheck_*.el # network security /network-security.data - ### Git ### # Created by git for backups. To disable backups in Git: # $ git config --global mergetool.keepBackup false @@ -245,9 +244,6 @@ docs/_build/ # PyBuilder target/ -# pyenv -.python-version - # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0e63ad4..5a2a60e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -21,7 +21,7 @@ ## 0. Development environment setup -We use Python 3.8 for the collection development. +We use Python for collection development. The Python version that is currently used in GitHub Actions workflows is tracked in the `.python-version` file in the root of this repository. We recommend using the same Python version for local development. Some tools, such as `pyenv`, may reference the `.python-version` file automatically, but in other cases you may have to manually install the specified Python version and add it to your path. Development of the collection is best done if your repository is located in a path that concludes with `ansible_collections/equinix/cloud`. This is a requirement specific to Ansible. You can clone the repository using the following command: