You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* upstream/main: (33 commits)
Fix virtual-env toolcache links
Updated @actions/cache (actions#382)
ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows (actions#379)
Cache hit output (actions#373)
Add pyton-version to setup PyPy output (actions#365)
Rework pipenv caching test (actions#375)
Update README.md to fix setup-python version in example (actions#368)
dist fix (actions#367)
Cache on ghes (actions#363)
Update dist
Use `\n` instead of `os.EOL`
Update dist
Initialise pyproject.toml
Build and format
Remove console.log
Remove unused file
Reduce test matrix
Parse values from poetry
Release
Add more tests
...
@@ -9,7 +9,7 @@ This action sets up a Python environment for use in actions by:
9
9
- optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
10
10
- downloading, installing and adding to PATH an available version of Python from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)) if a specific version is not available in the tools cache.
11
11
- failing if a specific version of Python is not preinstalled or available for download.
12
-
- optionally caching dependencies for pipand pipenv.
12
+
- optionally caching dependencies for pip, pipenv and poetry.
13
13
- registering problem matchers for error output.
14
14
15
15
# What's new
@@ -19,7 +19,7 @@ This action sets up a Python environment for use in actions by:
19
19
- Automatic setup and download of Python packages if using a self-hosted runner.
20
20
- Support for pre-release versions of Python.
21
21
- Support for installing any version of PyPy on-flight
22
-
- Support for built-in caching of pipand pipenv dependencies
22
+
- Support for built-in caching of pip, pipenv and poetry dependencies
23
23
- Support for `.python-version` file
24
24
25
25
# Usage
@@ -29,8 +29,8 @@ See [action.yml](action.yml)
29
29
Basic:
30
30
```yaml
31
31
steps:
32
-
- uses: actions/checkout@v2
33
-
- uses: actions/setup-python@v2
32
+
- uses: actions/checkout@v3
33
+
- uses: actions/setup-python@v3
34
34
with:
35
35
python-version: '3.x'# Version range or exact version of a Python version to use, using SemVer's version range syntax
36
36
architecture: 'x64'# optional x64 or x86. Defaults to x64 if not specified
# in this example, there is a newer version already installed, 3.7.7, so the older version will be downloaded
102
102
python-version: ['3.7.4', '3.8', '3.9', '3.10']
103
103
steps:
104
-
- uses: actions/checkout@v2
105
-
- uses: actions/setup-python@v2
104
+
- uses: actions/checkout@v3
105
+
- uses: actions/setup-python@v3
106
106
with:
107
107
python-version: ${{ matrix.python-version }}
108
108
- run: python my_script.py
@@ -111,8 +111,8 @@ jobs:
111
111
Download and set up an accurate pre-release version of Python:
112
112
```yaml
113
113
steps:
114
-
- uses: actions/checkout@v2
115
-
- uses: actions/setup-python@v2
114
+
- uses: actions/checkout@v3
115
+
- uses: actions/setup-python@v3
116
116
with:
117
117
python-version: '3.11.0-alpha.1'
118
118
- run: python my_script.py
@@ -121,8 +121,8 @@ steps:
121
121
Download and set up the latest available version of Python (includes both pre-release and stable versions):
122
122
```yaml
123
123
steps:
124
-
- uses: actions/checkout@v2
125
-
- uses: actions/setup-python@v2
124
+
- uses: actions/checkout@v3
125
+
- uses: actions/setup-python@v3
126
126
with:
127
127
python-version: '3.11.0-alpha - 3.11.0'# SemVer's version range syntax
128
128
- run: python my_script.py
@@ -141,8 +141,8 @@ jobs:
141
141
- 'pypy-3.7-v7.3.3'# Python 3.7 and PyPy 7.3.3
142
142
- 'pypy-3.8'# the latest available version of PyPy that supports Python 3.8
143
143
steps:
144
-
- uses: actions/checkout@v2
145
-
- uses: actions/setup-python@v2
144
+
- uses: actions/checkout@v3
145
+
- uses: actions/setup-python@v3
146
146
with:
147
147
python-version: ${{ matrix.python-version }}
148
148
- run: python my_script.py
@@ -191,8 +191,8 @@ GitHub hosted runners have a tools cache that comes with a few versions of Pytho
191
191
|**PyPy Tool Cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
192
192
193
193
GitHub virtual environments are setup in [actions/virtual-environments](https://github.com/actions/virtual-environments). During the setup, the available versions of Python and PyPy are automatically downloaded, setup and documented.
194
-
- [Tools cache setup for Ubuntu](https://github.com/actions/virtual-environments/blob/main/images/linux/scripts/installers/hosted-tool-cache.sh)
195
-
- [Tools cache setup for Windows](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Download-ToolCache.ps1)
194
+
- Tools cache setup for Ubuntu: [Install-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/linux/scripts/installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/linux/scripts/installers/Configure-Toolset.ps1)
195
+
- Tools cache setup for Windows: [Install-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Configure-Toolset.ps1)
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`and `pipenv`. The `cache` input is optional, and caching is turned off by default.
224
+
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default.
225
225
226
-
The action defaults to searching for a dependency file (`requirements.txt` for pip or `Pipfile.lock` for pipenv) in the repository, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases where multiple dependency files are used, they are located in different subdirectories or different files for the hash want to be used.
226
+
The action defaults to searching for a dependency file (`requirements.txt` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases where multiple dependency files are used, they are located in different subdirectories or different files for the hash want to be used.
227
227
228
228
- For pip, the action will cache global cache directory
229
229
- For pipenv, the action will cache virtualenv directory
230
+
- For poetry, the action will cache virtualenv directory
230
231
231
232
**Please Note:** Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available that can lead to an increase in total build time.
232
233
233
234
The requirements file format allows to specify dependency versions using logical operators (for example chardet>=3.0.4) or specify dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary.
234
235
235
-
**Caching pip dependencies:**
236
+
**Caching pip dependencies:**
236
237
237
238
```yaml
238
239
steps:
239
-
- uses: actions/checkout@v2
240
-
- uses: actions/setup-python@v2
240
+
- uses: actions/checkout@v3
241
+
- uses: actions/setup-python@v3
241
242
with:
242
243
python-version: '3.9'
243
244
cache: 'pip'
@@ -247,21 +248,35 @@ steps:
247
248
**Caching pipenv dependencies:**
248
249
```yaml
249
250
steps:
250
-
- uses: actions/checkout@v2
251
+
- uses: actions/checkout@v3
251
252
- name: Install pipenv
252
253
run: pipx install pipenv
253
-
- uses: actions/setup-python@v2
254
+
- uses: actions/setup-python@v3
254
255
with:
255
256
python-version: '3.9'
256
257
cache: 'pipenv'
257
258
- run: pipenv install
258
259
```
259
260
261
+
**Caching poetry dependencies:**
262
+
```yaml
263
+
steps:
264
+
- uses: actions/checkout@v3
265
+
- name: Install poetry
266
+
run: pipx install poetry
267
+
- uses: actions/setup-python@v3
268
+
with:
269
+
python-version: '3.9'
270
+
cache: 'poetry'
271
+
- run: poetry install
272
+
- run: poetry run pytest
273
+
```
274
+
260
275
**Using wildcard patterns to cache dependencies**
261
276
```yaml
262
277
steps:
263
-
- uses: actions/checkout@v2
264
-
- uses: actions/setup-python@v2
278
+
- uses: actions/checkout@v3
279
+
- uses: actions/setup-python@v3
265
280
with:
266
281
python-version: '3.9'
267
282
cache: 'pip'
@@ -272,10 +287,10 @@ steps:
272
287
**Using a list of file paths to cache dependencies**
0 commit comments