Skip to content

Commit 4237552

Browse files
authored
Improve Advanced Usage examples (#645)
* docs: fix outputs python-version example and description Description was lacking words, example was misleading (id was set to cp310 which clearly was a reference to CPython 3.10, but the id is referring to the setup-python action! * docs: copy-editing in advanced-usage.md Signed-off-by: Stephen L. <lrq3000@gmail.com> * docs: add example if statement in advanced-usage.md Signed-off-by: Stephen L. <lrq3000@gmail.com> * docs: implement changes suggested by @mahabaleshwars (deprecate pypy2.7, 3.7, 3.8, tweak example, remove wildcard *) Signed-off-by: Stephen L. <LRQ3000@gmail.com> --------- Signed-off-by: Stephen L. <lrq3000@gmail.com> Signed-off-by: Stephen L. <LRQ3000@gmail.com>
1 parent 709bfa5 commit 4237552

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

docs/advanced-usage.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ steps:
101101
- run: python my_script.py
102102
```
103103
104-
- **[x-ranges](https://github.com/npm/node-semver#x-ranges-12x-1x-12-)** to specify the latest stable version of Python (for specified major version):
104+
- **[x-ranges](https://github.com/npm/node-semver#x-ranges-12x-1x-12-)** to specify the latest stable version of Python (for the specified major version):
105105
106106
```yaml
107107
steps:
@@ -120,7 +120,6 @@ The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy
120120
```
121121
pypy3.10 or pypy-3.10 # the latest available version of PyPy that supports Python 3.10
122122
pypy3.9 or pypy-3.9 # the latest available version of PyPy that supports Python 3.9
123-
pypy2.7 or pypy-2.7 # the latest available version of PyPy that supports Python 2.7
124123
pypy3.7-v7.3.3 or pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
125124
pypy3.7-v7.x or pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
126125
pypy3.7-v7.3.3rc1 or pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
@@ -145,7 +144,7 @@ jobs:
145144
python-version: ${{ matrix.python-version }}
146145
- run: python my_script.py
147146
```
148-
More details on PyPy syntax can be found in the [Available versions of PyPy](#pypy) section.
147+
More details on the syntax for PyPy can be found in the [Available versions of PyPy](#pypy) section.
149148

150149
### Specifying multiple Python/PyPy versions
151150
The python-version input can get multiple python/pypy versions. The last specified version will be used as a default one.
@@ -205,15 +204,15 @@ jobs:
205204
206205
### Matrix Testing
207206
208-
Using `setup-python` it's possible to use [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
207+
Using `setup-python` it's possible to use the [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
209208

210209
```yaml
211210
jobs:
212211
build:
213212
runs-on: ubuntu-latest
214213
strategy:
215214
matrix:
216-
python-version: ['3.x', 'pypy2.7', 'pypy3.8', 'pypy3.9' ]
215+
python-version: ['3.x', 'pypy3.8', 'pypy3.9' ]
217216
name: Python ${{ matrix.python-version }} sample
218217
steps:
219218
- uses: actions/checkout@v4
@@ -232,27 +231,29 @@ jobs:
232231
build:
233232
runs-on: ${{ matrix.os }}
234233
strategy:
234+
fail-fast: false
235235
matrix:
236236
os: [ubuntu-latest, macos-latest, windows-latest]
237-
python-version: ['3.7', '3.8', '3.9', '3.10', 'pypy2.7', 'pypy3.9']
237+
python-version: ['3.9', '3.10', '3.11', 'pypy3.9']
238238
exclude:
239239
- os: macos-latest
240-
python-version: '3.8'
240+
python-version: '3.9'
241241
- os: windows-latest
242-
python-version: '3.8'
242+
python-version: '3.9'
243243
steps:
244244
- uses: actions/checkout@v4
245245
- name: Set up Python
246246
uses: actions/setup-python@v5
247247
with:
248248
python-version: ${{ matrix.python-version }}
249249
- name: Display Python version
250+
if: ${{ matrix.python-version != 'pypy3.9' }} # Use single quotes in expressions for input `python-version`
250251
run: python --version
251252
```
252253
253254
## Using the `python-version-file` input
254255

255-
`setup-python` action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.
256+
`setup-python` action can read the Python or PyPy version from a version file. `python-version-file` input is used to specify the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with an error.
256257

257258
>In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority.
258259

@@ -289,7 +290,7 @@ steps:
289290
check-latest: true
290291
- run: python my_script.py
291292
```
292-
> Setting `check-latest` to `true` has performance implications as downloading `Python or PyPy` versions is slower than using cached versions.
293+
> Setting `check-latest` to `true` impacts performance as downloading `Python or PyPy` versions is slower than using cached versions.
293294

294295

295296
## Caching packages
@@ -383,7 +384,7 @@ steps:
383384

384385
### `python-version`
385386

386-
Using **python-version** output it's possible to get the installed by action Python or PyPy version. This output is useful when the input `python-version` is given as a range (e.g. 3.8.0 - 3.12.0 ), but down in a workflow you need to operate with the exact installed version (e.g. 3.12.1).
387+
Using **python-version** output, it's possible to get the precise Python or PyPy version installed by the action. This output is useful when the input `python-version` is given as a range (e.g. 3.9.0 - 3.12.0, 3.x ), but down the line you need to operate (such as in an `if:` statement) with the exact installed version (e.g. 3.12.0).
387388

388389
```yaml
389390
jobs:
@@ -394,13 +395,13 @@ jobs:
394395
- uses: actions/setup-python@v5
395396
id: cp312
396397
with:
397-
python-version: "3.8.0 - 3.12.0"
398+
python-version: "3.9.0 - 3.12.0"
398399
- run: echo '${{ steps.cp312.outputs.python-version }}'
399400
```
400401

401402
### `python-path`
402403

403-
**python-path** output is available with the absolute path of the Python or PyPy interpreter executable if you need it:
404+
**python-path** output is available to get the absolute path of the Python or PyPy interpreter executable:
404405

405406
```yaml
406407
jobs:
@@ -449,7 +450,7 @@ The `update-environment` flag defaults to `true`.
449450
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for Python or PyPy to just work out of the box.
450451

451452
If `update-environment` is set to `false`, the action will not add/update environment variables.
452-
This can prove useful if you want the only side-effect to be to ensure Python or PyPy is installed and rely on the `python-path` output to run executable.
453+
This can prove useful if you only want the side-effect to ensure that Python or PyPy is installed and rely on the `python-path` output to run the executable.
453454
Such a requirement on side-effect could be because you don't want your composite action messing with your user's workflows.
454455

455456
```yaml
@@ -469,7 +470,7 @@ Such a requirement on side-effect could be because you don't want your composite
469470

470471
- Preinstalled versions of Python in the tool cache on GitHub-hosted runners.
471472
- For detailed information regarding the available versions of Python that are installed, see [Supported software](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-software).
472-
- For every minor version of Python, expect only the latest patch to be preinstalled.
473+
- For every minor versions of Python, expect only the latest patch to be preinstalled.
473474
- If `3.12.1` is installed for example, and `3.12.2` is released, expect `3.12.1` to be removed and replaced by `3.12.2` in the tool cache.
474475
- If the exact patch version doesn't matter to you, specifying just the major and minor versions will get you the latest preinstalled patch version. In the previous example, the version spec `3.12` will use the `3.12.2` Python version found in the cache.
475476
- Use `-dev` instead of a patch number (e.g., `3.14-dev`) to install the latest patch version release for a given minor version, *alpha and beta releases included*.
@@ -534,11 +535,11 @@ If you have a supported self-hosted runner and you would like to use `setup-pyth
534535

535536
### Linux
536537

537-
By default runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Linux self-hosted runners:
538+
By default, the runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Linux self-hosted runners:
538539
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/path/to/folder`.
539540
- More permanent way of setting the environment variable is to create an `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/path/to/folder`. This ensures the variable is always set if your runner is configured as a service.
540541

541-
If you're using a non-default tool cache directory be sure that the user starting the runner has write permission to the new tool cache directory. To check the current user and group that the runner belongs type `ls -l` inside the runner's root directory.
542+
If you're using a non-default tool cache directory be sure that the user starting the runner has write permission to the new tool cache directory. To check the current user and group that the runner belongs, type `ls -l` inside the runner's root directory.
542543

543544
The runner can be granted write access to any directory using a few techniques:
544545
- The user starting the runner is the owner, and the owner has write permission.

0 commit comments

Comments
 (0)