зеркало из https://github.com/github/docs.git
Update 'Building and testing Python' for Python 3.13 (#34915)
Co-authored-by: Alex Nguyen <150945400+nguyenalex836@users.noreply.github.com>
This commit is contained in:
Родитель
4a4ee6d0e2
Коммит
b7b273c6f8
|
@ -70,21 +70,21 @@ We recommend that you have a basic understanding of Python, and pip. For more in
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
- uses: {% data reusables.actions.action-checkout %}
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.13
|
||||||
uses: {% data reusables.actions.action-setup-python %}
|
uses: {% data reusables.actions.action-setup-python %}
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.13"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install flake8 pytest
|
pip install ruff pytest
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
- name: Lint with flake8
|
- name: Lint and format Python code with ruff
|
||||||
run: |
|
run: |
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
# Lint with the default set of ruff rules with GitHub Annotations
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
ruff check --format=github --target-version=py39
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
# Verify the code is properly formatted
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
ruff format --diff --target-version=py39
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
pytest
|
pytest
|
||||||
|
@ -136,7 +136,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
- uses: {% data reusables.actions.action-checkout %}
|
||||||
|
@ -151,7 +151,7 @@ jobs:
|
||||||
|
|
||||||
### Using a specific Python version
|
### Using a specific Python version
|
||||||
|
|
||||||
You can configure a specific version of Python. For example, 3.10. Alternatively, you can use semantic version syntax to get the latest minor release. This example uses the latest minor release of Python 3.
|
You can configure a specific version of Python. For example, 3.12. Alternatively, you can use semantic version syntax to get the latest minor release. This example uses the latest minor release of Python 3.
|
||||||
|
|
||||||
```yaml copy
|
```yaml copy
|
||||||
name: Python package
|
name: Python package
|
||||||
|
@ -180,7 +180,7 @@ jobs:
|
||||||
|
|
||||||
### Excluding a version
|
### Excluding a version
|
||||||
|
|
||||||
If you specify a version of Python that is not available, `setup-python` fails with an error such as: `##[error]Version 3.6 with arch x64 not found`. The error message includes the available versions.
|
If you specify a version of Python that is not available, `setup-python` fails with an error such as: `##[error]Version 3.7 with arch x64 not found`. The error message includes the available versions.
|
||||||
|
|
||||||
You can also use the `exclude` keyword in your workflow if there is a configuration of Python that you do not wish to run. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategy)."
|
You can also use the `exclude` keyword in your workflow if there is a configuration of Python that you do not wish to run. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategy)."
|
||||||
|
|
||||||
|
@ -196,12 +196,12 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
python-version: ["3.9", "3.10", "3.11", "pypy3.9", "pypy3.10"]
|
python-version: ["3.9", "3.11", "3.13", "pypy3.10"]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
python-version: "3.9"
|
python-version: "3.11"
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
python-version: "3.9"
|
python-version: "3.11"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using the default Python version
|
### Using the default Python version
|
||||||
|
@ -259,7 +259,7 @@ steps:
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
- uses: {% data reusables.actions.action-checkout %}
|
||||||
- uses: {% data reusables.actions.action-setup-python %}
|
- uses: {% data reusables.actions.action-setup-python %}
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.12'
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
- run: pip install -r requirements.txt
|
- run: pip install -r requirements.txt
|
||||||
- run: pip test
|
- run: pip test
|
||||||
|
@ -294,9 +294,9 @@ steps:
|
||||||
pytest tests.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
|
pytest tests.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using Ruff to lint code
|
### Using Ruff to lint and/or format code
|
||||||
|
|
||||||
The following example installs or upgrades `ruff` and uses it to lint all files. For more information, see [Ruff](https://beta.ruff.rs/docs).
|
The following example installs or upgrades `ruff` and uses it to lint all files. For more information, see [Ruff](https://docs.astral.sh/ruff).
|
||||||
|
|
||||||
```yaml copy
|
```yaml copy
|
||||||
steps:
|
steps:
|
||||||
|
@ -305,18 +305,16 @@ steps:
|
||||||
uses: {% data reusables.actions.action-setup-python %}
|
uses: {% data reusables.actions.action-setup-python %}
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
- name: Install dependencies
|
- name: Install the code linting and formatting tool Ruff
|
||||||
run: |
|
run: pipx install ruff
|
||||||
python -m pip install --upgrade pip
|
- name: Lint code with Ruff
|
||||||
pip install -r requirements.txt
|
run: ruff check --output-format=github --target-version=py39
|
||||||
- name: Lint with Ruff
|
- name: Check code formatting with Ruff
|
||||||
run: |
|
run: ruff format --diff --target-version=py39
|
||||||
pip install ruff
|
|
||||||
ruff check --output-format=github .
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
```
|
```
|
||||||
|
|
||||||
The linting step has `continue-on-error: true` set. This will keep the workflow from failing if the linting step doesn't succeed. Once you've addressed all of the linting errors, you can remove this option so the workflow will catch new issues.
|
The formatting step has `continue-on-error: true` set. This will keep the workflow from failing if the formatting step doesn't succeed. Once you've addressed all of the formatting errors, you can remove this option so the workflow will catch new issues.
|
||||||
|
|
||||||
### Running tests with tox
|
### Running tests with tox
|
||||||
|
|
||||||
|
@ -333,7 +331,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python: ["3.9", "3.10", "3.11"]
|
python: ["3.9", "3.11", "3.13"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
- uses: {% data reusables.actions.action-checkout %}
|
||||||
|
@ -365,7 +363,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
- uses: {% data reusables.actions.action-checkout %}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче