Skip to content

Commit a200bff

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* 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 ...
2 parents 5f05e1d + 4a33d3c commit a200bff

29 files changed

+14445
-2374
lines changed

.github/workflows/check-dist.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v2
2525

26-
- name: Set Node.js 12.x
27-
uses: actions/setup-node@v1
26+
- name: Set Node.js 16.x
27+
uses: actions/setup-node@v3
2828
with:
29-
node-version: 12.x
29+
node-version: 16.x
30+
cache: npm
3031

3132
- name: Install dependencies
3233
run: npm ci

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: "Code scanning - action"
22

33
on:
44
push:
5+
branches: [ 'main' ]
56
pull_request:
67
schedule:
78
- cron: '25 3 * * 5'

.github/workflows/e2e-cache.yml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: [ubuntu-latest, windows-latest, macos-latest]
24-
python-version: ['3.8', '3.9', 'pypy-3.7-v7.x']
24+
python-version: ['3.9', 'pypy-3.7-v7.x']
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
- name: Setup Python
2828
uses: ./
2929
with:
@@ -39,9 +39,9 @@ jobs:
3939
fail-fast: false
4040
matrix:
4141
os: [ubuntu-latest, windows-latest, macos-latest]
42-
python-version: ['3.8', '3.9', 'pypy-3.7-v7.x']
42+
python-version: ['3.9', 'pypy-3.7-v7.x']
4343
steps:
44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v3
4545
- name: Setup Python
4646
uses: ./
4747
with:
@@ -50,7 +50,31 @@ jobs:
5050
- name: Install pipenv
5151
run: pipx install pipenv
5252
- name: Install dependencies
53-
run: pipenv install numpy
53+
run: |
54+
cd __tests__/data
55+
pipenv install --verbose
56+
57+
python-poetry-dependencies-caching:
58+
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
os: [ubuntu-latest, windows-latest, macos-latest]
64+
python-version: ['3.9', 'pypy-3.7-v7.x']
65+
steps:
66+
- uses: actions/checkout@v3
67+
- name: Install poetry
68+
run: pipx install poetry
69+
- name: Setup Python
70+
uses: ./
71+
with:
72+
python-version: ${{ matrix.python-version }}
73+
cache: 'poetry'
74+
- name: Init pyproject.toml
75+
run: poetry init -n
76+
- name: Install dependencies
77+
run: poetry add flake8
5478

5579
python-pip-dependencies-caching-path:
5680
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
@@ -59,9 +83,9 @@ jobs:
5983
fail-fast: false
6084
matrix:
6185
os: [ubuntu-latest, windows-latest, macos-latest]
62-
python-version: ['3.8', '3.9', 'pypy-3.7-v7.x']
86+
python-version: ['3.9', 'pypy-3.7-v7.x']
6387
steps:
64-
- uses: actions/checkout@v2
88+
- uses: actions/checkout@v3
6589
- name: Setup Python
6690
uses: ./
6791
with:
@@ -78,16 +102,18 @@ jobs:
78102
fail-fast: false
79103
matrix:
80104
os: [ubuntu-latest, windows-latest, macos-latest]
81-
python-version: ['3.8', '3.9', 'pypy-3.7-v7.x']
105+
python-version: ['3.9', 'pypy-3.7-v7.x']
82106
steps:
83-
- uses: actions/checkout@v2
107+
- uses: actions/checkout@v3
84108
- name: Setup Python
85109
uses: ./
86110
with:
87111
python-version: ${{ matrix.python-version }}
88112
cache: 'pipenv'
89-
cache-dependency-path: '**/requirements-linux.txt'
113+
cache-dependency-path: '**/pipenv-requirements.txt'
90114
- name: Install pipenv
91115
run: pipx install pipenv
92116
- name: Install dependencies
93-
run: pipenv install numpy
117+
run: |
118+
cd __tests__/data
119+
pipenv install --verbose

.github/workflows/licensed.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ jobs:
1414
name: Check licenses
1515
steps:
1616
- uses: actions/checkout@v2
17-
- name: Set Node.js 12.x
18-
uses: actions/setup-node@v2
17+
- name: Set Node.js 16.x
18+
uses: actions/setup-node@v3
1919
with:
20-
node-version: 12.x
20+
node-version: 16.x
21+
cache: npm
2122
- run: npm ci
2223
- name: Install licensed
2324
run: |
2425
cd $RUNNER_TEMP
25-
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz
26+
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
2627
sudo tar -xzf licensed.tar.gz
2728
sudo mv licensed /usr/local/bin/licensed
2829
- run: licensed status

.github/workflows/test-python.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,3 @@ jobs:
125125
- name: Run simple code
126126
run: python -c 'import math; print(math.factorial(5))'
127127

128-
setup-pypy-legacy:
129-
name: Setup PyPy ${{ matrix.os }}
130-
runs-on: ${{ matrix.os }}
131-
strategy:
132-
fail-fast: false
133-
matrix:
134-
os: [macos-10.15, windows-2019, ubuntu-18.04, ubuntu-20.04]
135-
steps:
136-
- name: Checkout
137-
uses: actions/checkout@v2
138-
139-
- name: setup-python pypy3
140-
uses: ./
141-
with:
142-
python-version: 'pypy3'
143-
144-
- name: setup-python pypy2
145-
uses: ./
146-
with:
147-
python-version: 'pypy2'

.github/workflows/workflow.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v2
2121

22-
- name: Set Node.js 12.x
23-
uses: actions/setup-node@v1
22+
- name: Set Node.js 16.x
23+
uses: actions/setup-node@v3
2424
with:
25-
node-version: 12.x
25+
node-version: 16.x
26+
cache: npm
2627

27-
- name: npm install
28-
run: npm install
28+
- name: npm ci
29+
run: npm ci
2930

3031
- name: Lint
3132
run: npm run format-check

.licenses/npm/@actions/cache.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@types/node.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# setup-python V2
1+
# setup-python V3
22

33
<p align="left">
44
<a href="https://github.com/actions/setup-python"><img alt="GitHub Actions status" src="https://github.com/actions/setup-python/workflows/Main%20workflow/badge.svg"></a>
@@ -9,7 +9,7 @@ This action sets up a Python environment for use in actions by:
99
- optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
1010
- 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.
1111
- failing if a specific version of Python is not preinstalled or available for download.
12-
- optionally caching dependencies for pip and pipenv.
12+
- optionally caching dependencies for pip, pipenv and poetry.
1313
- registering problem matchers for error output.
1414

1515
# What's new
@@ -19,7 +19,7 @@ This action sets up a Python environment for use in actions by:
1919
- Automatic setup and download of Python packages if using a self-hosted runner.
2020
- Support for pre-release versions of Python.
2121
- Support for installing any version of PyPy on-flight
22-
- Support for built-in caching of pip and pipenv dependencies
22+
- Support for built-in caching of pip, pipenv and poetry dependencies
2323
- Support for `.python-version` file
2424

2525
# Usage
@@ -29,8 +29,8 @@ See [action.yml](action.yml)
2929
Basic:
3030
```yaml
3131
steps:
32-
- uses: actions/checkout@v2
33-
- uses: actions/setup-python@v2
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-python@v3
3434
with:
3535
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
3636
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
@@ -58,9 +58,9 @@ jobs:
5858
python-version: [ '2.x', '3.x', 'pypy-2.7', 'pypy-3.7', 'pypy-3.8' ]
5959
name: Python ${{ matrix.python-version }} sample
6060
steps:
61-
- uses: actions/checkout@v2
61+
- uses: actions/checkout@v3
6262
- name: Set up Python
63-
uses: actions/setup-python@v2
63+
uses: actions/setup-python@v3
6464
with:
6565
python-version: ${{ matrix.python-version }}
6666
architecture: x64
@@ -82,9 +82,9 @@ jobs:
8282
- os: windows-latest
8383
python-version: '3.6'
8484
steps:
85-
- uses: actions/checkout@v2
85+
- uses: actions/checkout@v3
8686
- name: Set up Python
87-
uses: actions/setup-python@v2
87+
uses: actions/setup-python@v3
8888
with:
8989
python-version: ${{ matrix.python-version }}
9090
- name: Display Python version
@@ -101,8 +101,8 @@ jobs:
101101
# in this example, there is a newer version already installed, 3.7.7, so the older version will be downloaded
102102
python-version: ['3.7.4', '3.8', '3.9', '3.10']
103103
steps:
104-
- uses: actions/checkout@v2
105-
- uses: actions/setup-python@v2
104+
- uses: actions/checkout@v3
105+
- uses: actions/setup-python@v3
106106
with:
107107
python-version: ${{ matrix.python-version }}
108108
- run: python my_script.py
@@ -111,8 +111,8 @@ jobs:
111111
Download and set up an accurate pre-release version of Python:
112112
```yaml
113113
steps:
114-
- uses: actions/checkout@v2
115-
- uses: actions/setup-python@v2
114+
- uses: actions/checkout@v3
115+
- uses: actions/setup-python@v3
116116
with:
117117
python-version: '3.11.0-alpha.1'
118118
- run: python my_script.py
@@ -121,8 +121,8 @@ steps:
121121
Download and set up the latest available version of Python (includes both pre-release and stable versions):
122122
```yaml
123123
steps:
124-
- uses: actions/checkout@v2
125-
- uses: actions/setup-python@v2
124+
- uses: actions/checkout@v3
125+
- uses: actions/setup-python@v3
126126
with:
127127
python-version: '3.11.0-alpha - 3.11.0' # SemVer's version range syntax
128128
- run: python my_script.py
@@ -141,8 +141,8 @@ jobs:
141141
- 'pypy-3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
142142
- 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8
143143
steps:
144-
- uses: actions/checkout@v2
145-
- uses: actions/setup-python@v2
144+
- uses: actions/checkout@v3
145+
- uses: actions/setup-python@v3
146146
with:
147147
python-version: ${{ matrix.python-version }}
148148
- run: python my_script.py
@@ -191,8 +191,8 @@ GitHub hosted runners have a tools cache that comes with a few versions of Pytho
191191
|**PyPy Tool Cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
192192

193193
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)
196196

197197
# Specifying a Python version
198198

@@ -221,23 +221,24 @@ pypy-3.7-nightly # Python 3.7 and nightly PyPy
221221
222222
# Caching packages dependencies
223223
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` 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.
225225
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.
227227
228228
- For pip, the action will cache global cache directory
229229
- For pipenv, the action will cache virtualenv directory
230+
- For poetry, the action will cache virtualenv directory
230231
231232
**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.
232233
233234
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.
234235
235-
**Caching pip dependencies:**
236+
**Caching pip dependencies:**
236237
237238
```yaml
238239
steps:
239-
- uses: actions/checkout@v2
240-
- uses: actions/setup-python@v2
240+
- uses: actions/checkout@v3
241+
- uses: actions/setup-python@v3
241242
with:
242243
python-version: '3.9'
243244
cache: 'pip'
@@ -247,21 +248,35 @@ steps:
247248
**Caching pipenv dependencies:**
248249
```yaml
249250
steps:
250-
- uses: actions/checkout@v2
251+
- uses: actions/checkout@v3
251252
- name: Install pipenv
252253
run: pipx install pipenv
253-
- uses: actions/setup-python@v2
254+
- uses: actions/setup-python@v3
254255
with:
255256
python-version: '3.9'
256257
cache: 'pipenv'
257258
- run: pipenv install
258259
```
259260
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+
260275
**Using wildcard patterns to cache dependencies**
261276
```yaml
262277
steps:
263-
- uses: actions/checkout@v2
264-
- uses: actions/setup-python@v2
278+
- uses: actions/checkout@v3
279+
- uses: actions/setup-python@v3
265280
with:
266281
python-version: '3.9'
267282
cache: 'pip'
@@ -272,10 +287,10 @@ steps:
272287
**Using a list of file paths to cache dependencies**
273288
```yaml
274289
steps:
275-
- uses: actions/checkout@v2
290+
- uses: actions/checkout@v3
276291
- name: Install pipenv
277292
run: pipx install pipenv
278-
- uses: actions/setup-python@v2
293+
- uses: actions/setup-python@v3
279294
with:
280295
python-version: '3.9'
281296
cache: 'pipenv'

0 commit comments

Comments
 (0)