Skip to content

Commit 1f0a39a

Browse files
author
IvanZosimov
committed
Sync with Main branch
2 parents b2241a4 + 2f06e9d commit 1f0a39a

25 files changed

+758
-134
lines changed

.github/workflows/check-dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222

2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525

2626
- name: Set Node.js 16.x
2727
uses: actions/setup-node@v3
@@ -45,7 +45,7 @@ jobs:
4545
id: diff
4646

4747
# If index.js was different than expected, upload the expected version as an artifact
48-
- uses: actions/upload-artifact@v2
48+
- uses: actions/upload-artifact@v3
4949
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
5050
with:
5151
name: dist

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ jobs:
1818

1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2222

2323
# Initializes the CodeQL tools for scanning.
2424
- name: Initialize CodeQL
25-
uses: github/codeql-action/init@v1
25+
uses: github/codeql-action/init@v2
2626
# Override language selection by uncommenting this and choosing your languages
2727
# with:
2828
# languages: go, javascript, csharp, python, cpp, java
2929

3030
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3131
# If this step fails, then you should remove it and run the build manually (see below)
3232
- name: Autobuild
33-
uses: github/codeql-action/autobuild@v1
33+
uses: github/codeql-action/autobuild@v2
3434

3535
# ℹ️ Command-line programs to run using the OS shell.
3636
# 📚 https://git.io/JvXDl
@@ -44,4 +44,4 @@ jobs:
4444
# make release
4545

4646
- name: Perform CodeQL Analysis
47-
uses: github/codeql-action/analyze@v1
47+
uses: github/codeql-action/analyze@v2

.github/workflows/e2e-cache.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ jobs:
7272
- uses: actions/checkout@v3
7373
- name: Install poetry
7474
run: pipx install poetry
75+
- name: Init pyproject.toml
76+
run: mv ./__tests__/data/pyproject.toml .
7577
- name: Setup Python
7678
uses: ./
7779
with:
7880
python-version: ${{ matrix.python-version }}
7981
cache: 'poetry'
80-
- name: Init pyproject.toml
81-
run: poetry init -n
8282
- name: Install dependencies
83-
run: poetry add flake8
83+
run: poetry install
8484

8585
python-pip-dependencies-caching-path:
8686
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})

.github/workflows/licensed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
name: Check licenses
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
- name: Set Node.js 16.x
1818
uses: actions/setup-node@v3
1919
with:

.github/workflows/release-new-action-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Update the ${{ env.TAG_NAME }} tag
24-
uses: actions/publish-action@v0.1.0
24+
uses: actions/publish-action@v0.2.0
2525
with:
2626
source-tag: ${{ env.TAG_NAME }}
27-
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
27+
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

.github/workflows/test-pypy.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
steps:
3636
- name: Checkout
37-
uses: actions/checkout@v2
37+
uses: actions/checkout@v3
3838

3939
- name: setup-python ${{ matrix.pypy }}
4040
id: setup-python
@@ -91,3 +91,36 @@ jobs:
9191

9292
- name: Run simple code
9393
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
94+
95+
check-latest:
96+
runs-on: ${{ matrix.os }}
97+
strategy:
98+
fail-fast: false
99+
matrix:
100+
os: [ubuntu-latest, windows-latest, macos-latest]
101+
steps:
102+
- uses: actions/checkout@v3
103+
- name: Setup PyPy and check latest
104+
uses: ./
105+
with:
106+
python-version: 'pypy-3.7-v7.3.x'
107+
check-latest: true
108+
- name: PyPy and Python version
109+
run: python --version
110+
111+
- name: Run simple code
112+
run: python -c 'import math; print(math.factorial(5))'
113+
114+
- name: Assert PyPy is running
115+
run: |
116+
import platform
117+
assert platform.python_implementation().lower() == "pypy"
118+
shell: python
119+
120+
- name: Assert expected binaries (or symlinks) are present
121+
run: |
122+
EXECUTABLE="pypy-3.7-v7.3.x"
123+
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
124+
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
125+
${EXECUTABLE} --version
126+
shell: bash

.github/workflows/test-python.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,27 @@ jobs:
172172

173173
- name: Run simple code
174174
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
175+
176+
check-latest:
177+
runs-on: ${{ matrix.os }}
178+
strategy:
179+
fail-fast: false
180+
matrix:
181+
os: [ubuntu-latest, windows-latest, macos-latest]
182+
python-version: ["3.8", "3.9", "3.10"]
183+
steps:
184+
- uses: actions/checkout@v3
185+
- name: Setup Python and check latest
186+
uses: ./
187+
with:
188+
python-version: ${{ matrix.python-version }}
189+
check-latest: true
190+
- name: Validate version
191+
run: |
192+
$pythonVersion = (python --version)
193+
if ("$pythonVersion" -NotMatch "${{ matrix.python }}"){
194+
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
195+
exit 1
196+
}
197+
$pythonVersion
198+
shell: pwsh

.github/workflows/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
operating-system: [ubuntu-latest, windows-latest]
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
2121

2222
- name: Set Node.js 16.x
2323
uses: actions/setup-node@v3

.licenses/npm/@actions/http-client.dep.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,151 @@ The `python-version` input supports the [Semantic Versioning Specification](http
4747

4848
Using `architecture` input it is possible to specify required Python/PyPy interpreter architecture: `x86` or `x64`. If input is not specified the architecture defaults to `x64`.
4949

50+
<<<<<<< HEAD
5051
## Caching packages dependencies
52+
=======
53+
Download and set up the latest stable version of Python (for specified major version):
54+
```yaml
55+
steps:
56+
- uses: actions/checkout@v3
57+
- uses: actions/setup-python@v4
58+
with:
59+
python-version: '3.x'
60+
- run: python my_script.py
61+
```
62+
63+
Download and set up PyPy:
64+
65+
```yaml
66+
jobs:
67+
build:
68+
runs-on: ubuntu-latest
69+
strategy:
70+
matrix:
71+
python-version:
72+
- 'pypy3.7' # the latest available version of PyPy that supports Python 3.7
73+
- 'pypy3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
74+
- 'pypy3.8' # the latest available version of PyPy that supports Python 3.8
75+
steps:
76+
- uses: actions/checkout@v3
77+
- uses: actions/setup-python@v4
78+
with:
79+
python-version: ${{ matrix.python-version }}
80+
- run: python my_script.py
81+
```
82+
More details on PyPy syntax and examples of using preview / nightly versions of PyPy can be found in the [Available versions of PyPy](#available-versions-of-pypy) section.
83+
84+
An output is available with the absolute path of the python interpreter executable if you need it:
85+
```yaml
86+
jobs:
87+
build:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v3
91+
- uses: actions/setup-python@v4
92+
id: cp310
93+
with:
94+
python-version: "3.10"
95+
- run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version
96+
```
97+
98+
>The environment variable `pythonLocation` also becomes available after Python or PyPy installation. It contains the absolute path to the folder where the desired version of Python or PyPy is installed.
99+
100+
# Getting started with Python + Actions
101+
102+
Check out our detailed guide on using [Python with GitHub Actions](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-python-with-github-actions).
103+
104+
# Available versions of Python
105+
106+
`setup-python` is able to configure Python from two sources:
107+
108+
- Preinstalled versions of Python in the tools cache on GitHub-hosted runners.
109+
- 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).
110+
- For every minor version of Python, expect only the latest patch to be preinstalled.
111+
- If `3.8.1` is installed for example, and `3.8.2` is released, expect `3.8.1` to be removed and replaced by `3.8.2` in the tools cache.
112+
- If the exact patch version doesn't matter to you, specifying just the major and minor version will get you the latest preinstalled patch version. In the previous example, the version spec `3.8` will use the `3.8.2` Python version found in the cache.
113+
- Use `-dev` instead of a patch number (e.g., `3.11-dev`) to install the latest patch version release for a given minor version, *alpha and beta releases included*.
114+
- Downloadable Python versions from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)).
115+
- All available versions are listed in the [version-manifest.json](https://github.com/actions/python-versions/blob/main/versions-manifest.json) file.
116+
- If there is a specific version of Python that is not available, you can open an issue here
117+
118+
**Note:** Python versions used in this action are generated in the [python-versions](https://github.com/actions/python-versions) repository. For macOS and Ubuntu images python versions are built from the source code. For Windows the python-versions repository uses installation executable. For more information please refer to the [python-versions](https://github.com/actions/python-versions) repository.
119+
120+
# Available versions of PyPy
121+
122+
`setup-python` is able to configure PyPy from two sources:
123+
124+
- Preinstalled versions of PyPy in the tools cache on GitHub-hosted runners
125+
- For detailed information regarding the available versions of PyPy that are installed, see [Supported software](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-software).
126+
- For the latest PyPy release, all versions of Python are cached.
127+
- Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy3.7` or `pypy-3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy3.7-v7.3.3` or `pypy-3.7-v7.3.3`.
128+
129+
- Downloadable PyPy versions from the [official PyPy site](https://downloads.python.org/pypy/).
130+
- All available versions that we can download are listed in [versions.json](https://downloads.python.org/pypy/versions.json) file.
131+
- PyPy < 7.3.3 are not available to install on-flight.
132+
- If some versions are not available, you can open an issue in https://foss.heptapod.net/pypy/pypy/
133+
134+
# Hosted Tool Cache
135+
136+
GitHub hosted runners have a tools cache that comes with a few versions of Python + PyPy already installed. This tools cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and there is where you will find Python and PyPy installed. `setup-python` works by taking a specific version of Python or PyPy in this tools cache and adding it to PATH.
137+
138+
|| Location |
139+
|------|-------|
140+
|**Tool Cache Directory** |`RUNNER_TOOL_CACHE`|
141+
|**Python Tool Cache**|`RUNNER_TOOL_CACHE/Python/*`|
142+
|**PyPy Tool Cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
143+
144+
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.
145+
- 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)
146+
- 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)
147+
148+
# Specifying a Python version
149+
150+
If there is a specific version of Python that you need and you don't want to worry about any potential breaking changes due to patch updates (going from `3.7.5` to `3.7.6` for example), you should specify the exact major, minor, and patch version (such as `3.7.5`)
151+
- The only downside to this is that set up will take a little longer since the exact version will have to be downloaded if the exact version is not already installed on the runner due to more recent versions.
152+
- MSI installers are used on Windows for this, so runs will take a little longer to set up vs Mac and Linux.
153+
154+
You should specify only a major and minor version if you are okay with the most recent patch version being used.
155+
- There will be a single patch version already installed on each runner for every minor version of Python that is supported.
156+
- The patch version that will be preinstalled, will generally be the latest and every time there is a new patch released, the older version that is preinstalled will be replaced.
157+
- Using the most recent patch version will result in a very quick setup since no downloads will be required since a locally installed version Python on the runner will be used.
158+
159+
# Specifying a PyPy version
160+
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
161+
The `<pypy_version>` parameter is optional and can be skipped. The latest version will be used in this case.
162+
163+
```
164+
pypy3.7 or pypy-3.7 # the latest available version of PyPy that supports Python 3.7
165+
pypy3.8 or pypy-3.8 # the latest available version of PyPy that supports Python 3.8
166+
pypy2.7 or pypy-2.7 # the latest available version of PyPy that supports Python 2.7
167+
pypy3.7-v7.3.3 or pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
168+
pypy3.7-v7.x or pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
169+
pypy3.7-v7.3.3rc1 or pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
170+
pypy3.7-nightly or pypy-3.7-nightly # Python 3.7 and nightly PyPy
171+
```
172+
173+
Note: `pypy2` and `pypy3` have been removed in v3. Use the format above instead.
174+
175+
# Check latest version
176+
177+
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific `Python/PyPy` version is always used.
178+
179+
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a `Python/PyPy` version will then be downloaded. Set `check-latest` to `true` if you want the most up-to-date `Python/PyPy` version to always be used.
180+
181+
> Setting `check-latest` to `true` has performance implications as downloading `Python/PyPy` versions is slower than using cached versions.
182+
183+
```yaml
184+
steps:
185+
- uses: actions/checkout@v3
186+
- uses: actions/setup-python@v3
187+
with:
188+
python-version: '3.7'
189+
check-latest: true
190+
- run: python my_script.py
191+
```
192+
193+
# Caching packages dependencies
194+
>>>>>>> main
51195
52196
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.
53197

0 commit comments

Comments
 (0)