mirror of
https://github.com/actions/setup-python.git
synced 2025-06-24 12:41:09 +02:00
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
3105fb18c0 | |||
8c5ea631b2 | |||
2831efe49a | |||
3b3f2de1b1 | |||
723e46dad7 | |||
195f5c388b | |||
41b7212b16 | |||
878156f1de | |||
c181ffa198 | |||
1ce870e10f | |||
b9436a7e86 | |||
51d2bf1911 | |||
24156c231c | |||
212e83ff58 | |||
0c28554988 | |||
7010ec794f | |||
306c473438 | |||
7a69c2bc7d | |||
654aa00a6e | |||
6f45e887f6 | |||
2989dc4a1a | |||
a0a76c4ddb | |||
2241d846ba | |||
807b74f98c | |||
5230712b36 | |||
4dda7a3aa1 | |||
9f521e1bf4 | |||
ee653cd47f | |||
c23f4218be | |||
f129643215 | |||
6cbb9cfdfd | |||
6c4e46d258 | |||
824e8a7e12 | |||
8910d815ad | |||
e5af64b2df | |||
985150d1f6 | |||
c881de7f35 | |||
b7d744ca11 |
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1 +1,2 @@
|
||||
* text=auto eol=lf
|
||||
* text=auto eol=lf
|
||||
.licenses/** -diff linguist-generated=true
|
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
||||
* @actions/actions-service
|
44
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
44
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Which version of the action are you using?**
|
||||
|
||||
- [ ] `v1`
|
||||
- [ ] `v2`
|
||||
- [ ] Some other tag (such as `v2.0.1` or `master`)
|
||||
|
||||
**Environment**
|
||||
- [ ] self-hosted
|
||||
- [ ] Linux
|
||||
- [ ] Windows
|
||||
- [ ] Mac
|
||||
|
||||
If applicable, please specify if you're using a container
|
||||
|
||||
**Python Versions**
|
||||
Please list all of the effected versions of Python (`3.8.2`, etc.)
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Run/Repo Url**
|
||||
If applicable, and if your repo/run is public, please include a URL so it is easier for us to investigate.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
45
.github/workflows/codeql-analysis.yml
vendored
Normal file
45
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
name: "Code scanning - action"
|
||||
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '25 3 * * 5'
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
# CodeQL runs on ubuntu-latest and windows-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
20
.github/workflows/licensed.yml
vendored
Normal file
20
.github/workflows/licensed.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: Licensed
|
||||
|
||||
on:
|
||||
push: {branches: main}
|
||||
pull_request: {branches: main}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check licenses
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm ci
|
||||
- name: Install licensed
|
||||
run: |
|
||||
cd $RUNNER_TEMP
|
||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
||||
sudo tar -xzf licensed.tar.gz
|
||||
sudo mv licensed /usr/local/bin/licensed
|
||||
- run: licensed status
|
12
.github/workflows/lint-yaml.yml
vendored
12
.github/workflows/lint-yaml.yml
vendored
@ -1,12 +0,0 @@
|
||||
name: Lint YAML
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Lint action.yml
|
||||
uses: ibiqlik/action-yamllint@master
|
||||
with:
|
||||
file_or_dir: action.yml
|
||||
config_file: yaml-lint-config.yml
|
47
.github/workflows/test-pypy.yml
vendored
Normal file
47
.github/workflows/test-pypy.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: Validate PyPy e2e
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
schedule:
|
||||
- cron: 30 3 * * *
|
||||
|
||||
jobs:
|
||||
setup-pypy:
|
||||
name: Setup PyPy ${{ matrix.pypy }} ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
|
||||
pypy:
|
||||
- 'pypy-2.7'
|
||||
- 'pypy-3.6'
|
||||
- 'pypy-3.7'
|
||||
- 'pypy-2.7-v7.3.2'
|
||||
- 'pypy-3.6-v7.3.2'
|
||||
- 'pypy-3.7-v7.3.2'
|
||||
- 'pypy-3.6-v7.3.x'
|
||||
- 'pypy-3.7-v7.x'
|
||||
- 'pypy-3.6-v7.3.3rc1'
|
||||
- 'pypy-3.7-nightly'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: setup-python ${{ matrix.pypy }}
|
||||
uses: ./
|
||||
with:
|
||||
python-version: ${{ matrix.pypy }}
|
||||
|
||||
- name: PyPy and Python version
|
||||
run: python --version
|
||||
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
@ -1,8 +1,15 @@
|
||||
name: Validate 'setup-python'
|
||||
name: Validate Python e2e
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
schedule:
|
||||
- cron: 30 3 * * *
|
||||
|
||||
jobs:
|
||||
default-version:
|
||||
@ -11,7 +18,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
|
||||
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
@ -25,14 +32,14 @@ jobs:
|
||||
- name: Run simple python code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
||||
setup-python:
|
||||
setup-versions-from-manifest:
|
||||
name: Setup ${{ matrix.python }} ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
|
||||
python: [3.5, 3.6, 3.7, 3.8, 3.9]
|
||||
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
|
||||
python: [3.5.4, 3.6.7, 3.7.5, 3.8.1]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
@ -45,7 +52,7 @@ jobs:
|
||||
- name: Validate version
|
||||
run: |
|
||||
$pythonVersion = (python --version)
|
||||
if ("$pythonVersion" -notlike "Python ${{ matrix.python }}.*"){
|
||||
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
|
||||
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
|
||||
exit 1
|
||||
}
|
||||
@ -55,13 +62,42 @@ jobs:
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
||||
setup-pypy:
|
||||
setup-pre-release-version-from-manifest:
|
||||
name: Setup 3.9.0-beta.4 ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: setup-python 3.9.0-beta.4
|
||||
uses: ./
|
||||
with:
|
||||
python-version: '3.9.0-beta.4'
|
||||
|
||||
- name: Validate version
|
||||
run: |
|
||||
$pythonVersion = (python --version)
|
||||
if ("Python 3.9.0b4" -ne "$pythonVersion"){
|
||||
Write-Host "The current version is $pythonVersion; expected version is 3.9.0b4"
|
||||
exit 1
|
||||
}
|
||||
$pythonVersion
|
||||
shell: pwsh
|
||||
|
||||
- name: Run simple code
|
||||
run: python -c 'import math; print(math.factorial(5))'
|
||||
|
||||
setup-pypy-legacy:
|
||||
name: Setup PyPy ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
|
||||
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
66
.github/workflows/workflow.yml
vendored
66
.github/workflows/workflow.yml
vendored
@ -1,5 +1,13 @@
|
||||
name: Main workflow
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
jobs:
|
||||
run:
|
||||
name: Run
|
||||
@ -24,3 +32,59 @@ jobs:
|
||||
|
||||
- name: npm test
|
||||
run: npm test
|
||||
|
||||
- name: Run with setup-python 2.7
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 2.7
|
||||
- name: Verify 2.7
|
||||
run: python __tests__/verify-python.py 2.7
|
||||
|
||||
- name: Run with setup-python 3.5
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.5
|
||||
- name: Verify 3.5
|
||||
run: python __tests__/verify-python.py 3.5
|
||||
|
||||
- name: Run with setup-python 3.6
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.6
|
||||
- name: Verify 3.6
|
||||
run: python __tests__/verify-python.py 3.6
|
||||
|
||||
- name: Run with setup-python 3.7
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Verify 3.7
|
||||
run: python __tests__/verify-python.py 3.7
|
||||
|
||||
- name: Run with setup-python 3.8
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Verify 3.8
|
||||
run: python __tests__/verify-python.py 3.8
|
||||
|
||||
- name: Run with setup-python 3.7.5
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.7.5
|
||||
- name: Verify 3.7.5
|
||||
run: python __tests__/verify-python.py 3.7.5
|
||||
|
||||
- name: Run with setup-python 3.6.7
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.6.7
|
||||
- name: Verify 3.6.7
|
||||
run: python __tests__/verify-python.py 3.6.7
|
||||
|
||||
- name: Run with setup-python 3.8.1
|
||||
uses: ./
|
||||
with:
|
||||
python-version: 3.8.1
|
||||
- name: Verify 3.8.1
|
||||
run: python __tests__/verify-python.py 3.8.1
|
||||
|
14
.licensed.yml
Normal file
14
.licensed.yml
Normal file
@ -0,0 +1,14 @@
|
||||
sources:
|
||||
npm: true
|
||||
|
||||
allowed:
|
||||
- apache-2.0
|
||||
- bsd-2-clause
|
||||
- bsd-3-clause
|
||||
- isc
|
||||
- mit
|
||||
- cc0-1.0
|
||||
- unlicense
|
||||
|
||||
reviewed:
|
||||
npm:
|
20
.licenses/npm/@actions/core.dep.yml
generated
Normal file
20
.licenses/npm/@actions/core.dep.yml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: "@actions/core"
|
||||
version: 1.2.6
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
30
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
30
.licenses/npm/@actions/exec.dep.yml
generated
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: "@actions/exec"
|
||||
version: 1.0.4
|
||||
type: npm
|
||||
summary: Actions exec lib
|
||||
homepage: https://github.com/actions/toolkit/tree/master/packages/exec
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: Auto-generated MIT license text
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
32
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
version: 1.0.8
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/http-client#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
30
.licenses/npm/@actions/io.dep.yml
generated
Normal file
30
.licenses/npm/@actions/io.dep.yml
generated
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: "@actions/io"
|
||||
version: 1.0.2
|
||||
type: npm
|
||||
summary: Actions io lib
|
||||
homepage: https://github.com/actions/toolkit/tree/master/packages/io
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: Auto-generated MIT license text
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
30
.licenses/npm/@actions/tool-cache.dep.yml
generated
Normal file
30
.licenses/npm/@actions/tool-cache.dep.yml
generated
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: "@actions/tool-cache"
|
||||
version: 1.5.5
|
||||
type: npm
|
||||
summary: Actions tool-cache lib
|
||||
homepage: https://github.com/actions/toolkit/tree/master/packages/tool-cache
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: Auto-generated MIT license text
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
26
.licenses/npm/semver-6.3.0.dep.yml
generated
Normal file
26
.licenses/npm/semver-6.3.0.dep.yml
generated
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
name: semver
|
||||
version: 6.3.0
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage: https://github.com/npm/node-semver#readme
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
26
.licenses/npm/semver-7.1.3.dep.yml
generated
Normal file
26
.licenses/npm/semver-7.1.3.dep.yml
generated
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.1.3
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage: https://github.com/npm/node-semver#readme
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
35
.licenses/npm/tunnel.dep.yml
generated
Normal file
35
.licenses/npm/tunnel.dep.yml
generated
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
name: tunnel
|
||||
version: 0.0.6
|
||||
type: npm
|
||||
summary: Node HTTP/HTTPS Agents for tunneling proxies
|
||||
homepage: https://github.com/koichik/node-tunnel/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
- sources: README.md
|
||||
text: Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE)
|
||||
license.
|
||||
notices: []
|
39
.licenses/npm/uuid.dep.yml
generated
Normal file
39
.licenses/npm/uuid.dep.yml
generated
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
name: uuid
|
||||
version: 3.4.0
|
||||
type: npm
|
||||
summary: RFC4122 (v1, v4, and v5) UUIDs
|
||||
homepage: https://github.com/uuidjs/uuid#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices:
|
||||
- sources: AUTHORS
|
||||
text: |-
|
||||
Robert Kieffer <robert@broofa.com>
|
||||
Christoph Tavan <dev@tavan.de>
|
||||
AJ ONeal <coolaj86@gmail.com>
|
||||
Vincent Voyer <vincent@zeroload.net>
|
||||
Roman Shtylman <shtylman@gmail.com>
|
197
README.md
197
README.md
@ -1,4 +1,4 @@
|
||||
# setup-python
|
||||
# setup-python V2
|
||||
|
||||
<p align="left">
|
||||
<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>
|
||||
@ -6,8 +6,18 @@
|
||||
|
||||
This action sets up a Python environment for use in actions by:
|
||||
|
||||
- optionally installing a version of Python and adding to PATH. Note that this action only uses versions of Python already installed in the cache. The action will fail if no matching versions are found.
|
||||
- registering problem matchers for error output
|
||||
- optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
|
||||
- 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.
|
||||
- failing if a specific version of Python is not preinstalled or available for download.
|
||||
- registering problem matchers for error output.
|
||||
|
||||
# What's new
|
||||
|
||||
- Ability to download, install and set up Python packages from `actions/python-versions` that do not come preinstalled on runners.
|
||||
- Allows for pinning to a specific patch version of Python without the worry of it ever being removed or changed.
|
||||
- Automatic setup and download of Python packages if using a self-hosted runner.
|
||||
- Support for pre-release versions of Python.
|
||||
- Support for installing any version of PyPy on-flight
|
||||
|
||||
# Usage
|
||||
|
||||
@ -17,7 +27,7 @@ Basic:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v1
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
|
||||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||
@ -31,12 +41,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [ '2.x', '3.x', 'pypy2', 'pypy3' ]
|
||||
python-version: [ '2.x', '3.x', 'pypy-2.7', 'pypy-3.6', 'pypy-3.7' ]
|
||||
name: Python ${{ matrix.python-version }} sample
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
architecture: x64
|
||||
@ -51,7 +61,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3]
|
||||
python-version: [2.7, 3.6, 3.7, 3.8, pypy-2.7, pypy-3.6]
|
||||
exclude:
|
||||
- os: macos-latest
|
||||
python-version: 3.8
|
||||
@ -60,20 +70,105 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Display Python version
|
||||
run: python -c "import sys; print(sys.version)"
|
||||
```
|
||||
|
||||
Download and set up a version of Python that does not come preinstalled on an image:
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
# in this example, there is a newer version already installed, 3.7.7, so the older version will be downloaded
|
||||
python-version: [3.5, 3.6, 3.7.4, 3.8]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- run: python my_script.py
|
||||
```
|
||||
|
||||
Download and set up an accurate pre-release version of Python:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.0-beta.4'
|
||||
- run: python my_script.py
|
||||
```
|
||||
|
||||
Download and set up the latest available version of Python (includes both pre-release and stable versions):
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.0-alpha - 3.9.0' # SemVer's version range syntax
|
||||
- run: python my_script.py
|
||||
```
|
||||
|
||||
Download and set up PyPy:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version:
|
||||
- pypy-3.6 # the latest available version of PyPy that supports Python 3.6
|
||||
- pypy-3.7 # the latest available version of PyPy that supports Python 3.7
|
||||
- pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- run: python my_script.py
|
||||
```
|
||||
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.
|
||||
|
||||
# Getting started with Python + Actions
|
||||
|
||||
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).
|
||||
|
||||
# Available versions of Python
|
||||
|
||||
`setup-python` is able to configure Python from two sources:
|
||||
|
||||
- Preinstalled versions of Python in the tools cache on GitHub-hosted runners.
|
||||
- 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).
|
||||
- For every minor version of Python, expect only the latest patch to be preinstalled.
|
||||
- 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.
|
||||
- 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.
|
||||
- Downloadable Python versions from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)).
|
||||
- All available versions are listed in the [version-manifest.json](https://github.com/actions/python-versions/blob/main/versions-manifest.json) file.
|
||||
- If there is a specific version of Python that is not available, you can open an issue here
|
||||
|
||||
# Available versions of PyPy
|
||||
|
||||
`setup-python` is able to configure PyPy from two sources:
|
||||
|
||||
- Preinstalled versions of PyPy in the tools cache on GitHub-hosted runners
|
||||
- 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).
|
||||
- For the latest PyPy release, all versions of Python are cached.
|
||||
- Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy-3.6`, 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 `pypy-3.6-v7.3.3`.
|
||||
|
||||
- Downloadable PyPy versions from the [official PyPy site](https://downloads.python.org/pypy/).
|
||||
- All available versions that we can download are listed in [versions.json](https://downloads.python.org/pypy/versions.json) file.
|
||||
- PyPy < 7.3.3 are not available to install on-flight.
|
||||
- If some versions are not available, you can open an issue in https://foss.heptapod.net/pypy/pypy/
|
||||
|
||||
# Hosted Tool Cache
|
||||
|
||||
GitHub hosted runners have a tools cache that comes with 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.
|
||||
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.
|
||||
|
||||
|| Location |
|
||||
|------|-------|
|
||||
@ -82,38 +177,80 @@ GitHub hosted runners have a tools cache that comes with Python + PyPy already i
|
||||
|**PyPy Tool Cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
|
||||
|
||||
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.
|
||||
- [Tools cache setup for Ubuntu](https://github.com/actions/virtual-environments/blob/master/images/linux/scripts/installers/hosted-tool-cache.sh)
|
||||
- [Tools cache setup for Windows](https://github.com/actions/virtual-environments/blob/master/images/win/scripts/Installers/Download-ToolCache.ps1)
|
||||
- [Tools cache setup for Ubuntu](https://github.com/actions/virtual-environments/blob/main/images/linux/scripts/installers/hosted-tool-cache.sh)
|
||||
- [Tools cache setup for Windows](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Download-ToolCache.ps1)
|
||||
|
||||
# Specifying a Python version
|
||||
|
||||
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`)
|
||||
- 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.
|
||||
- MSI installers are used on Windows for this, so runs will take a little longer to set up vs Mac and Linux.
|
||||
|
||||
You should specify only a major and minor version if you are okay with the most recent patch version being used.
|
||||
- There will be a single patch version already installed on each runner for every minor version of Python that is supported.
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
# Specifying a PyPy version
|
||||
The version of PyPy should be specified in the format `pypy-<python_version>[-v<pypy_version>]`.
|
||||
The `<pypy_version>` parameter is optional and can be skipped. The latest version will be used in this case.
|
||||
|
||||
```
|
||||
pypy-3.6 # the latest available version of PyPy that supports Python 3.6
|
||||
pypy-3.7 # the latest available version of PyPy that supports Python 3.7
|
||||
pypy-2.7 # the latest available version of PyPy that supports Python 2.7
|
||||
pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
|
||||
pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
|
||||
pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
|
||||
pypy-3.7-nightly # Python 3.7 and nightly PyPy
|
||||
```
|
||||
|
||||
# Using `setup-python` with a self hosted runner
|
||||
|
||||
If you would like to use `setup-python` on a self-hosted runner, you will need to download all versions of Python & PyPy that you would like and setup a similar tools cache locally for your runner.
|
||||
Python distributions are only available for the same [environments](https://github.com/actions/virtual-environments#available-environments) that GitHub Actions hosted environments are available for. If you are using an unsupported version of Ubuntu such as `19.04` or another Linux distribution such as Fedora, `setup-python` will not work. If you have a supported self-hosted runner and you would like to use `setup-python`, there are a few extra things you need to make sure are set up so that new versions of Python can be downloaded and configured on your runner.
|
||||
|
||||
If you are experiencing problems while configuring Python on your self-hosted runner, turn on [step debugging](https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs) to see addition logs.
|
||||
|
||||
### Windows
|
||||
|
||||
- Your runner needs to be running with administrator privileges so that the appropriate directories and files can be set up when downloading and installing a new version of Python for the first time.
|
||||
- If your runner is configured as a service, make sure the account that is running the service has the appropriate write permissions so that Python can get installed. The default `NT AUTHORITY\NETWORK SERVICE` should be sufficient.
|
||||
- You need `7zip` installed and added to your `PATH` so that the downloaded versions of Python files can be extracted properly during first-time setup.
|
||||
- MSI installers are used when setting up Python on Windows. A word of caution as MSI installers update registry settings.
|
||||
- The 3.8 MSI installer for Windows will not let you install another 3.8 version of Python. If `setup-python` fails for a 3.8 version of Python, make sure any previously installed versions are removed by going to "Apps & Features" in the Settings app.
|
||||
|
||||
### Linux
|
||||
|
||||
- The Python packages that are downloaded from `actions/python-versions` are originally compiled from source in `/opt/hostedtoolcache/` with the [--enable-shared](https://github.com/actions/python-versions/blob/94f04ae6806c6633c82db94c6406a16e17decd5c/builders/ubuntu-python-builder.psm1#L35) flag, which makes them non-relocatable.
|
||||
- Create an environment variable called `AGENT_TOOLSDIRECTORY` and set it to `/opt/hostedtoolcache`. This controls where the runner downloads and installs tools.
|
||||
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`.
|
||||
- A more permanent way of setting the environment variable is to create a `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`. This ensures the variable is always set if your runner is configured as a service.
|
||||
- Create a directory called `hostedtoolcache` inside `/opt`.
|
||||
- The user starting the runner must have write permission to the `/opt/hostedtoolcache` directory. It is not possible to start the Linux runner with `sudo` and the `/opt` directory usually requires root privileges to write to. Check the current user and group that the runner belongs to by typing `ls -l` inside the runners root directory.
|
||||
- The runner can be granted write access to the `/opt/hostedtoolcache` directory using a few techniques:
|
||||
- The user starting the runner is the owner, and the owner has write permission.
|
||||
- The user starting the runner is in the owning group, and the owning group has write permission.
|
||||
- All users have write permission.
|
||||
- One quick way to grant access is to change the user and group of `/opt/hostedtoolcache` to be the same as the runners using `chown`.
|
||||
- `sudo chown runner-user:runner-group opt/hostedtoolcache/`.
|
||||
- If your runner is configured as a service and you run into problems, make sure the user that the service is running as is correct. For more information, you can [check the status of your self-hosted runner](https://help.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service#checking-the-status-of-the-service).
|
||||
|
||||
### Mac
|
||||
|
||||
- The same setup that applies to `Linux` also applies to `Mac`, just with a different tools cache directory.
|
||||
- Create a directory called `/Users/runner/hostedtoolcache`.
|
||||
- Set the `AGENT_TOOLSDIRECTORY` environment variable to `/Users/runner/hostedtoolcache`.
|
||||
- Change the permissions of `/Users/runner/hostedtoolcache` so that the runner has write access.
|
||||
|
||||
- Create an global environment variable called `AGENT_TOOLSDIRECTORY` that will point to the root directory of where you want the tools installed. The env variable is preferrably global as it must be set in the shell that will install the tools cache, along with the shell that the runner will be using.
|
||||
- This env variable is used internally by the runner to set the `RUNNER_TOOL_CACHE` env variable
|
||||
- Example for Administrator Powershell: `[System.Environment]::SetEnvironmentVariable("AGENT_TOOLSDIRECTORY", "C:\hostedtoolcache\windows", [System.EnvironmentVariableTarget]::Machine)` (restart the shell afterwards)
|
||||
- Download the appropriate NPM packages from the [GitHub Actions NPM registry](https://github.com/orgs/actions/packages)
|
||||
- Make sure to have `npm` installed, and then [configure npm for use with GitHub packages](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#authenticating-to-github-package-registry)
|
||||
- Create an empty npm project for easier installation (`npm init`) in the tools cache directory. You can delete `package.json`, `package.lock.json` and `node_modules` after all tools get installed
|
||||
- Before downloading a specific package, create an empty folder for the version of Python/PyPY that is being installed. If downloading Python 3.6.8 for example, create `C:\hostedtoolcache\windows\Python\3.6.8`
|
||||
- Once configured, download a specific package by calling `npm install`. Note (if downloading a PyPy package on Windows, you will need 7zip installed along with `7z.exe` added to your PATH)
|
||||
- Each NPM package has multiple versions that determine the version of Python or PyPy that should be installed.
|
||||
- `npm install @actions/toolcache-python-windows-x64@3.7.61579791175` for example installs Python 3.7.6 while `npm install @actions/toolcache-python-windows-x64@3.6.81579791177` installs Python 3.6.8
|
||||
- You can browse and find all available versions of a package by searching the GitHub Actions NPM registry
|
||||

|
||||
|
||||
# Using Python without `setup-python`
|
||||
|
||||
`setup-python` helps keep your dependencies explicit and ensures consistent behavior between different runners. If you use `python` in a shell on a GitHub hosted runner without `setup-python` it will default to whatever is in PATH. The default version of Python in PATH vary between runners and can change unexpectedly so we recommend you always use `setup-python`.
|
||||
|
||||
# Available versions of Python
|
||||
|
||||
For detailed information regarding the available versions of Python that are installed see [Software installed on GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners)
|
||||
|
||||
# License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||
|
||||
# Contributions
|
||||
|
||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
Contributions are welcome! See our [Contributor's Guide](docs/contributors.md).
|
||||
|
494
__tests__/data/pypy.json
Normal file
494
__tests__/data/pypy.json
Normal file
@ -0,0 +1,494 @@
|
||||
[
|
||||
{
|
||||
"pypy_version": "7.3.3",
|
||||
"python_version": "3.6.12",
|
||||
"stable": true,
|
||||
"latest_pypy": true,
|
||||
"date": "2020-11-21",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-darwin64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-darwin64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.3rc1",
|
||||
"python_version": "3.6.12",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"date": "2020-11-11",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3rc1-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-linux32rc1.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3rc1-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3rc1-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3-win32rc1.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.3rc1-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.3rc1-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.3rc2",
|
||||
"python_version": "3.7.7",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"date": "2020-11-11",
|
||||
"files": [
|
||||
{
|
||||
"filename": "test.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "test.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "test.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "test.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "test.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "test.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "test.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "test.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "test.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "test.zip"
|
||||
},
|
||||
{
|
||||
"filename": "test.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "test.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.3",
|
||||
"python_version": "3.7.9",
|
||||
"stable": true,
|
||||
"latest_pypy": true,
|
||||
"date": "2020-11-21",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.3-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.3-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.3",
|
||||
"python_version": "2.7.18",
|
||||
"stable": true,
|
||||
"latest_pypy": true,
|
||||
"date": "2020-11-21",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.3-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.3-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.2",
|
||||
"python_version": "3.6.9",
|
||||
"stable": true,
|
||||
"latest_pypy": true,
|
||||
"date": "2020-09-25",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.3.2-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.3.2-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.2",
|
||||
"python_version": "3.7.9",
|
||||
"stable": true,
|
||||
"latest_pypy": false,
|
||||
"date": "2020-09-25",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.7-v7.3.2-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.7-v7.3.2-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.2",
|
||||
"python_version": "2.7.13",
|
||||
"stable": true,
|
||||
"latest_pypy": true,
|
||||
"date": "2020-09-25",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-osx64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-osx64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy2.7-v7.3.2-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy2.7-v7.3.2-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "nightly",
|
||||
"python_version": "2.7",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"files": [
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "http://nightlyBuilds.org/filename.zip"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "nightly",
|
||||
"python_version": "3.7",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"files": [
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "http://nightlyBuilds.org/filename.zip"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "nightly",
|
||||
"python_version": "3.6",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"files": [
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "filename.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "http://nightlyBuilds.org/filename.zip"
|
||||
},
|
||||
{
|
||||
"filename": "filename.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "http://nightlyBuilds.org/filename.tar.bz2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
52
__tests__/data/versions-manifest.json
Normal file
52
__tests__/data/versions-manifest.json
Normal file
@ -0,0 +1,52 @@
|
||||
[
|
||||
{
|
||||
"version": "1.2.3",
|
||||
"stable": true,
|
||||
"release_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6",
|
||||
"files": [
|
||||
{
|
||||
"filename": "sometool-1.2.3-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6/sometool-1.2.3-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-darwin-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6/sometool-1.2.3-darwin-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-win32-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.6/sometool-1.2.3-win32-x64.tar.gz"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.2.3-beta.2",
|
||||
"stable": false,
|
||||
"release_url": "https://github.com/actions/sometool/releases/tag/1.2.3-beta.2-20200402.5",
|
||||
"files": [
|
||||
{
|
||||
"filename": "sometool-1.2.3-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-beta.2-20200402.5/sometool-1.2.3-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-darwin-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.5/sometool-1.2.3-darwin-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-win32-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.5/sometool-1.2.3-win32-x64.tar.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
237
__tests__/find-pypy.test.ts
Normal file
237
__tests__/find-pypy.test.ts
Normal file
@ -0,0 +1,237 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import * as utils from '../src/utils';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import * as ifm from '@actions/http-client/interfaces';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import * as finder from '../src/find-pypy';
|
||||
import {
|
||||
IPyPyManifestRelease,
|
||||
IS_WINDOWS,
|
||||
validateVersion,
|
||||
getPyPyVersionFromPath
|
||||
} from '../src/utils';
|
||||
|
||||
const manifestData = require('./data/pypy.json');
|
||||
|
||||
let architecture: string;
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
architecture = 'x86';
|
||||
} else {
|
||||
architecture = 'x64';
|
||||
}
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
|
||||
describe('parsePyPyVersion', () => {
|
||||
it.each([
|
||||
['pypy-3.6-v7.3.3', {pythonVersion: '3.6', pypyVersion: 'v7.3.3'}],
|
||||
['pypy-3.6-v7.3.x', {pythonVersion: '3.6', pypyVersion: 'v7.3.x'}],
|
||||
['pypy-3.6-v7.x', {pythonVersion: '3.6', pypyVersion: 'v7.x'}],
|
||||
['pypy-3.6', {pythonVersion: '3.6', pypyVersion: 'x'}],
|
||||
['pypy-3.6-nightly', {pythonVersion: '3.6', pypyVersion: 'nightly'}],
|
||||
['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
expect(finder.parsePyPyVersion(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('throw on invalid input', () => {
|
||||
expect(() => finder.parsePyPyVersion('pypy-')).toThrowError(
|
||||
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPyPyVersionFromPath', () => {
|
||||
it('/fake/toolcache/PyPy/3.6.5/x64 -> 3.6.5', () => {
|
||||
expect(getPyPyVersionFromPath('/fake/toolcache/PyPy/3.6.5/x64')).toEqual(
|
||||
'3.6.5'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPyPyToolCache', () => {
|
||||
const actualPythonVersion = '3.6.17';
|
||||
const actualPyPyVersion = '7.5.4';
|
||||
const pypyPath = path.join('PyPy', actualPythonVersion, architecture);
|
||||
let tcFind: jest.SpyInstance;
|
||||
let spyReadExactPyPyVersion: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
tcFind = jest.spyOn(tc, 'find');
|
||||
tcFind.mockImplementation((toolname: string, pythonVersion: string) => {
|
||||
const semverVersion = new semver.Range(pythonVersion);
|
||||
return semver.satisfies(actualPythonVersion, semverVersion)
|
||||
? pypyPath
|
||||
: '';
|
||||
});
|
||||
|
||||
spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile');
|
||||
spyReadExactPyPyVersion.mockImplementation(() => actualPyPyVersion);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('PyPy exists on the path and versions are satisfied', () => {
|
||||
expect(finder.findPyPyToolCache('3.6.17', 'v7.5.4', architecture)).toEqual({
|
||||
installDir: pypyPath,
|
||||
resolvedPythonVersion: actualPythonVersion,
|
||||
resolvedPyPyVersion: actualPyPyVersion
|
||||
});
|
||||
});
|
||||
|
||||
it('PyPy exists on the path and versions are satisfied with semver', () => {
|
||||
expect(finder.findPyPyToolCache('3.6', 'v7.5.x', architecture)).toEqual({
|
||||
installDir: pypyPath,
|
||||
resolvedPythonVersion: actualPythonVersion,
|
||||
resolvedPyPyVersion: actualPyPyVersion
|
||||
});
|
||||
});
|
||||
|
||||
it("PyPy exists on the path, but Python version doesn't match", () => {
|
||||
expect(finder.findPyPyToolCache('3.7', 'v7.5.4', architecture)).toEqual({
|
||||
installDir: '',
|
||||
resolvedPythonVersion: '',
|
||||
resolvedPyPyVersion: ''
|
||||
});
|
||||
});
|
||||
|
||||
it("PyPy exists on the path, but PyPy version doesn't match", () => {
|
||||
expect(finder.findPyPyToolCache('3.6', 'v7.5.1', architecture)).toEqual({
|
||||
installDir: null,
|
||||
resolvedPythonVersion: '',
|
||||
resolvedPyPyVersion: ''
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPyPyVersion', () => {
|
||||
let tcFind: jest.SpyInstance;
|
||||
let spyExtractZip: jest.SpyInstance;
|
||||
let spyExtractTar: jest.SpyInstance;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyExistsSync: jest.SpyInstance;
|
||||
let spyExec: jest.SpyInstance;
|
||||
let spySymlinkSync: jest.SpyInstance;
|
||||
let spyDownloadTool: jest.SpyInstance;
|
||||
let spyReadExactPyPyVersion: jest.SpyInstance;
|
||||
let spyFsReadDir: jest.SpyInstance;
|
||||
let spyWriteExactPyPyVersionFile: jest.SpyInstance;
|
||||
let spyCacheDir: jest.SpyInstance;
|
||||
let spyChmodSync: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
tcFind = jest.spyOn(tc, 'find');
|
||||
tcFind.mockImplementation((tool: string, version: string) => {
|
||||
const semverRange = new semver.Range(version);
|
||||
let pypyPath = '';
|
||||
if (semver.satisfies('3.6.12', semverRange)) {
|
||||
pypyPath = path.join(toolDir, 'PyPy', '3.6.12', architecture);
|
||||
}
|
||||
return pypyPath;
|
||||
});
|
||||
|
||||
spyWriteExactPyPyVersionFile = jest.spyOn(
|
||||
utils,
|
||||
'writeExactPyPyVersionFile'
|
||||
);
|
||||
spyWriteExactPyPyVersionFile.mockImplementation(() => null);
|
||||
|
||||
spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile');
|
||||
spyReadExactPyPyVersion.mockImplementation(() => '7.3.3');
|
||||
|
||||
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
|
||||
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'PyPy'));
|
||||
|
||||
spyExtractZip = jest.spyOn(tc, 'extractZip');
|
||||
spyExtractZip.mockImplementation(() => tempDir);
|
||||
|
||||
spyExtractTar = jest.spyOn(tc, 'extractTar');
|
||||
spyExtractTar.mockImplementation(() => tempDir);
|
||||
|
||||
spyFsReadDir = jest.spyOn(fs, 'readdirSync');
|
||||
spyFsReadDir.mockImplementation((directory: string) => ['PyPyTest']);
|
||||
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockImplementation(
|
||||
async (): Promise<ifm.ITypedResponse<IPyPyManifestRelease[]>> => {
|
||||
const result = JSON.stringify(manifestData);
|
||||
return {
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: JSON.parse(result) as IPyPyManifestRelease[]
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
spyExec = jest.spyOn(exec, 'exec');
|
||||
spyExec.mockImplementation(() => undefined);
|
||||
|
||||
spySymlinkSync = jest.spyOn(fs, 'symlinkSync');
|
||||
spySymlinkSync.mockImplementation(() => undefined);
|
||||
|
||||
spyExistsSync = jest.spyOn(fs, 'existsSync');
|
||||
spyExistsSync.mockReturnValue(true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('found PyPy in toolcache', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
});
|
||||
});
|
||||
|
||||
it('throw on invalid input format', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('throw on invalid input format pypy3.7-7.3.x', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('found and install successfully', async () => {
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(() =>
|
||||
path.join(toolDir, 'PyPy', '3.7.7', architecture)
|
||||
);
|
||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.7.9',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
});
|
||||
});
|
||||
|
||||
it('throw if release is not found', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture)
|
||||
).rejects.toThrowError(
|
||||
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
|
||||
);
|
||||
});
|
||||
});
|
@ -18,19 +18,67 @@ const tempDir = path.join(
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as finder from '../src/find-python';
|
||||
import * as installer from '../src/install-python';
|
||||
|
||||
const manifestData = require('./data/versions-manifest.json');
|
||||
|
||||
describe('Finder tests', () => {
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('Finds Python if it is installed', async () => {
|
||||
const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64');
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('3.x', 'x64');
|
||||
});
|
||||
|
||||
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
||||
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
|
||||
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
|
||||
|
||||
const installSpy: jest.SpyInstance = jest.spyOn(
|
||||
installer,
|
||||
'installCpythonFromRelease'
|
||||
);
|
||||
installSpy.mockImplementation(async () => {
|
||||
const pythonDir: string = path.join(toolDir, 'Python', '1.2.3', 'x64');
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('1.2.3', 'x64');
|
||||
});
|
||||
|
||||
it('Finds pre-release Python version in the manifest', async () => {
|
||||
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
|
||||
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
|
||||
|
||||
const installSpy: jest.SpyInstance = jest.spyOn(
|
||||
installer,
|
||||
'installCpythonFromRelease'
|
||||
);
|
||||
installSpy.mockImplementation(async () => {
|
||||
const pythonDir: string = path.join(
|
||||
toolDir,
|
||||
'Python',
|
||||
'1.2.3-beta.2',
|
||||
'x64'
|
||||
);
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
||||
await finder.findPythonVersion('1.2.3-beta.2', 'x64');
|
||||
});
|
||||
|
||||
it('Errors if Python is not installed', async () => {
|
||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
let thrown = false;
|
||||
try {
|
||||
await finder.findPythonVersion('3.300000', 'x64');
|
||||
|
230
__tests__/install-pypy.test.ts
Normal file
230
__tests__/install-pypy.test.ts
Normal file
@ -0,0 +1,230 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import * as ifm from '@actions/http-client/interfaces';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as installer from '../src/install-pypy';
|
||||
import {
|
||||
IPyPyManifestRelease,
|
||||
IPyPyManifestAsset,
|
||||
IS_WINDOWS
|
||||
} from '../src/utils';
|
||||
|
||||
const manifestData = require('./data/pypy.json');
|
||||
|
||||
let architecture: string;
|
||||
if (IS_WINDOWS) {
|
||||
architecture = 'x86';
|
||||
} else {
|
||||
architecture = 'x64';
|
||||
}
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
|
||||
describe('pypyVersionToSemantic', () => {
|
||||
it.each([
|
||||
['7.3.3rc1', '7.3.3-rc.1'],
|
||||
['7.3.3', '7.3.3'],
|
||||
['7.3.x', '7.3.x'],
|
||||
['7.x', '7.x'],
|
||||
['nightly', 'nightly']
|
||||
])('%s -> %s', (input, expected) => {
|
||||
expect(installer.pypyVersionToSemantic(input)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findRelease', () => {
|
||||
const result = JSON.stringify(manifestData);
|
||||
const releases = JSON.parse(result) as IPyPyManifestRelease[];
|
||||
const extension = IS_WINDOWS ? '.zip' : '.tar.bz2';
|
||||
const extensionName = IS_WINDOWS
|
||||
? `${process.platform}${extension}`
|
||||
: `${process.platform}64${extension}`;
|
||||
const files: IPyPyManifestAsset = {
|
||||
filename: `pypy3.6-v7.3.3-${extensionName}`,
|
||||
arch: architecture,
|
||||
platform: process.platform,
|
||||
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}`
|
||||
};
|
||||
|
||||
it("Python version is found, but PyPy version doesn't match", () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.3.7';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual(null);
|
||||
});
|
||||
|
||||
it('Python version is found and PyPy version matches', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.3.3';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: pypyVersion
|
||||
});
|
||||
});
|
||||
|
||||
it('Python version is found in toolcache and PyPy version matches semver', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.x';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
});
|
||||
});
|
||||
|
||||
it('Python and preview version of PyPy are found', () => {
|
||||
const pythonVersion = '3.7';
|
||||
const pypyVersion = installer.pypyVersionToSemantic('7.3.3rc2');
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual({
|
||||
foundAsset: {
|
||||
filename: `test${extension}`,
|
||||
arch: architecture,
|
||||
platform: process.platform,
|
||||
download_url: `test${extension}`
|
||||
},
|
||||
resolvedPythonVersion: '3.7.7',
|
||||
resolvedPyPyVersion: '7.3.3rc2'
|
||||
});
|
||||
});
|
||||
|
||||
it('Python version with latest PyPy is found', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = 'x';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
});
|
||||
});
|
||||
|
||||
it('Nightly release is found', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = 'nightly';
|
||||
const filename = IS_WINDOWS ? 'filename.zip' : 'filename.tar.bz2';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
).toEqual({
|
||||
foundAsset: {
|
||||
filename: filename,
|
||||
arch: architecture,
|
||||
platform: process.platform,
|
||||
download_url: `http://nightlyBuilds.org/${filename}`
|
||||
},
|
||||
resolvedPythonVersion: '3.6',
|
||||
resolvedPyPyVersion: pypyVersion
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('installPyPy', () => {
|
||||
let tcFind: jest.SpyInstance;
|
||||
let spyExtractZip: jest.SpyInstance;
|
||||
let spyExtractTar: jest.SpyInstance;
|
||||
let spyFsReadDir: jest.SpyInstance;
|
||||
let spyFsWriteFile: jest.SpyInstance;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyExistsSync: jest.SpyInstance;
|
||||
let spyExec: jest.SpyInstance;
|
||||
let spySymlinkSync: jest.SpyInstance;
|
||||
let spyDownloadTool: jest.SpyInstance;
|
||||
let spyCacheDir: jest.SpyInstance;
|
||||
let spyChmodSync: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
tcFind = jest.spyOn(tc, 'find');
|
||||
tcFind.mockImplementation(() => path.join('PyPy', '3.6.12', architecture));
|
||||
|
||||
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
|
||||
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'PyPy'));
|
||||
|
||||
spyExtractZip = jest.spyOn(tc, 'extractZip');
|
||||
spyExtractZip.mockImplementation(() => tempDir);
|
||||
|
||||
spyExtractTar = jest.spyOn(tc, 'extractTar');
|
||||
spyExtractTar.mockImplementation(() => tempDir);
|
||||
|
||||
spyFsReadDir = jest.spyOn(fs, 'readdirSync');
|
||||
spyFsReadDir.mockImplementation(() => ['PyPyTest']);
|
||||
|
||||
spyFsWriteFile = jest.spyOn(fs, 'writeFileSync');
|
||||
spyFsWriteFile.mockImplementation(() => undefined);
|
||||
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockImplementation(
|
||||
async (): Promise<ifm.ITypedResponse<IPyPyManifestRelease[]>> => {
|
||||
const result = JSON.stringify(manifestData);
|
||||
return {
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: JSON.parse(result) as IPyPyManifestRelease[]
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
spyExec = jest.spyOn(exec, 'exec');
|
||||
spyExec.mockImplementation(() => undefined);
|
||||
|
||||
spySymlinkSync = jest.spyOn(fs, 'symlinkSync');
|
||||
spySymlinkSync.mockImplementation(() => undefined);
|
||||
|
||||
spyExistsSync = jest.spyOn(fs, 'existsSync');
|
||||
spyExistsSync.mockImplementation(() => false);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('throw if release is not found', async () => {
|
||||
await expect(
|
||||
installer.installPyPy('7.3.3', '3.6.17', architecture)
|
||||
).rejects.toThrowError(
|
||||
`PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found`
|
||||
);
|
||||
|
||||
expect(spyHttpClient).toHaveBeenCalled();
|
||||
expect(spyDownloadTool).not.toHaveBeenCalled();
|
||||
expect(spyExec).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('found and install PyPy', async () => {
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(() =>
|
||||
path.join(toolDir, 'PyPy', '3.6.12', architecture)
|
||||
);
|
||||
|
||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
|
||||
await expect(
|
||||
installer.installPyPy('7.3.x', '3.6.12', architecture)
|
||||
).resolves.toEqual({
|
||||
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
});
|
||||
|
||||
expect(spyHttpClient).toHaveBeenCalled();
|
||||
expect(spyDownloadTool).toHaveBeenCalled();
|
||||
expect(spyExistsSync).toHaveBeenCalled();
|
||||
expect(spyCacheDir).toHaveBeenCalled();
|
||||
expect(spyExec).toHaveBeenCalled();
|
||||
});
|
||||
});
|
34
__tests__/utils.test.ts
Normal file
34
__tests__/utils.test.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import {
|
||||
validateVersion,
|
||||
validatePythonVersionFormatForPyPy
|
||||
} from '../src/utils';
|
||||
|
||||
describe('validatePythonVersionFormatForPyPy', () => {
|
||||
it.each([
|
||||
['3.6', true],
|
||||
['3.7', true],
|
||||
['3.6.x', false],
|
||||
['3.7.x', false],
|
||||
['3.x', false],
|
||||
['3', false]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
expect(validatePythonVersionFormatForPyPy(input)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateVersion', () => {
|
||||
it.each([
|
||||
['v7.3.3', true],
|
||||
['v7.3.x', true],
|
||||
['v7.x', true],
|
||||
['x', true],
|
||||
['v7.3.3-rc.1', true],
|
||||
['nightly', true],
|
||||
['v7.3.b', false],
|
||||
['3.6', true],
|
||||
['3.b', false],
|
||||
['3', true]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
expect(validateVersion(input)).toEqual(expected);
|
||||
});
|
||||
});
|
22
__tests__/verify-python.py
Normal file
22
__tests__/verify-python.py
Normal file
@ -0,0 +1,22 @@
|
||||
import sys
|
||||
argCount = len(sys.argv) - 1
|
||||
|
||||
if argCount == 1:
|
||||
expectedVersion = sys.argv[1]
|
||||
versions = len(expectedVersion.split("."))
|
||||
majorMinor = str(sys.version_info[0]) + '.' + str(sys.version_info[1])
|
||||
|
||||
if versions == 2:
|
||||
# Test only major and minor version
|
||||
if expectedVersion != majorMinor:
|
||||
raise Exception("Incorrect major + minor version detected\nExpected: " + expectedVersion + "\nActual: " + majorMinor)
|
||||
elif versions == 3:
|
||||
# Test major, minor and micro version
|
||||
majorMinorMicro = majorMinor + '.' + str(sys.version_info[2])
|
||||
if expectedVersion != majorMinorMicro:
|
||||
raise Exception("Incorrect major + minor + micro version detected\nExpected: " + expectedVersion + "\nActual: " + majorMinorMicro)
|
||||
else:
|
||||
raise Exception("Incorrect number of arguments supplied")
|
||||
print("Correct version of Python " + expectedVersion + " detected")
|
||||
else:
|
||||
raise Exception("Incorrect number of arguments supplied")
|
@ -8,7 +8,9 @@ inputs:
|
||||
default: '3.x'
|
||||
architecture:
|
||||
description: 'The target architecture (x86, x64) of the Python interpreter.'
|
||||
default: 'x64'
|
||||
token:
|
||||
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
||||
default: ${{ github.token }}
|
||||
outputs:
|
||||
python-version:
|
||||
description: "The installed python version. Useful when given a version range as input."
|
||||
|
2903
dist/index.js
vendored
2903
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -8,24 +8,30 @@
|
||||
|
||||
### NCC
|
||||
|
||||
In order to avoid uploading `node_modules/` to the repository, we use [zeit/ncc](https://github.com/zeit/ncc) to create a single `index.js` file that gets saved in `dist/`.
|
||||
In order to avoid uploading `node_modules/` to the repository, we use [vercel/ncc](https://github.com/vercel/ncc) to create a single `index.js` file that gets saved in `dist/`.
|
||||
|
||||
### Developing
|
||||
|
||||
If you're developing locally, you can run
|
||||
```
|
||||
|
||||
```sh
|
||||
npm install
|
||||
tsc
|
||||
ncc build
|
||||
ncc build src/setup-python.ts
|
||||
```
|
||||
Any files generated using `tsc` will be added to `lib/`, however those files also are not uploaded to the repository and are exluded using `.gitignore`.
|
||||
|
||||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier)
|
||||
Any files generated using `tsc` will be added to `lib/`, however those files also are not uploaded to the repository and are excluded using `.gitignore`.
|
||||
|
||||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) (to run manually, use `npm run format`).
|
||||
|
||||
### Testing
|
||||
|
||||
We ask that you include a link to a successful run that utilizes the changes you are working on. For example, if your changes are in the branch `newAwesomeFeature`, then show an example run that uses `setup-python@newAwesomeFeature` or `my-fork@newAwesomeFeature`. This will help speed up testing and help us confirm that there are no breaking changes or bugs.
|
||||
|
||||
### Licensed
|
||||
|
||||
This repository uses a tool called [Licensed](https://github.com/github/licensed) to verify third party dependencies. You may need to locally install licensed and run `licensed cache` to update the dependency cache if you install or update a production dependency. If licensed cache is unable to determine the dependency, you may need to modify the cache file yourself to put the correct license. You should still verify the dependency, licensed is a tool to help, but is not a substitute for human review of dependencies.
|
||||
|
||||
### Releases
|
||||
|
||||
There is a `master` branch where contributor changes are merged into. There are also release branches such as `releases/v1` that are used for tagging (for example the `v1` tag) and publishing new versions of the action. Changes from `master` are periodically merged into a releases branch. You do not need to create any PR that merges changes from master into a releases branch.
|
||||
|
67
package-lock.json
generated
67
package-lock.json
generated
@ -1,47 +1,26 @@
|
||||
{
|
||||
"name": "setup-python",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/http-client": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
|
||||
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
|
||||
"requires": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
}
|
||||
}
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||
},
|
||||
"@actions/exec": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.3.tgz",
|
||||
"integrity": "sha512-TogJGnueOmM7ntCi0ASTUj4LapRRtDfj57Ja4IhPmg2fls28uVOPbAn8N+JifaOumN2UG3oEO/Ixek2A4NcYSA==",
|
||||
"dev": true,
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
|
||||
"integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
|
||||
"requires": {
|
||||
"@actions/io": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"@actions/http-client": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.6.tgz",
|
||||
"integrity": "sha512-LGmio4w98UyGX33b/W6V6Nx/sQHRXZ859YlMkn36wPsXPB82u8xTVlA/Dq2DXrm6lEq9RVmisRJa1c+HETAIJA==",
|
||||
"dev": true,
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz",
|
||||
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==",
|
||||
"requires": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
@ -49,18 +28,16 @@
|
||||
"@actions/io": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz",
|
||||
"integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg=="
|
||||
},
|
||||
"@actions/tool-cache": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.3.3.tgz",
|
||||
"integrity": "sha512-AFVyTLcIxusDVI1gMhbZW8m/On7YNJG+xYaxorV+qic+f7lO7h37aT2mfzxqAq7mwHxtP1YlVFNrXe9QDf/bPg==",
|
||||
"dev": true,
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.5.5.tgz",
|
||||
"integrity": "sha512-y/YO37BOaXzOEHpvoGZDLCwvg6XZWQ7Ala4Np4xzrKD1r48mff+K/GAmzXMejnApU7kgqC6lL/aCKTZDCrhdmw==",
|
||||
"requires": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@actions/core": "^1.2.3",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/http-client": "^1.0.3",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/io": "^1.0.1",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.2"
|
||||
@ -69,8 +46,7 @@
|
||||
"semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -3049,9 +3025,9 @@
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
|
||||
"version": "4.17.19",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
|
||||
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
|
||||
"dev": true
|
||||
},
|
||||
"lodash.memoize": {
|
||||
@ -4703,8 +4679,7 @@
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
},
|
||||
"v8-to-istanbul": {
|
||||
"version": "4.1.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-python",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.1",
|
||||
"private": true,
|
||||
"description": "Setup python action",
|
||||
"main": "dist/index.js",
|
||||
@ -23,12 +23,12 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/core": "^1.2.3",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.5.5",
|
||||
"semver": "^7.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.3.3",
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^12.12.31",
|
||||
"@types/semver": "^7.1.0",
|
||||
|
131
src/find-pypy.ts
Normal file
131
src/find-pypy.ts
Normal file
@ -0,0 +1,131 @@
|
||||
import * as path from 'path';
|
||||
import * as pypyInstall from './install-pypy';
|
||||
import {
|
||||
IS_WINDOWS,
|
||||
validateVersion,
|
||||
getPyPyVersionFromPath,
|
||||
readExactPyPyVersionFile,
|
||||
validatePythonVersionFormatForPyPy
|
||||
} from './utils';
|
||||
|
||||
import * as semver from 'semver';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
interface IPyPyVersionSpec {
|
||||
pypyVersion: string;
|
||||
pythonVersion: string;
|
||||
}
|
||||
|
||||
export async function findPyPyVersion(
|
||||
versionSpec: string,
|
||||
architecture: string
|
||||
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
|
||||
let resolvedPyPyVersion = '';
|
||||
let resolvedPythonVersion = '';
|
||||
let installDir: string | null;
|
||||
|
||||
const pypyVersionSpec = parsePyPyVersion(versionSpec);
|
||||
|
||||
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
|
||||
if (IS_WINDOWS && architecture === 'x64') {
|
||||
architecture = 'x86';
|
||||
}
|
||||
|
||||
({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache(
|
||||
pypyVersionSpec.pythonVersion,
|
||||
pypyVersionSpec.pypyVersion,
|
||||
architecture
|
||||
));
|
||||
|
||||
if (!installDir) {
|
||||
({
|
||||
installDir,
|
||||
resolvedPythonVersion,
|
||||
resolvedPyPyVersion
|
||||
} = await pypyInstall.installPyPy(
|
||||
pypyVersionSpec.pypyVersion,
|
||||
pypyVersionSpec.pythonVersion,
|
||||
architecture
|
||||
));
|
||||
}
|
||||
|
||||
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
|
||||
const _binDir = path.join(installDir, pipDir);
|
||||
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
||||
core.exportVariable('pythonLocation', pythonLocation);
|
||||
core.addPath(pythonLocation);
|
||||
core.addPath(_binDir);
|
||||
|
||||
return {resolvedPyPyVersion, resolvedPythonVersion};
|
||||
}
|
||||
|
||||
export function findPyPyToolCache(
|
||||
pythonVersion: string,
|
||||
pypyVersion: string,
|
||||
architecture: string
|
||||
) {
|
||||
let resolvedPyPyVersion = '';
|
||||
let resolvedPythonVersion = '';
|
||||
let installDir: string | null = tc.find('PyPy', pythonVersion, architecture);
|
||||
|
||||
if (installDir) {
|
||||
// 'tc.find' finds tool based on Python version but we also need to check
|
||||
// whether PyPy version satisfies requested version.
|
||||
resolvedPythonVersion = getPyPyVersionFromPath(installDir);
|
||||
resolvedPyPyVersion = readExactPyPyVersionFile(installDir);
|
||||
|
||||
const isPyPyVersionSatisfies = semver.satisfies(
|
||||
resolvedPyPyVersion,
|
||||
pypyVersion
|
||||
);
|
||||
if (!isPyPyVersionSatisfies) {
|
||||
installDir = null;
|
||||
resolvedPyPyVersion = '';
|
||||
resolvedPythonVersion = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!installDir) {
|
||||
core.info(
|
||||
`PyPy version ${pythonVersion} (${pypyVersion}) was not found in the local cache`
|
||||
);
|
||||
}
|
||||
|
||||
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
|
||||
}
|
||||
|
||||
export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
|
||||
const versions = versionSpec.split('-').filter(item => !!item);
|
||||
|
||||
if (versions.length < 2 || versions[0] != 'pypy') {
|
||||
throw new Error(
|
||||
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
|
||||
);
|
||||
}
|
||||
|
||||
const pythonVersion = versions[1];
|
||||
let pypyVersion: string;
|
||||
if (versions.length > 2) {
|
||||
pypyVersion = pypyInstall.pypyVersionToSemantic(versions[2]);
|
||||
} else {
|
||||
pypyVersion = 'x';
|
||||
}
|
||||
|
||||
if (!validateVersion(pythonVersion) || !validateVersion(pypyVersion)) {
|
||||
throw new Error(
|
||||
"Invalid 'version' property for PyPy. Both Python version and PyPy versions should satisfy SemVer notation. See README for examples and documentation."
|
||||
);
|
||||
}
|
||||
|
||||
if (!validatePythonVersionFormatForPyPy(pythonVersion)) {
|
||||
throw new Error(
|
||||
"Invalid format of Python version for PyPy. Python version should be specified in format 'x.y'. See README for examples and documentation."
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
pypyVersion: pypyVersion,
|
||||
pythonVersion: pythonVersion
|
||||
};
|
||||
}
|
@ -1,30 +1,14 @@
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import {IS_WINDOWS, IS_LINUX} from './utils';
|
||||
|
||||
import * as semver from 'semver';
|
||||
|
||||
let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
|
||||
|
||||
if (!cacheDirectory) {
|
||||
let baseLocation;
|
||||
if (process.platform === 'win32') {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
cacheDirectory = path.join(baseLocation, 'actions', 'cache');
|
||||
}
|
||||
import * as installer from './install-python';
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
|
||||
// This is where pip is, along with anything that pip installs.
|
||||
// There is a seperate directory for `pip install --user`.
|
||||
@ -99,34 +83,50 @@ async function useCpythonVersion(
|
||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||
|
||||
const installDir: string | null = tc.find(
|
||||
let installDir: string | null = tc.find(
|
||||
'Python',
|
||||
semanticVersionSpec,
|
||||
architecture
|
||||
);
|
||||
if (!installDir) {
|
||||
// Fail and list available versions
|
||||
const x86Versions = tc
|
||||
.findAllVersions('Python', 'x86')
|
||||
.map(s => `${s} (x86)`)
|
||||
.join(os.EOL);
|
||||
core.info(
|
||||
`Version ${semanticVersionSpec} was not found in the local cache`
|
||||
);
|
||||
const foundRelease = await installer.findReleaseFromManifest(
|
||||
semanticVersionSpec,
|
||||
architecture
|
||||
);
|
||||
|
||||
const x64Versions = tc
|
||||
.findAllVersions('Python', 'x64')
|
||||
.map(s => `${s} (x64)`)
|
||||
.join(os.EOL);
|
||||
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
|
||||
core.info(`Version ${semanticVersionSpec} is available for downloading`);
|
||||
await installer.installCpythonFromRelease(foundRelease);
|
||||
|
||||
installDir = tc.find('Python', semanticVersionSpec, architecture);
|
||||
}
|
||||
}
|
||||
|
||||
if (!installDir) {
|
||||
throw new Error(
|
||||
[
|
||||
`Version ${version} with arch ${architecture} not found`,
|
||||
'Available versions:',
|
||||
x86Versions,
|
||||
x64Versions
|
||||
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
||||
].join(os.EOL)
|
||||
);
|
||||
}
|
||||
|
||||
core.exportVariable('pythonLocation', installDir);
|
||||
|
||||
if (IS_LINUX) {
|
||||
const libPath = process.env.LD_LIBRARY_PATH
|
||||
? `:${process.env.LD_LIBRARY_PATH}`
|
||||
: '';
|
||||
const pyLibPath = path.join(installDir, 'lib');
|
||||
|
||||
if (!libPath.split(':').includes(pyLibPath)) {
|
||||
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
|
||||
}
|
||||
}
|
||||
|
||||
core.addPath(installDir);
|
||||
core.addPath(binDir(installDir));
|
||||
|
||||
|
193
src/install-pypy.ts
Normal file
193
src/install-pypy.ts
Normal file
@ -0,0 +1,193 @@
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as semver from 'semver';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as exec from '@actions/exec';
|
||||
import fs from 'fs';
|
||||
|
||||
import {
|
||||
IS_WINDOWS,
|
||||
IPyPyManifestRelease,
|
||||
createSymlinkInFolder,
|
||||
isNightlyKeyword,
|
||||
writeExactPyPyVersionFile
|
||||
} from './utils';
|
||||
|
||||
export async function installPyPy(
|
||||
pypyVersion: string,
|
||||
pythonVersion: string,
|
||||
architecture: string
|
||||
) {
|
||||
let downloadDir;
|
||||
|
||||
const releases = await getAvailablePyPyVersions();
|
||||
if (!releases || releases.length === 0) {
|
||||
throw new Error('No release was found in PyPy version.json');
|
||||
}
|
||||
|
||||
const releaseData = findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture
|
||||
);
|
||||
|
||||
if (!releaseData || !releaseData.foundAsset) {
|
||||
throw new Error(
|
||||
`PyPy version ${pythonVersion} (${pypyVersion}) with arch ${architecture} not found`
|
||||
);
|
||||
}
|
||||
|
||||
const {foundAsset, resolvedPythonVersion, resolvedPyPyVersion} = releaseData;
|
||||
let downloadUrl = `${foundAsset.download_url}`;
|
||||
|
||||
core.info(`Downloading PyPy from "${downloadUrl}" ...`);
|
||||
const pypyPath = await tc.downloadTool(downloadUrl);
|
||||
|
||||
core.info('Extracting downloaded archive...');
|
||||
if (IS_WINDOWS) {
|
||||
downloadDir = await tc.extractZip(pypyPath);
|
||||
} else {
|
||||
downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
|
||||
}
|
||||
|
||||
// root folder in archive can have unpredictable name so just take the first folder
|
||||
// downloadDir is unique folder under TEMP and can't contain any other folders
|
||||
const archiveName = fs.readdirSync(downloadDir)[0];
|
||||
|
||||
const toolDir = path.join(downloadDir, archiveName);
|
||||
let installDir = toolDir;
|
||||
if (!isNightlyKeyword(resolvedPyPyVersion)) {
|
||||
installDir = await tc.cacheDir(
|
||||
toolDir,
|
||||
'PyPy',
|
||||
resolvedPythonVersion,
|
||||
architecture
|
||||
);
|
||||
}
|
||||
|
||||
writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
||||
|
||||
const binaryPath = getPyPyBinaryPath(installDir);
|
||||
await createPyPySymlink(binaryPath, resolvedPythonVersion);
|
||||
await installPip(binaryPath);
|
||||
|
||||
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
|
||||
}
|
||||
|
||||
async function getAvailablePyPyVersions() {
|
||||
const url = 'https://downloads.python.org/pypy/versions.json';
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
|
||||
|
||||
const response = await http.getJson<IPyPyManifestRelease[]>(url);
|
||||
if (!response.result) {
|
||||
throw new Error(
|
||||
`Unable to retrieve the list of available PyPy versions from '${url}'`
|
||||
);
|
||||
}
|
||||
|
||||
return response.result;
|
||||
}
|
||||
|
||||
async function createPyPySymlink(
|
||||
pypyBinaryPath: string,
|
||||
pythonVersion: string
|
||||
) {
|
||||
const version = semver.coerce(pythonVersion)!;
|
||||
const pythonBinaryPostfix = semver.major(version);
|
||||
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
|
||||
let binaryExtension = IS_WINDOWS ? '.exe' : '';
|
||||
|
||||
core.info('Creating symlinks...');
|
||||
createSymlinkInFolder(
|
||||
pypyBinaryPath,
|
||||
`pypy${pypyBinaryPostfix}${binaryExtension}`,
|
||||
`python${pythonBinaryPostfix}${binaryExtension}`,
|
||||
true
|
||||
);
|
||||
|
||||
createSymlinkInFolder(
|
||||
pypyBinaryPath,
|
||||
`pypy${pypyBinaryPostfix}${binaryExtension}`,
|
||||
`python${binaryExtension}`,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
async function installPip(pythonLocation: string) {
|
||||
core.info('Installing and updating pip');
|
||||
const pythonBinary = path.join(pythonLocation, 'python');
|
||||
await exec.exec(`${pythonBinary} -m ensurepip`);
|
||||
|
||||
await exec.exec(
|
||||
`${pythonLocation}/python -m pip install --ignore-installed pip`
|
||||
);
|
||||
}
|
||||
|
||||
export function findRelease(
|
||||
releases: IPyPyManifestRelease[],
|
||||
pythonVersion: string,
|
||||
pypyVersion: string,
|
||||
architecture: string
|
||||
) {
|
||||
const filterReleases = releases.filter(item => {
|
||||
const isPythonVersionSatisfied = semver.satisfies(
|
||||
semver.coerce(item.python_version)!,
|
||||
pythonVersion
|
||||
);
|
||||
const isPyPyNightly =
|
||||
isNightlyKeyword(pypyVersion) && isNightlyKeyword(item.pypy_version);
|
||||
const isPyPyVersionSatisfied =
|
||||
isPyPyNightly ||
|
||||
semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion);
|
||||
const isArchPresent =
|
||||
item.files &&
|
||||
item.files.some(
|
||||
file => file.arch === architecture && file.platform === process.platform
|
||||
);
|
||||
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
||||
});
|
||||
|
||||
if (filterReleases.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const sortedReleases = filterReleases.sort((previous, current) => {
|
||||
return (
|
||||
semver.compare(
|
||||
semver.coerce(pypyVersionToSemantic(current.pypy_version))!,
|
||||
semver.coerce(pypyVersionToSemantic(previous.pypy_version))!
|
||||
) ||
|
||||
semver.compare(
|
||||
semver.coerce(current.python_version)!,
|
||||
semver.coerce(previous.python_version)!
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
const foundRelease = sortedReleases[0];
|
||||
const foundAsset = foundRelease.files.find(
|
||||
item => item.arch === architecture && item.platform === process.platform
|
||||
);
|
||||
|
||||
return {
|
||||
foundAsset,
|
||||
resolvedPythonVersion: foundRelease.python_version,
|
||||
resolvedPyPyVersion: foundRelease.pypy_version
|
||||
};
|
||||
}
|
||||
|
||||
/** Get PyPy binary location from the tool of installation directory
|
||||
* - On Linux and macOS, the Python interpreter is in 'bin'.
|
||||
* - On Windows, it is in the installation root.
|
||||
*/
|
||||
export function getPyPyBinaryPath(installDir: string) {
|
||||
const _binDir = path.join(installDir, 'bin');
|
||||
return IS_WINDOWS ? installDir : _binDir;
|
||||
}
|
||||
|
||||
export function pypyVersionToSemantic(versionSpec: string) {
|
||||
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc))(\d*)/g;
|
||||
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
||||
}
|
80
src/install-python.ts
Normal file
80
src/install-python.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import {ExecOptions} from '@actions/exec/lib/interfaces';
|
||||
import {IS_WINDOWS, IS_LINUX} from './utils';
|
||||
|
||||
const TOKEN = core.getInput('token');
|
||||
const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`;
|
||||
const MANIFEST_REPO_OWNER = 'actions';
|
||||
const MANIFEST_REPO_NAME = 'python-versions';
|
||||
const MANIFEST_REPO_BRANCH = 'main';
|
||||
export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
|
||||
|
||||
export async function findReleaseFromManifest(
|
||||
semanticVersionSpec: string,
|
||||
architecture: string
|
||||
): Promise<tc.IToolRelease | undefined> {
|
||||
const manifest: tc.IToolRelease[] = await tc.getManifestFromRepo(
|
||||
MANIFEST_REPO_OWNER,
|
||||
MANIFEST_REPO_NAME,
|
||||
AUTH,
|
||||
MANIFEST_REPO_BRANCH
|
||||
);
|
||||
return await tc.findFromManifest(
|
||||
semanticVersionSpec,
|
||||
false,
|
||||
manifest,
|
||||
architecture
|
||||
);
|
||||
}
|
||||
|
||||
async function installPython(workingDirectory: string) {
|
||||
const options: ExecOptions = {
|
||||
cwd: workingDirectory,
|
||||
env: {
|
||||
...process.env,
|
||||
...(IS_LINUX && {LD_LIBRARY_PATH: path.join(workingDirectory, 'lib')})
|
||||
},
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
core.info(data.toString().trim());
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
core.error(data.toString().trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
await exec.exec('powershell', ['./setup.ps1'], options);
|
||||
} else {
|
||||
await exec.exec('bash', ['./setup.sh'], options);
|
||||
}
|
||||
}
|
||||
|
||||
export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
||||
const downloadUrl = release.files[0].download_url;
|
||||
|
||||
core.info(`Download from "${downloadUrl}"`);
|
||||
const pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||
core.info('Extract downloaded archive');
|
||||
let pythonExtractedFolder;
|
||||
if (IS_WINDOWS) {
|
||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
||||
} else {
|
||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
||||
}
|
||||
|
||||
core.info('Execute installation script');
|
||||
await installPython(pythonExtractedFolder);
|
||||
}
|
||||
|
||||
function isGhes(): boolean {
|
||||
const ghUrl = new URL(
|
||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
);
|
||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||
}
|
@ -1,14 +1,29 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as finder from './find-python';
|
||||
import * as finderPyPy from './find-pypy';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
|
||||
function isPyPyVersion(versionSpec: string) {
|
||||
return versionSpec.startsWith('pypy-');
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
let version = core.getInput('python-version');
|
||||
if (version) {
|
||||
const arch: string = core.getInput('architecture', {required: true});
|
||||
const installed = await finder.findPythonVersion(version, arch);
|
||||
core.info(`Successfully setup ${installed.impl} (${installed.version})`);
|
||||
const arch: string = core.getInput('architecture') || os.arch();
|
||||
if (isPyPyVersion(version)) {
|
||||
const installed = await finderPyPy.findPyPyVersion(version, arch);
|
||||
core.info(
|
||||
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
||||
);
|
||||
} else {
|
||||
const installed = await finder.findPythonVersion(version, arch);
|
||||
core.info(
|
||||
`Successfully setup ${installed.impl} (${installed.version})`
|
||||
);
|
||||
}
|
||||
}
|
||||
const matchersPath = path.join(__dirname, '..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||
|
92
src/utils.ts
Normal file
92
src/utils.ts
Normal file
@ -0,0 +1,92 @@
|
||||
import fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
|
||||
export const IS_WINDOWS = process.platform === 'win32';
|
||||
export const IS_LINUX = process.platform === 'linux';
|
||||
const PYPY_VERSION_FILE = 'PYPY_VERSION';
|
||||
|
||||
export interface IPyPyManifestAsset {
|
||||
filename: string;
|
||||
arch: string;
|
||||
platform: string;
|
||||
download_url: string;
|
||||
}
|
||||
|
||||
export interface IPyPyManifestRelease {
|
||||
pypy_version: string;
|
||||
python_version: string;
|
||||
stable: boolean;
|
||||
latest_pypy: boolean;
|
||||
files: IPyPyManifestAsset[];
|
||||
}
|
||||
|
||||
/** create Symlinks for downloaded PyPy
|
||||
* It should be executed only for downloaded versions in runtime, because
|
||||
* toolcache versions have this setup.
|
||||
*/
|
||||
export function createSymlinkInFolder(
|
||||
folderPath: string,
|
||||
sourceName: string,
|
||||
targetName: string,
|
||||
setExecutable = false
|
||||
) {
|
||||
const sourcePath = path.join(folderPath, sourceName);
|
||||
const targetPath = path.join(folderPath, targetName);
|
||||
if (fs.existsSync(targetPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs.symlinkSync(sourcePath, targetPath);
|
||||
if (!IS_WINDOWS && setExecutable) {
|
||||
fs.chmodSync(targetPath, '755');
|
||||
}
|
||||
}
|
||||
|
||||
export function validateVersion(version: string) {
|
||||
return isNightlyKeyword(version) || Boolean(semver.validRange(version));
|
||||
}
|
||||
|
||||
export function isNightlyKeyword(pypyVersion: string) {
|
||||
return pypyVersion === 'nightly';
|
||||
}
|
||||
|
||||
export function getPyPyVersionFromPath(installDir: string) {
|
||||
return path.basename(path.dirname(installDir));
|
||||
}
|
||||
|
||||
/**
|
||||
* In tool-cache, we put PyPy to '<toolcache_root>/PyPy/<python_version>/x64'
|
||||
* There is no easy way to determine what PyPy version is located in specific folder
|
||||
* 'pypy --version' is not reliable enough since it is not set properly for preview versions
|
||||
* "7.3.3rc1" is marked as '7.3.3' in 'pypy --version'
|
||||
* so we put PYPY_VERSION file to PyPy directory when install it to VM and read it when we need to know version
|
||||
* PYPY_VERSION contains exact version from 'versions.json'
|
||||
*/
|
||||
export function readExactPyPyVersionFile(installDir: string) {
|
||||
let pypyVersion = '';
|
||||
let fileVersion = path.join(installDir, PYPY_VERSION_FILE);
|
||||
if (fs.existsSync(fileVersion)) {
|
||||
pypyVersion = fs.readFileSync(fileVersion).toString();
|
||||
}
|
||||
|
||||
return pypyVersion;
|
||||
}
|
||||
|
||||
export function writeExactPyPyVersionFile(
|
||||
installDir: string,
|
||||
resolvedPyPyVersion: string
|
||||
) {
|
||||
const pypyFilePath = path.join(installDir, PYPY_VERSION_FILE);
|
||||
fs.writeFileSync(pypyFilePath, resolvedPyPyVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Python version should be specified explicitly like "x.y" (2.7, 3.6, 3.7)
|
||||
* "3.x" or "3" are not supported
|
||||
* because it could cause ambiguity when both PyPy version and Python version are not precise
|
||||
*/
|
||||
export function validatePythonVersionFormatForPyPy(version: string) {
|
||||
const re = /^\d+\.\d+$/;
|
||||
return re.test(version);
|
||||
}
|
Reference in New Issue
Block a user