Compare commits

..

4 commits

Author SHA1 Message Date
Deepak Dahiya
281b9d65e0 New package-lock 2022-04-11 12:58:25 +00:00
Deepak Dahiya
72e7b2061f Lincesed 2022-04-11 09:35:26 +00:00
Deepak Dahiya
8925e56ea4 new build 2022-04-11 07:34:15 +00:00
Deepak Dahiya
86c4aa8d46 Updated @actions/cache 2022-04-11 07:28:36 +00:00
102 changed files with 71750 additions and 124713 deletions

View file

@ -1,6 +0,0 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!src/

View file

@ -1,51 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'node/no-extraneous-import': 'error'
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};

2
.github/CODEOWNERS vendored
View file

@ -1 +1 @@
* @actions/setup-actions-team * @actions/actions-service

View file

@ -1 +1 @@
blank_issues_enabled: false blank_issues_enabled: false

View file

@ -1,17 +0,0 @@
name: Basic validation
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
with:
node-version: '20.x'

View file

@ -1,3 +1,8 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/ name: Check dist/
on: on:
@ -12,8 +17,36 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
call-check-dist: check-dist:
name: Check dist/ runs-on: ubuntu-latest
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
with: steps:
node-version: '20.x' - uses: actions/checkout@v2
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/

View file

@ -1,13 +1,47 @@
name: CodeQL analysis name: "Code scanning - action"
on: on:
push: push:
branches: ['main'] branches: [ 'main' ]
pull_request: pull_request:
schedule: schedule:
- cron: '0 3 * * 0' - cron: '25 3 * * 5'
jobs: jobs:
call-codeQL-analysis: CodeQL-Build:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main 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

View file

@ -23,7 +23,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x'] python-version: ['3.9', 'pypy-3.7-v7.x']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup Python - name: Setup Python
uses: ./ uses: ./
with: with:
@ -39,34 +39,20 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.9-v7.x'] python-version: ['3.9', 'pypy-3.7-v7.x']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup Python - name: Setup Python
id: cache-pipenv
uses: ./ uses: ./
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
cache: 'pipenv' cache: 'pipenv'
- name: Install pipenv - name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python run: pipx install pipenv
- name: Prepare environment
shell: pwsh
run: |
mv ./__tests__/data/Pipfile.lock .
mv ./__tests__/data/Pipfile .
mv ./__tests__/test-pipenv.py .
- name: Install dependencies - name: Install dependencies
shell: pwsh
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: | run: |
if ("${{ matrix.python-version }}" -Match "pypy") { cd __tests__/data
pipenv install --python pypy # --keep-outdated pipenv install --verbose
} else {
pipenv install --python ${{ matrix.python-version }} # --keep-outdated
}
- name: Run Python Script
run: pipenv run python test-pipenv.py
python-poetry-dependencies-caching: python-poetry-dependencies-caching:
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }}) name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
@ -75,20 +61,20 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.8'] python-version: ['3.9', 'pypy-3.7-v7.x']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Install poetry - name: Install poetry
run: pipx install poetry run: pipx install poetry
- name: Init pyproject.toml
run: mv ./__tests__/data/pyproject.toml .
- name: Setup Python - name: Setup Python
uses: ./ uses: ./
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
cache: 'poetry' cache: 'poetry'
- name: Init pyproject.toml
run: poetry init -n
- name: Install dependencies - name: Install dependencies
run: poetry install run: poetry add flake8
python-pip-dependencies-caching-path: python-pip-dependencies-caching-path:
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}) name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
@ -99,7 +85,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.7-v7.x'] python-version: ['3.9', 'pypy-3.7-v7.x']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup Python - name: Setup Python
uses: ./ uses: ./
with: with:
@ -116,32 +102,18 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', 'pypy-3.9-v7.x'] python-version: ['3.9', 'pypy-3.7-v7.x']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup Python - name: Setup Python
id: cache-pipenv
uses: ./ uses: ./
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
cache: 'pipenv' cache: 'pipenv'
cache-dependency-path: '**/pipenv-requirements.txt' cache-dependency-path: '**/pipenv-requirements.txt'
- name: Install pipenv - name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python run: pipx install pipenv
- name: Prepare environment
shell: pwsh
run: |
mv ./__tests__/data/Pipfile.lock .
mv ./__tests__/data/Pipfile .
mv ./__tests__/test-pipenv.py .
- name: Install dependencies - name: Install dependencies
shell: pwsh
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: | run: |
if ("${{ matrix.python-version }}" -Match "pypy") { cd __tests__/data
pipenv install --python pypy # --keep-outdated pipenv install --verbose
} else {
pipenv install --python ${{ matrix.python-version }} # --keep-outdated
}
- name: Run Python Script
run: pipenv run python test-pipenv.py

View file

@ -1,95 +0,0 @@
name: e2e tests
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
test-setup-python:
name: Test setup-python
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-20.04, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- 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
- name: Run with setup-python 3.10
id: cp310
uses: ./
with:
python-version: '3.10'
- name: Verify 3.10
run: python __tests__/verify-python.py 3.10
- name: Run python-path sample 3.10
run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version
- 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.11
uses: ./
with:
python-version: '<3.11'
- name: Verify <3.11
run: python __tests__/verify-python.py 3.10

View file

@ -9,6 +9,21 @@ on:
- main - main
jobs: jobs:
call-licensed: test:
name: Licensed runs-on: ubuntu-latest
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main name: Check licenses
steps:
- uses: actions/checkout@v2
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- run: npm ci
- name: Install licensed
run: |
cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status

View file

@ -1,5 +1,4 @@
name: Release new action version name: Release new action version
on: on:
release: release:
types: [released] types: [released]
@ -21,8 +20,8 @@ jobs:
name: releaseNewActionVersion name: releaseNewActionVersion
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Update the ${{ env.TAG_NAME }} tag - name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.2 uses: actions/publish-action@v0.1.0
with: with:
source-tag: ${{ env.TAG_NAME }} source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View file

@ -1,116 +0,0 @@
name: Validate GraalPy e2e
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
setup-graalpy:
name: Setup GraalPy ${{ matrix.graalpy }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-20.04, ubuntu-latest]
graalpy:
- 'graalpy-23.0'
- 'graalpy-22.3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python ${{ matrix.graalpy }}
id: setup-python
uses: ./
with:
python-version: ${{ matrix.graalpy }}
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: GraalPy and Python version
run: python --version
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
- name: Assert GraalPy is running
run: |
import platform
assert platform.python_implementation().lower() == "graalvm"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE=${{ matrix.graalpy }}
EXECUTABLE=${EXECUTABLE/graalpy-/graalpy} # remove the first '-' in "graalpy-X.Y" -> "graalpyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash
setup-graalpy-noenv:
name: Setup GraalPy ${{ matrix.graalpy }} ${{ matrix.os }} (noenv)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-20.04, ubuntu-latest]
graalpy: ['graalpy23.0', 'graalpy22.3']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python ${{ matrix.graalpy }}
id: setup-python
uses: ./
with:
python-version: ${{ matrix.graalpy }}
update-environment: false
- name: GraalPy and Python version
run: ${{ steps.setup-python.outputs.python-path }} --version
- name: Run simple code
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
check-latest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup GraalPy and check latest
uses: ./
id: graalpy
with:
python-version: 'graalpy-23.x'
check-latest: true
- name: GraalPy and Python version
run: python --version
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
- name: Assert GraalPy is running
run: |
import platform
assert platform.python_implementation().lower() == "graalvm"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE='${{ steps.graalpy.outputs.python-version }}'
EXECUTABLE="${EXECUTABLE%.*}"
${EXECUTABLE} --version
shell: bash

View file

@ -1,6 +1,5 @@
name: Validate PyPy e2e name: Validate PyPy e2e
on:
on:
push: push:
branches: branches:
- main - main
@ -19,151 +18,29 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-latest]
pypy: pypy:
- 'pypy-2.7' - 'pypy-2.7'
- 'pypy-3.7' - 'pypy-3.7'
- 'pypy3.9' - 'pypy-2.7-v7.3.4'
- 'pypy-2.7-v7.3.4' - 'pypy-3.7-v7.3.5'
- 'pypy-3.7-v7.3.5' - 'pypy-3.7-v7.3.4'
- 'pypy-3.7-v7.3.4' - 'pypy-3.7-v7.3.x'
- 'pypy-3.7-v7.3.x' - 'pypy-3.7-v7.x'
- 'pypy-3.7-v7.x' - 'pypy-2.7-v7.3.4rc1'
- 'pypy-2.7-v7.3.4rc1' - 'pypy-3.7-nightly'
- 'pypy-3.7-nightly'
- 'pypy3.8-v7.3.7'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: setup-python ${{ matrix.pypy }} - name: setup-python ${{ matrix.pypy }}
id: setup-python
uses: ./ uses: ./
with: with:
python-version: ${{ matrix.pypy }} python-version: ${{ matrix.pypy }}
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: PyPy and Python version - name: PyPy and Python version
run: python --version run: python --version
- name: Run simple code - name: Run simple code
run: python -c 'import math; print(math.factorial(5))' run: python -c 'import math; print(math.factorial(5))'
- name: Assert PyPy is running
run: |
import platform
assert platform.python_implementation().lower() == "pypy"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE=${{ matrix.pypy }}
EXECUTABLE=${EXECUTABLE/pypy-/pypy} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash
setup-pypy-noenv:
name: Setup PyPy ${{ matrix.pypy }} ${{ matrix.os }} (noenv)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-latest]
pypy: ['pypy2.7', 'pypy3.7', 'pypy3.8', 'pypy3.9-nightly']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python ${{ matrix.pypy }}
id: setup-python
uses: ./
with:
python-version: ${{ matrix.pypy }}
update-environment: false
- name: PyPy and Python version
run: ${{ steps.setup-python.outputs.python-path }} --version
- name: Run simple code
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
check-latest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup PyPy and check latest
uses: ./
with:
python-version: 'pypy-3.7-v7.3.x'
check-latest: true
- name: PyPy and Python version
run: python --version
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
- name: Assert PyPy is running
run: |
import platform
assert platform.python_implementation().lower() == "pypy"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE="pypy-3.7-v7.3.x"
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash
setup-pypy-multiple-versions:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup PyPy and check latest
uses: ./
with:
python-version: |
pypy-3.7-v7.3.x
pypy3.8
check-latest: true
- name: PyPy and Python version
run: python --version
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
- name: Assert PyPy is running
run: |
import platform
assert platform.python_implementation().lower() == "pypy"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE="pypy-3.7-v7.3.x"
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE='pypy3.8'
EXECUTABLE=${EXECUTABLE/pypy-/pypy} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash

View file

@ -1,6 +1,5 @@
name: Validate Python e2e name: Validate Python e2e
on:
on:
push: push:
branches: branches:
- main - main
@ -11,244 +10,57 @@ on:
- '**.md' - '**.md'
schedule: schedule:
- cron: 30 3 * * * - cron: 30 3 * * *
workflow_dispatch:
jobs: jobs:
default-version:
name: Setup default version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup default python
uses: ./
- name: Validate version
run: python --version
- name: Run simple python code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-from-manifest: setup-versions-from-manifest:
name: Setup ${{ matrix.python }} ${{ matrix.os }} name: Setup ${{ matrix.python }} ${{ matrix.os }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04] os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
python: [3.5.4, 3.6.7, 3.7.5, 3.8.15, 3.9.13] python: [3.5.4, 3.6.7, 3.7.5, 3.8.1]
exclude:
- os: ubuntu-22.04
python: 3.5.4
- os: ubuntu-22.04
python: 3.6.7
- os: ubuntu-22.04
python: 3.7.5
- os: windows-latest
python: 3.8.15
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: setup-python ${{ matrix.python }} - name: setup-python ${{ matrix.python }}
id: setup-python uses: ./
uses: ./ with:
with: python-version: ${{ matrix.python }}
python-version: ${{ matrix.python }}
- name: Check python-path - name: Validate version
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' run: |
shell: bash $pythonVersion = (python --version)
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Validate version - name: Run simple code
run: | run: python -c 'import math; print(math.factorial(5))'
$pythonVersion = (python --version)
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-from-file:
name: Setup ${{ matrix.python }} ${{ matrix.os }} version file
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: [3.5.4, 3.6.7, 3.7.5, 3.8.15, 3.9.13]
exclude:
- os: ubuntu-22.04
python: 3.5.4
- os: ubuntu-22.04
python: 3.6.7
- os: ubuntu-22.04
python: 3.7.5
- os: windows-latest
python: 3.8.15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: build-version-file ${{ matrix.python }}
run: echo ${{ matrix.python }} > .python-version
- name: setup-python ${{ matrix.python }}
id: setup-python
uses: ./
with:
python-version-file: .python-version
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-from-file-without-parameter:
name: Setup ${{ matrix.python }} ${{ matrix.os }} version file without parameter
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: [3.5.4, 3.6.7, 3.7.5, 3.8.15, 3.9.13]
exclude:
- os: ubuntu-22.04
python: 3.5.4
- os: ubuntu-22.04
python: 3.6.7
- os: ubuntu-22.04
python: 3.7.5
- os: windows-latest
python: 3.8.15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: build-version-file ${{ matrix.python }}
run: echo ${{ matrix.python }} > .python-version
- name: setup-python ${{ matrix.python }}
id: setup-python
uses: ./
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-from-standard-pyproject-file:
name: Setup ${{ matrix.python }} ${{ matrix.os }} standard pyproject file
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: [3.5.4, 3.6.7, 3.7.5, 3.8.15, 3.9.13, '==3.10.10']
exclude:
- os: ubuntu-22.04
python: 3.5.4
- os: ubuntu-22.04
python: 3.6.7
- os: ubuntu-22.04
python: 3.7.5
- os: windows-latest
python: 3.8.15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: build-version-file ${{ matrix.python }}
run: |
echo '[project]
requires-python = "${{ matrix.python }}"
' > pyproject.toml
- name: setup-python ${{ matrix.python }}
id: setup-python
uses: ./
with:
python-version-file: pyproject.toml
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("Python ${{ matrix.python }}".replace("==", "") -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-from-poetry-pyproject-file:
name: Setup ${{ matrix.python }} ${{ matrix.os }} poetry pyproject file
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: [3.5.4, 3.6.7, 3.7.5, 3.8.15, 3.9.13]
exclude:
- os: ubuntu-22.04
python: 3.5.4
- os: ubuntu-22.04
python: 3.6.7
- os: ubuntu-22.04
python: 3.7.5
- os: windows-latest
python: 3.8.15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: build-version-file ${{ matrix.python }}
run: |
echo '[tool.poetry.dependencies]
python = "${{ matrix.python }}"
' > pyproject.toml
- name: setup-python ${{ matrix.python }}
id: setup-python
uses: ./
with:
python-version-file: pyproject.toml
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-pre-release-version-from-manifest: setup-pre-release-version-from-manifest:
name: Setup 3.9.0-beta.4 ${{ matrix.os }} name: Setup 3.9.0-beta.4 ${{ matrix.os }}
@ -256,163 +68,26 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-20.04] os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: setup-python 3.9.0-beta.4 - name: setup-python 3.9.0-beta.4
id: setup-python uses: ./
uses: ./ with:
with: python-version: '3.9.0-beta.4'
python-version: '3.9.0-beta.4'
- name: Check python-path - name: Validate version
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' run: |
shell: bash $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: Validate version - name: Run simple code
run: | run: python -c 'import math; print(math.factorial(5))'
$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-dev-version:
name: Setup 3.9-dev ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python 3.9-dev
id: setup-python
uses: ./
with:
python-version: '3.9-dev'
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: ${{ startsWith(steps.setup-python.outputs.python-version, '3.9.') }}
shell: bash
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-prerelease-version:
name: Setup 3.12 ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python 3.12
id: setup-python
uses: ./
with:
python-version: '3.12'
allow-prereleases: true
- name: Check python-path
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
shell: bash
- name: Validate version
run: ${{ startsWith(steps.setup-python.outputs.python-version, '3.12.') }}
shell: bash
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
setup-versions-noenv:
name: Setup ${{ matrix.python }} ${{ matrix.os }} (noenv)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04, ubuntu-22.04]
python: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-python ${{ matrix.python }}
id: setup-python
uses: ./
with:
python-version: ${{ matrix.python }}
update-environment: false
- name: Python version
run: ${{ steps.setup-python.outputs.python-path }} --version
- name: Run simple code
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
check-latest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v4
- name: Setup Python and check latest
uses: ./
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("$pythonVersion" -NotMatch "${{ matrix.python-version }}"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python-version }}"
exit 1
}
$pythonVersion
shell: pwsh
setup-python-multiple-python-versions:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Python and check latest
uses: ./
with:
python-version: |
3.7
3.8
3.9
3.10
check-latest: true
- name: Validate version
run: |
$pythonVersion = (python --version)
if ("$pythonVersion" -NotMatch "3.10"){
Write-Host "The current version is $pythonVersion; expected version is 3.10"
exit 1
}
$pythonVersion
shell: pwsh

View file

@ -1,11 +0,0 @@
name: Update configuration files
on:
schedule:
- cron: '0 3 * * 0'
workflow_dispatch:
jobs:
call-update-configuration-files:
name: Update configuration files
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main

91
.github/workflows/workflow.yml vendored Normal file
View file

@ -0,0 +1,91 @@
name: Main workflow
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
run:
name: Run
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- name: npm ci
run: npm ci
- name: Lint
run: npm run format-check
- 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

1702
.licenses/NOTICE generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
--- ---
name: "@actions/cache" name: "@actions/cache"
version: 3.2.2 version: 2.0.2
type: npm type: npm
summary: Actions cache lib summary: Actions cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/cache homepage: https://github.com/actions/toolkit/tree/main/packages/cache

View file

@ -1,6 +1,6 @@
--- ---
name: "@actions/core" name: "@actions/core"
version: 1.10.1 version: 1.6.0
type: npm type: npm
summary: Actions core lib summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core homepage: https://github.com/actions/toolkit/tree/main/packages/core

View file

@ -1,6 +1,6 @@
--- ---
name: "@actions/glob" name: "@actions/glob"
version: 0.4.0 version: 0.2.1
type: npm type: npm
summary: Actions glob lib summary: Actions glob lib
homepage: https://github.com/actions/toolkit/tree/main/packages/glob homepage: https://github.com/actions/toolkit/tree/main/packages/glob

View file

@ -1,10 +1,10 @@
--- ---
name: "@actions/http-client" name: "@actions/http-client"
version: 2.2.0 version: 1.0.11
type: npm type: npm
summary: Actions Http Client summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client homepage: https://github.com/actions/http-client#readme
license: mit license: other
licenses: licenses:
- sources: LICENSE - sources: LICENSE
text: | text: |

View file

@ -1,6 +1,6 @@
--- ---
name: "@actions/io" name: "@actions/io"
version: 1.1.3 version: 1.1.2
type: npm type: npm
summary: Actions io lib summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/main/packages/io homepage: https://github.com/actions/toolkit/tree/main/packages/io

View file

@ -1,6 +1,6 @@
--- ---
name: "@actions/tool-cache" name: "@actions/tool-cache"
version: 2.0.1 version: 1.7.2
type: npm type: npm
summary: Actions tool-cache lib summary: Actions tool-cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache

View file

@ -1,9 +1,9 @@
--- ---
name: "@azure/abort-controller" name: "@azure/abort-controller"
version: 1.1.0 version: 1.0.4
type: npm type: npm
summary: Microsoft Azure SDK for JavaScript - Aborter summary: Microsoft Azure SDK for JavaScript - Aborter
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/abort-controller/README.md homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/abort-controller/README.md
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE

View file

@ -1,9 +1,9 @@
--- ---
name: "@azure/core-util" name: "@azure/core-asynciterator-polyfill"
version: 1.6.1 version: 1.0.2
type: npm type: npm
summary: Core library for shared utility methods summary: Polyfill for IE/Node 8 for Symbol.asyncIterator
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-util/ homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-asynciterator-polyfill/README.md
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-auth" name: "@azure/core-auth"
version: 1.5.0 version: 1.3.2
type: npm type: npm
summary: Provides low-level interfaces and helper methods for authentication in Azure summary: Provides low-level interfaces and helper methods for authentication in Azure
SDK SDK

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-http" name: "@azure/core-http"
version: 3.0.4 version: 2.2.4
type: npm type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest libraries generated using AutoRest

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-lro" name: "@azure/core-lro"
version: 2.5.4 version: 2.2.4
type: npm type: npm
summary: Isomorphic client library for supporting long-running operations in node.js summary: Isomorphic client library for supporting long-running operations in node.js
and browser. and browser.

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/core-paging" name: "@azure/core-paging"
version: 1.5.0 version: 1.2.1
type: npm type: npm
summary: Core types for paging async iterable iterators summary: Core types for paging async iterable iterators
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/logger" name: "@azure/logger"
version: 1.0.4 version: 1.0.3
type: npm type: npm
summary: Microsoft Azure SDK for JavaScript - Logger summary: Microsoft Azure SDK for JavaScript - Logger
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger/README.md homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger/README.md

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/ms-rest-js" name: "@azure/ms-rest-js"
version: 2.7.0 version: 2.6.1
type: npm type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest libraries generated using AutoRest

View file

@ -1,6 +1,6 @@
--- ---
name: "@azure/storage-blob" name: "@azure/storage-blob"
version: 12.17.0 version: 12.9.0
type: npm type: npm
summary: Microsoft Azure Storage SDK for JavaScript - Blob summary: Microsoft Azure Storage SDK for JavaScript - Blob
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/ homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/

View file

@ -1,30 +0,0 @@
---
name: "@fastify/busboy"
version: 2.1.0
type: npm
summary: A streaming parser for HTML form data for node.js
homepage:
license: mit
licenses:
- sources: LICENSE
text: |-
Copyright Brian White. All rights reserved.
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: []

View file

@ -1,26 +0,0 @@
---
name: "@iarna/toml"
version: 2.2.5
type: npm
summary: Better TOML parsing and stringifying all in that familiar JSON interface.
homepage: https://github.com/iarna/iarna-toml#readme
license: isc
licenses:
- sources: LICENSE
text: |+
Copyright (c) 2016, Rebecca Turner <me@re-becca.org>
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: []
...

View file

@ -1,9 +1,9 @@
--- ---
name: "@opentelemetry/api" name: "@opentelemetry/api"
version: 1.7.0 version: 1.0.4
type: npm type: npm
summary: Public API for OpenTelemetry summary: Public API for OpenTelemetry
homepage: https://github.com/open-telemetry/opentelemetry-js/tree/main/api homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme
license: apache-2.0 license: apache-2.0
licenses: licenses:
- sources: LICENSE - sources: LICENSE
@ -216,8 +216,10 @@ licenses:
[opentelemetry-js]: https://github.com/open-telemetry/opentelemetry-js [opentelemetry-js]: https://github.com/open-telemetry/opentelemetry-js
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/api/LICENSE [license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/tracing.md [npm-url]: https://www.npmjs.com/package/@opentelemetry/api
[docs-sdk-registration]: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/sdk-registration.md [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md
[docs-sdk-registration]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/sdk-registration.md
notices: [] notices: []

View file

@ -1,6 +1,6 @@
--- ---
name: "@types/node-fetch" name: "@types/node-fetch"
version: 2.6.9 version: 2.6.1
type: npm type: npm
summary: TypeScript definitions for node-fetch summary: TypeScript definitions for node-fetch
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch

View file

@ -1,8 +1,8 @@
--- ---
name: "@types/node" name: "@types/node"
version: 20.9.1 version: 17.0.23
type: npm type: npm
summary: TypeScript definitions for node summary: TypeScript definitions for Node.js
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
license: mit license: mit
licenses: licenses:

33
.licenses/npm/form-data-3.0.1.dep.yml generated Normal file
View file

@ -0,0 +1,33 @@
---
name: form-data
version: 3.0.1
type: npm
summary: A library to create readable "multipart/form-data" streams. Can be used to
submit forms and file uploads to other web applications.
homepage: https://github.com/form-data/form-data#readme
license: mit
licenses:
- sources: License
text: |
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and 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.
- sources: Readme.md
text: Form-Data is released under the [MIT](License) license.
notices: []

View file

@ -1,16 +1,16 @@
--- ---
name: undici name: ip-regex
version: 5.27.2 version: 2.1.0
type: npm type: npm
summary: An HTTP/1.1 client, written from scratch for Node.js summary: Regular expression for matching IP addresses (IPv4 & IPv6)
homepage: https://undici.nodejs.org homepage: https://github.com/sindresorhus/ip-regex#readme
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: license
text: | text: |
MIT License The MIT License (MIT)
Copyright (c) Matteo Collina and Undici contributors Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -19,16 +19,16 @@ licenses:
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in
copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
SOFTWARE. THE SOFTWARE.
- sources: README.md - sources: readme.md
text: MIT text: MIT © [Sindre Sorhus](https://sindresorhus.com)
notices: [] notices: []

View file

@ -1,16 +1,16 @@
--- ---
name: lru-cache name: lru-cache
version: 6.0.0 version: 7.8.1
type: npm type: npm
summary: A cache object that deletes the least-recently-used items. summary: A cache object that deletes the least-recently-used items.
homepage: homepage: https://github.com/isaacs/node-lru-cache#readme
license: isc license: isc
licenses: licenses:
- sources: LICENSE - sources: LICENSE
text: | text: |
The ISC License The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above

View file

@ -3,7 +3,7 @@ name: mime-db
version: 1.52.0 version: 1.52.0
type: npm type: npm
summary: Media Type Database summary: Media Type Database
homepage: homepage: https://github.com/jshttp/mime-db#readme
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE

View file

@ -3,7 +3,7 @@ name: mime-types
version: 2.1.35 version: 2.1.35
type: npm type: npm
summary: The ultimate javascript content-type utility. summary: The ultimate javascript content-type utility.
homepage: homepage: https://github.com/jshttp/mime-types#readme
license: mit license: mit
licenses: licenses:
- sources: LICENSE - sources: LICENSE

View file

@ -1,6 +1,6 @@
--- ---
name: node-fetch name: node-fetch
version: 2.7.0 version: 2.6.7
type: npm type: npm
summary: A light-weight module that brings window.fetch to node.js summary: A light-weight module that brings window.fetch to node.js
homepage: https://github.com/bitinn/node-fetch homepage: https://github.com/bitinn/node-fetch

43
.licenses/npm/psl.dep.yml generated Normal file
View file

@ -0,0 +1,43 @@
---
name: psl
version: 1.8.0
type: npm
summary: Domain name parser based on the Public Suffix List
homepage: https://github.com/lupomontero/psl#readme
license: mit
licenses:
- sources: LICENSE
text: |
The MIT License (MIT)
Copyright (c) 2017 Lupo Montero lupomontero@gmail.com
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: |-
The MIT License (MIT)
Copyright (c) 2017 Lupo Montero <lupomontero@gmail.com>
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: []

34
.licenses/npm/punycode.dep.yml generated Normal file
View file

@ -0,0 +1,34 @@
---
name: punycode
version: 2.1.1
type: npm
summary: A robust Punycode converter that fully complies to RFC 3492 and RFC 5891,
and works on nearly all JavaScript platforms.
homepage: https://mths.be/punycode
license: mit
licenses:
- sources: LICENSE-MIT.txt
text: |
Copyright Mathias Bynens <https://mathiasbynens.be/>
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: Punycode.js is available under the [MIT](https://mths.be/mit) license.
notices: []

View file

@ -1,16 +1,16 @@
--- ---
name: sax name: sax
version: 1.3.0 version: 1.2.4
type: npm type: npm
summary: An evented streaming XML parser in JavaScript summary: An evented streaming XML parser in JavaScript
homepage: homepage: https://github.com/isaacs/sax-js#readme
license: isc license: isc
licenses: licenses:
- sources: LICENSE - sources: LICENSE
text: | text: |
The ISC License The ISC License
Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -29,7 +29,7 @@ licenses:
`String.fromCodePoint` by Mathias Bynens used according to terms of MIT `String.fromCodePoint` by Mathias Bynens used according to terms of MIT
License, as follows: License, as follows:
Copyright (c) 2010-2022 Mathias Bynens <https://mathiasbynens.be/> Copyright Mathias Bynens <https://mathiasbynens.be/>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View file

@ -1,9 +1,9 @@
--- ---
name: semver name: semver
version: 6.3.1 version: 6.3.0
type: npm type: npm
summary: The semantic version parser used by npm. summary: The semantic version parser used by npm.
homepage: homepage: https://github.com/npm/node-semver#readme
license: isc license: isc
licenses: licenses:
- sources: LICENSE - sources: LICENSE

View file

@ -1,9 +1,9 @@
--- ---
name: semver name: semver
version: 7.5.4 version: 7.3.6
type: npm type: npm
summary: The semantic version parser used by npm. summary: The semantic version parser used by npm.
homepage: homepage: https://github.com/npm/node-semver#readme
license: isc license: isc
licenses: licenses:
- sources: LICENSE - sources: LICENSE

23
.licenses/npm/tough-cookie-3.0.1.dep.yml generated Normal file
View file

@ -0,0 +1,23 @@
---
name: tough-cookie
version: 3.0.1
type: npm
summary: RFC6265 Cookies and Cookie Jar for node.js
homepage: https://github.com/salesforce/tough-cookie
license: bsd-3-clause
licenses:
- sources: LICENSE
text: |
Copyright (c) 2015, Salesforce.com, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
notices: []

23
.licenses/npm/tough-cookie-4.0.0.dep.yml generated Normal file
View file

@ -0,0 +1,23 @@
---
name: tough-cookie
version: 4.0.0
type: npm
summary: RFC6265 Cookies and Cookie Jar for node.js
homepage: https://github.com/salesforce/tough-cookie
license: bsd-3-clause
licenses:
- sources: LICENSE
text: |
Copyright (c) 2015, Salesforce.com, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
notices: []

View file

@ -1,28 +1,24 @@
--- ---
name: tslib name: tslib
version: 2.6.2 version: 2.3.1
type: npm type: npm
summary: Runtime library for TypeScript helper functions summary: Runtime library for TypeScript helper functions
homepage: https://www.typescriptlang.org/ homepage: https://www.typescriptlang.org/
license: 0bsd license: 0bsd
licenses: licenses:
- sources: LICENSE.txt - sources: LICENSE.txt
text: |- text: "Copyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify,
Copyright (c) Microsoft Corporation. and/or distribute this software for any\r\npurpose with or without fee is hereby
granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL
Permission to use, copy, modify, and/or distribute this software for any WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
purpose with or without fee is hereby granted. MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, USE OR\r\nPERFORMANCE OF THIS SOFTWARE."
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: notices:
- sources: CopyrightNotice.txt - sources: CopyrightNotice.txt
text: "/******************************************************************************\r\nCopyright text: "/*! *****************************************************************************\r\nCopyright
(c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute
this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE
SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD

View file

@ -1,30 +0,0 @@
---
name: undici-types
version: 5.26.5
type: npm
summary: A stand-alone types package for Undici
homepage: https://undici.nodejs.org
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: []

33
.licenses/npm/universalify.dep.yml generated Normal file
View file

@ -0,0 +1,33 @@
---
name: universalify
version: 0.1.2
type: npm
summary: Make a callback- or promise-based function support both promises and callbacks.
homepage: https://github.com/RyanZim/universalify#readme
license: mit
licenses:
- sources: LICENSE
text: |
(The MIT License)
Copyright (c) 2017, Ryan Zimmerman <opensrc@ryanzim.com>
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: MIT
notices: []

View file

@ -1,6 +1,6 @@
--- ---
name: xml2js name: xml2js
version: 0.5.0 version: 0.4.23
type: npm type: npm
summary: Simple XML to JavaScript object converter. summary: Simple XML to JavaScript object converter.
homepage: https://github.com/Leonidas-from-XIV/node-xml2js homepage: https://github.com/Leonidas-from-XIV/node-xml2js

View file

@ -1,26 +0,0 @@
---
name: yallist
version: 4.0.0
type: npm
summary: Yet Another Linked List
homepage:
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: []

View file

@ -1,7 +0,0 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!.github/
!src/

View file

@ -1,11 +0,0 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};

11
.prettierrc.json Normal file
View file

@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

View file

@ -1,76 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource+actions/setup-python@github.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

345
README.md
View file

@ -1,108 +1,345 @@
# setup-python # setup-python V3
[![Basic validation](https://github.com/actions/setup-python/actions/workflows/basic-validation.yml/badge.svg?branch=main)](https://github.com/actions/setup-python/actions/workflows/basic-validation.yml) <p align="left">
[![Validate Python e2e](https://github.com/actions/setup-python/actions/workflows/test-python.yml/badge.svg?branch=main)](https://github.com/actions/setup-python/actions/workflows/test-python.yml) <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>
[![Validate PyPy e2e](https://github.com/actions/setup-python/actions/workflows/test-pypy.yml/badge.svg?branch=main)](https://github.com/actions/setup-python/actions/workflows/test-pypy.yml) </p>
[![e2e-cache](https://github.com/actions/setup-python/actions/workflows/e2e-cache.yml/badge.svg?branch=main)](https://github.com/actions/setup-python/actions/workflows/e2e-cache.yml)
This action provides the following functionality for GitHub Actions users: This action sets up a Python environment for use in actions by:
- Installing a version of Python or PyPy and (by default) adding it to the PATH - optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
- Optionally caching dependencies for pip, pipenv and poetry - 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.
- Registering problem matchers for error output - failing if a specific version of Python is not preinstalled or available for download.
- optionally caching dependencies for pip, pipenv and poetry.
- registering problem matchers for error output.
## Basic usage # 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
- Support for built-in caching of pip, pipenv and poetry dependencies
# Usage
See [action.yml](action.yml) See [action.yml](action.yml)
**Python** Basic:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-python@v5 - uses: actions/setup-python@v3
with: with:
python-version: '3.10' 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
- run: python my_script.py - run: python my_script.py
``` ```
**PyPy** Matrix Testing:
```yaml
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '2.x', '3.x', 'pypy-2.7', 'pypy-3.7', 'pypy-3.8' ]
name: Python ${{ matrix.python-version }} sample
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: python my_script.py
```
Exclude a specific Python version:
```yaml
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy-2.7', 'pypy-3.8']
exclude:
- os: macos-latest
python-version: '3.8'
- os: windows-latest
python-version: '3.6'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python --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.7.4', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- run: python my_script.py
```
Download and set up an accurate pre-release version of Python:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-python@v5 - uses: actions/setup-python@v3
with: with:
python-version: 'pypy3.9' python-version: '3.11.0-alpha.1'
- run: python my_script.py - run: python my_script.py
``` ```
**GraalPy** Download and set up the latest available version of Python (includes both pre-release and stable versions):
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-python@v5 - uses: actions/setup-python@v3
with: with:
python-version: 'graalpy-22.3' python-version: '3.11.0-alpha - 3.11.0' # SemVer's version range syntax
- run: python my_script.py - run: python my_script.py
``` ```
The `python-version` input is optional. If not supplied, the action will try to resolve the version from the default `.python-version` file. If the `.python-version` file doesn't exist Python or PyPy version from the PATH will be used. The default version of Python or PyPy in PATH varies between runners and can be changed unexpectedly so we recommend always setting Python version explicitly using the `python-version` or `python-version-file` inputs. Download and set up PyPy:
The action will first check the local [tool cache](docs/advanced-usage.md#hosted-tool-cache) for a [semver](https://github.com/npm/node-semver#versions) match. If unable to find a specific version in the tool cache, the action will attempt to download a version of Python from [GitHub Releases](https://github.com/actions/python-versions/releases) and for PyPy from the official [PyPy's dist](https://downloads.python.org/pypy/). ```yaml
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '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
- 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
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.
For information regarding locally cached versions of Python or PyPy on GitHub hosted runners, check out [GitHub Actions Runner Images](https://github.com/actions/runner-images). # Getting started with Python + Actions
## Supported version syntax 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).
The `python-version` input supports the [Semantic Versioning Specification](https://semver.org/) and some special version notations (e.g. `semver ranges`, `x.y-dev syntax`, etc.), for detailed examples please refer to the section: [Using python-version input](docs/advanced-usage.md#using-the-python-version-input) of the [Advanced usage](docs/advanced-usage.md) guide. # Available versions of Python
## Supported architectures `setup-python` is able to configure Python from two sources:
Using `architecture` input it is possible to specify the required Python or PyPy interpreter architecture: `x86` or `x64`. If the input is not specified the architecture defaults to `x64`. - 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
## Caching packages dependencies # Available versions of PyPy
The action has built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default. `setup-python` is able to configure PyPy from two sources:
The action defaults to searching for a dependency file (`requirements.txt` or `pyproject.toml` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Input `cache-dependency-path` is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used. - 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.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy-3.7-v7.3.3`.
- For `pip`, the action will cache the global cache directory - Downloadable PyPy versions from the [official PyPy site](https://downloads.python.org/pypy/).
- For `pipenv`, the action will cache virtualenv directory - All available versions that we can download are listed in [versions.json](https://downloads.python.org/pypy/versions.json) file.
- For `poetry`, the action will cache virtualenv directories -- one for each poetry project found - 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 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 |
|------|-------|
|**Tool Cache Directory** |`RUNNER_TOOL_CACHE`|
|**Python Tool Cache**|`RUNNER_TOOL_CACHE/Python/*`|
|**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/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.7 # the latest available version of PyPy that supports Python 3.7
pypy-3.8 # the latest available version of PyPy that supports Python 3.8
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
```
# Caching packages dependencies
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default.
The action defaults to searching for a dependency file (`requirements.txt` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases where multiple dependency files are used, they are located in different subdirectories or different files for the hash want to be used.
- For pip, the action will cache global cache directory
- For pipenv, the action will cache virtualenv directory
- For poetry, the action will cache virtualenv directory
**Please Note:** Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available that can lead to an increase in total build time.
The requirements file format allows to specify dependency versions using logical operators (for example chardet>=3.0.4) or specify dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary.
**Caching pip dependencies:** **Caching pip dependencies:**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-python@v5 - uses: actions/setup-python@v3
with: with:
python-version: '3.9' python-version: '3.9'
cache: 'pip' # caching pip dependencies cache: 'pip'
- run: pip install -r requirements.txt - run: pip install -r requirements.txt
``` ```
>**Note:** Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available which can lead to an increase in total build time.
>The requirements file format allows for specifying dependency versions using logical operators (for example chardet>=3.0.4) or specifying dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary. **Caching pipenv dependencies:**
```yaml
steps:
- uses: actions/checkout@v3
- name: Install pipenv
run: pipx install pipenv
- uses: actions/setup-python@v3
with:
python-version: '3.9'
cache: 'pipenv'
- run: pipenv install
```
See examples of using `cache` and `cache-dependency-path` for `pipenv` and `poetry` in the section: [Caching packages](docs/advanced-usage.md#caching-packages) of the [Advanced usage](docs/advanced-usage.md) guide. **Caching poetry dependencies:**
```yaml
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v3
with:
python-version: '3.9'
cache: 'poetry'
- run: poetry install
- run: poetry run pytest
```
## Advanced usage **Using wildcard patterns to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: '**/requirements-dev.txt'
- run: pip install -r subdirectory/requirements-dev.txt
```
- [Using the python-version input](docs/advanced-usage.md#using-the-python-version-input) **Using a list of file paths to cache dependencies**
- [Using the python-version-file input](docs/advanced-usage.md#using-the-python-version-file-input) ```yaml
- [Check latest version](docs/advanced-usage.md#check-latest-version) steps:
- [Caching packages](docs/advanced-usage.md#caching-packages) - uses: actions/checkout@v3
- [Outputs and environment variables](docs/advanced-usage.md#outputs-and-environment-variables) - name: Install pipenv
- [Available versions of Python, PyPy and GraalPy](docs/advanced-usage.md#available-versions-of-python-pypy-and-graalpy) run: pipx install pipenv
- [Hosted tool cache](docs/advanced-usage.md#hosted-tool-cache) - uses: actions/setup-python@v3
- [Using `setup-python` with a self-hosted runner](docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner) with:
- [Using `setup-python` on GHES](docs/advanced-usage.md#using-setup-python-on-ghes) python-version: '3.9'
- [Allow pre-releases](docs/advanced-usage.md#allow-pre-releases) cache: 'pipenv'
cache-dependency-path: |
server/app/Pipfile.lock
__test__/app/Pipfile.lock
- run: pipenv install
```
## License # Using `setup-python` with a self hosted 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.
# 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`.
# Using `setup-python` on GHES
`setup-python` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Python distributions, `setup-python` downloads distributions from [`actions/python-versions`](https://github.com/actions/python-versions) on github.com (outside of the appliance). These calls to `actions/python-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during download that read `##[error]API rate limit exceeded for...`.
To avoid hitting rate-limit problems, we recommend [setting up your own runner tool cache](https://docs.github.com/en/enterprise-server@2.22/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access#about-the-included-setup-actions-and-the-runner-tool-cache).
# 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
Contributions are welcome! See our [Contributor's Guide](docs/contributors.md). Contributions are welcome! See our [Contributor's Guide](docs/contributors.md).

View file

@ -1,20 +1,17 @@
import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as io from '@actions/io';
import {getCacheDistributor} from '../src/cache-distributions/cache-factory'; import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
import {State} from '../src/cache-distributions/cache-distributor';
describe('restore-cache', () => { describe('restore-cache', () => {
const pipFileLockHash = const pipFileLockHash =
'f8428d7cf00ea53a5c3702f0a9cb3cc467f76cd86a34723009350c4e4b32751a'; 'd1dd6218299d8a6db5fc2001d988b34a8b31f1e9d0bb4534d377dde7c19f64b3';
const requirementsHash = const requirementsHash =
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121'; 'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121';
const requirementsLinuxHash = const requirementsLinuxHash =
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c'; '2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
const poetryLockHash = const poetryLockHash =
'f24ea1ad73968e6c8d80c16a093ade72d9332c433aeef979a0dd943e6a99b2ab'; '571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836';
const poetryConfigOutput = ` const poetryConfigOutput = `
cache-dir = "/Users/patrick/Library/Caches/pypoetry" cache-dir = "/Users/patrick/Library/Caches/pypoetry"
experimental.new-installer = false experimental.new-installer = false
@ -28,7 +25,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
let infoSpy: jest.SpyInstance; let infoSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance; let debugSpy: jest.SpyInstance;
let saveStateSpy: jest.SpyInstance; let saveSatetSpy: jest.SpyInstance;
let getStateSpy: jest.SpyInstance; let getStateSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance; let setOutputSpy: jest.SpyInstance;
@ -38,9 +35,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
// exec spy // exec spy
let getExecOutputSpy: jest.SpyInstance; let getExecOutputSpy: jest.SpyInstance;
// io spy
let whichSpy: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
process.env['RUNNER_OS'] = process.env['RUNNER_OS'] ?? 'linux'; process.env['RUNNER_OS'] = process.env['RUNNER_OS'] ?? 'linux';
@ -53,8 +47,8 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
debugSpy = jest.spyOn(core, 'debug'); debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(input => undefined); debugSpy.mockImplementation(input => undefined);
saveStateSpy = jest.spyOn(core, 'saveState'); saveSatetSpy = jest.spyOn(core, 'saveState');
saveStateSpy.mockImplementation(input => undefined); saveSatetSpy.mockImplementation(input => undefined);
getStateSpy = jest.spyOn(core, 'getState'); getStateSpy = jest.spyOn(core, 'getState');
getStateSpy.mockImplementation(input => undefined); getStateSpy.mockImplementation(input => undefined);
@ -67,9 +61,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
if (input.includes('poetry')) { if (input.includes('poetry')) {
return {stdout: poetryConfigOutput, stderr: '', exitCode: 0}; return {stdout: poetryConfigOutput, stderr: '', exitCode: 0};
} }
if (input.includes('lsb_release')) {
return {stdout: 'Ubuntu\n20.04', stderr: '', exitCode: 0};
}
return {stdout: '', stderr: 'Error occured', exitCode: 2}; return {stdout: '', stderr: 'Error occured', exitCode: 2};
}); });
@ -83,9 +74,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
return primaryKey; return primaryKey;
} }
); );
whichSpy = jest.spyOn(io, 'which');
whichSpy.mockImplementation(() => '/path/to/python');
}); });
describe('Validate provided package manager', () => { describe('Validate provided package manager', () => {
@ -94,114 +82,47 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
async packageManager => { async packageManager => {
expect(() => expect(() =>
getCacheDistributor(packageManager, '3.8.12', undefined) getCacheDistributor(packageManager, '3.8.12', undefined)
).toThrow(`Caching for '${packageManager}' is not supported`); ).toThrowError(`Caching for '${packageManager}' is not supported`);
} }
); );
}); });
describe('Restore dependencies', () => { describe('Restore dependencies', () => {
it.each([ it.each([
[ ['pip', '3.8.12', undefined, requirementsHash],
'pip', ['pip', '3.8.12', '**/requirements-linux.txt', requirementsLinuxHash],
'3.8.12',
'__tests__/data/**/requirements.txt',
requirementsHash,
undefined
],
[
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
requirementsLinuxHash,
undefined
],
[ [
'pip', 'pip',
'3.8.12', '3.8.12',
'__tests__/data/requirements-linux.txt', '__tests__/data/requirements-linux.txt',
requirementsLinuxHash, requirementsLinuxHash
undefined
], ],
[ ['pip', '3.8.12', '__tests__/data/requirements.txt', requirementsHash],
'pip', ['pipenv', '3.9.1', undefined, pipFileLockHash],
'3.8.12', ['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash],
'__tests__/data/requirements.txt', ['poetry', '3.9.1', undefined, poetryLockHash]
requirementsHash,
undefined
],
[
'pipenv',
'3.9.1',
'__tests__/data/**/Pipfile.lock',
pipFileLockHash,
undefined
],
[
'pipenv',
'3.9.12',
'__tests__/data/requirements.txt',
requirementsHash,
undefined
],
[
'poetry',
'3.9.1',
'__tests__/data/**/poetry.lock',
poetryLockHash,
[
'/Users/patrick/Library/Caches/pypoetry/virtualenvs',
path.join(__dirname, 'data', 'inner', '.venv'),
path.join(__dirname, 'data', '.venv')
]
]
])( ])(
'restored dependencies for %s by primaryKey', 'restored dependencies for %s by primaryKey',
async ( async (packageManager, pythonVersion, dependencyFile, fileHash) => {
packageManager,
pythonVersion,
dependencyFile,
fileHash,
cachePaths
) => {
restoreCacheSpy.mockImplementation(
(cachePaths: string[], primaryKey: string, restoreKey?: string) => {
return primaryKey.includes(fileHash) ? primaryKey : '';
}
);
const cacheDistributor = getCacheDistributor( const cacheDistributor = getCacheDistributor(
packageManager, packageManager,
pythonVersion, pythonVersion,
dependencyFile dependencyFile
); );
await cacheDistributor.restoreCache(); await cacheDistributor.restoreCache();
if (cachePaths !== undefined) { expect(infoSpy).toHaveBeenCalledWith(
expect(saveStateSpy).toHaveBeenCalledWith( `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}`
State.CACHE_PATHS, );
cachePaths
);
}
if (process.platform === 'linux' && packageManager === 'pip') {
expect(infoSpy).toHaveBeenCalledWith(
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}`
);
} else if (packageManager === 'poetry') {
expect(infoSpy).toHaveBeenCalledWith(
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-v2-${fileHash}`
);
} else {
expect(infoSpy).toHaveBeenCalledWith(
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}`
);
}
}, },
30000 30000
); );
it.each([['pipenv', '3.9.12', 'requirements.txt', 'requirements.txt']])( it.each([
['pip', '3.8.12', 'requirements-linux.txt', 'requirements-linux.txt'],
['pip', '3.8.12', 'requirements.txt', 'requirements.txt'],
['pipenv', '3.9.12', 'requirements.txt', 'requirements.txt']
])(
'Should throw an error because dependency file is not found', 'Should throw an error because dependency file is not found',
async ( async (
packageManager, packageManager,
@ -214,58 +135,19 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
pythonVersion, pythonVersion,
dependencyFile dependencyFile
); );
await expect(cacheDistributor.restoreCache()).rejects.toThrowError(
await expect(cacheDistributor.restoreCache()).rejects.toThrow(
`No file in ${process.cwd()} matched to [${cacheDependencyPath `No file in ${process.cwd()} matched to [${cacheDependencyPath
.split('\n') .split('\n')
.join(',')}], make sure you have checked out the target repository` .join(',')}], make sure you have checked out the target repository`
); );
} }
); );
it.each([
['pip', '3.8.12', 'requirements-linux.txt'],
['pip', '3.8.12', 'requirements.txt']
])(
'Shouldn`t throw an error as there is a default file `pyproject.toml` to use when requirements.txt is not specified',
async (packageManager, pythonVersion, dependencyFile) => {
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
);
await expect(cacheDistributor.restoreCache()).resolves.not.toThrow();
}
);
it.each([
['pip', '3.8.12', 'requirements-linux.txt'],
['pip', '3.8.12', 'requirements.txt']
])(
'Should throw an error as there is no default file `pyproject.toml` to use when requirements.txt is not specified',
async (packageManager, pythonVersion, dependencyFile) => {
const cacheDistributor = getCacheDistributor(
packageManager,
pythonVersion,
dependencyFile
) as any; // Widening PipCache | PipenvCache | PoetryCache type to any allow us to change private property on the cacheDistributor to test value: "**/pyprojecttest.toml"
cacheDistributor.cacheDependencyBackupPath = '**/pyprojecttest.toml';
await expect(cacheDistributor.restoreCache()).rejects.toThrow();
}
);
}); });
describe('Dependencies changed', () => { describe('Dependencies changed', () => {
it.each([ it.each([
['pip', '3.8.12', '__tests__/data/**/requirements.txt', pipFileLockHash], ['pip', '3.8.12', undefined, pipFileLockHash],
[ ['pip', '3.8.12', '**/requirements-linux.txt', pipFileLockHash],
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
pipFileLockHash
],
[ [
'pip', 'pip',
'3.8.12', '3.8.12',
@ -273,9 +155,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
pipFileLockHash pipFileLockHash
], ],
['pip', '3.8.12', '__tests__/data/requirements.txt', pipFileLockHash], ['pip', '3.8.12', '__tests__/data/requirements.txt', pipFileLockHash],
['pipenv', '3.9.1', '__tests__/data/**/Pipfile.lock', requirementsHash], ['pipenv', '3.9.1', undefined, requirementsHash],
['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash], ['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash],
['poetry', '3.9.1', '__tests__/data/**/poetry.lock', requirementsHash] ['poetry', '3.9.1', undefined, requirementsHash]
])( ])(
'restored dependencies for %s by primaryKey', 'restored dependencies for %s by primaryKey',
async (packageManager, pythonVersion, dependencyFile, fileHash) => { async (packageManager, pythonVersion, dependencyFile, fileHash) => {

View file

@ -18,7 +18,7 @@ describe('run', () => {
let infoSpy: jest.SpyInstance; let infoSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance; let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance; let debugSpy: jest.SpyInstance;
let saveStateSpy: jest.SpyInstance; let saveSatetSpy: jest.SpyInstance;
let getStateSpy: jest.SpyInstance; let getStateSpy: jest.SpyInstance;
let getInputSpy: jest.SpyInstance; let getInputSpy: jest.SpyInstance;
let setFailedSpy: jest.SpyInstance; let setFailedSpy: jest.SpyInstance;
@ -43,8 +43,8 @@ describe('run', () => {
debugSpy = jest.spyOn(core, 'debug'); debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(input => undefined); debugSpy.mockImplementation(input => undefined);
saveStateSpy = jest.spyOn(core, 'saveState'); saveSatetSpy = jest.spyOn(core, 'saveState');
saveStateSpy.mockImplementation(input => undefined); saveSatetSpy.mockImplementation(input => undefined);
getStateSpy = jest.spyOn(core, 'getState'); getStateSpy = jest.spyOn(core, 'getState');
getStateSpy.mockImplementation(input => { getStateSpy.mockImplementation(input => {
@ -87,7 +87,6 @@ describe('run', () => {
describe('Validate unchanged cache is not saved', () => { describe('Validate unchanged cache is not saved', () => {
it('should not save cache for pip', async () => { it('should not save cache for pip', async () => {
inputs['cache'] = 'pip'; inputs['cache'] = 'pip';
inputs['python-version'] = '3.10.0';
await run(); await run();
@ -104,7 +103,22 @@ describe('run', () => {
it('should not save cache for pipenv', async () => { it('should not save cache for pipenv', async () => {
inputs['cache'] = 'pipenv'; inputs['cache'] = 'pipenv';
inputs['python-version'] = '3.10.0';
await run();
expect(getInputSpy).toHaveBeenCalled();
expect(debugSpy).toHaveBeenCalledWith(
`paths for caching are ${__dirname}`
);
expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(infoSpy).toHaveBeenCalledWith(
`Cache hit occurred on the primary key ${requirementsHash}, not saving cache.`
);
expect(setFailedSpy).not.toHaveBeenCalled();
});
it('should not save cache for pipenv', async () => {
inputs['cache'] = 'pipenv';
await run(); await run();
@ -123,7 +137,6 @@ describe('run', () => {
describe('action saves the cache', () => { describe('action saves the cache', () => {
it('saves cache from pip', async () => { it('saves cache from pip', async () => {
inputs['cache'] = 'pip'; inputs['cache'] = 'pip';
inputs['python-version'] = '3.10.0';
getStateSpy.mockImplementation((name: string) => { getStateSpy.mockImplementation((name: string) => {
if (name === State.CACHE_MATCHED_KEY) { if (name === State.CACHE_MATCHED_KEY) {
return requirementsHash; return requirementsHash;
@ -150,7 +163,6 @@ describe('run', () => {
it('saves cache from pipenv', async () => { it('saves cache from pipenv', async () => {
inputs['cache'] = 'pipenv'; inputs['cache'] = 'pipenv';
inputs['python-version'] = '3.10.0';
getStateSpy.mockImplementation((name: string) => { getStateSpy.mockImplementation((name: string) => {
if (name === State.CACHE_MATCHED_KEY) { if (name === State.CACHE_MATCHED_KEY) {
return pipFileLockHash; return pipFileLockHash;
@ -177,7 +189,6 @@ describe('run', () => {
it('saves cache from poetry', async () => { it('saves cache from poetry', async () => {
inputs['cache'] = 'poetry'; inputs['cache'] = 'poetry';
inputs['python-version'] = '3.10.0';
getStateSpy.mockImplementation((name: string) => { getStateSpy.mockImplementation((name: string) => {
if (name === State.CACHE_MATCHED_KEY) { if (name === State.CACHE_MATCHED_KEY) {
return poetryLockHash; return poetryLockHash;
@ -201,61 +212,6 @@ describe('run', () => {
); );
expect(setFailedSpy).not.toHaveBeenCalled(); expect(setFailedSpy).not.toHaveBeenCalled();
}); });
it('saves with -1 cacheId , should not fail workflow', async () => {
inputs['cache'] = 'poetry';
inputs['python-version'] = '3.10.0';
getStateSpy.mockImplementation((name: string) => {
if (name === State.STATE_CACHE_PRIMARY_KEY) {
return poetryLockHash;
} else if (name === State.CACHE_PATHS) {
return JSON.stringify([__dirname]);
} else {
return requirementsHash;
}
});
saveCacheSpy.mockImplementation(() => {
return -1;
});
await run();
expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(infoSpy).not.toHaveBeenCalled();
expect(saveCacheSpy).toHaveBeenCalled();
expect(infoSpy).not.toHaveBeenLastCalledWith(
`Cache saved with the key: ${poetryLockHash}`
);
expect(setFailedSpy).not.toHaveBeenCalled();
});
it('saves with error from toolkit, should not fail the workflow', async () => {
inputs['cache'] = 'npm';
inputs['python-version'] = '3.10.0';
getStateSpy.mockImplementation((name: string) => {
if (name === State.STATE_CACHE_PRIMARY_KEY) {
return poetryLockHash;
} else if (name === State.CACHE_PATHS) {
return JSON.stringify([__dirname]);
} else {
return requirementsHash;
}
});
saveCacheSpy.mockImplementation(() => {
throw new cache.ValidationError('Validation failed');
});
await run();
expect(getInputSpy).toHaveBeenCalled();
expect(getStateSpy).toHaveBeenCalledTimes(3);
expect(infoSpy).not.toHaveBeenCalledWith();
expect(saveCacheSpy).toHaveBeenCalled();
expect(setFailedSpy).not.toHaveBeenCalled();
});
}); });
afterEach(() => { afterEach(() => {

View file

@ -1,14 +0,0 @@
#!/bin/bash
set -euo pipefail
PYTHON_PATH="$1"
PATH_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')
PYTHON_PATH_EXECUTABLE=$("${PYTHON_PATH}" -c 'import sys; print(sys.executable)')
if [ "${PATH_EXECUTABLE}" != "${PYTHON_PATH_EXECUTABLE}" ]; then
echo "Executable mismatch."
echo "python in PATH is: ${PATH_EXECUTABLE}"
echo "python-path (${PYTHON_PATH}) is: ${PYTHON_PATH_EXECUTABLE}"
exit 1
fi
echo "python-path: ${PYTHON_PATH}"

View file

@ -4,8 +4,8 @@ verify_ssl = true
name = "pypi" name = "pypi"
[packages] [packages]
flake8 = "==6.0.0" numpy = "1.22.3"
numpy = "==1.25.1" pandas = "1.4.2"
[dev-packages] [dev-packages]

View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "dcea65dabfe8442466b5e9280ecab72cfa7bf555791ee0ad55b6e7255dca1f43" "sha256": "33e3640eff8b2b6c7149b85568151f39a66c544033b4b3f3f2ec9ad5ce6dfe7e"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -16,68 +16,81 @@
] ]
}, },
"default": { "default": {
"flake8": {
"hashes": [
"sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7",
"sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181"
],
"index": "pypi",
"version": "==6.0.0"
},
"mccabe": {
"hashes": [
"sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325",
"sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"
],
"markers": "python_version >= '3.6'",
"version": "==0.7.0"
},
"numpy": { "numpy": {
"hashes": [ "hashes": [
"sha256:012097b5b0d00a11070e8f2e261128c44157a8689f7dedcf35576e525893f4fe", "sha256:07a8c89a04997625236c5ecb7afe35a02af3896c8aa01890a849913a2309c676",
"sha256:0d3fe3dd0506a28493d82dc3cf254be8cd0d26f4008a417385cbf1ae95b54004", "sha256:08d9b008d0156c70dc392bb3ab3abb6e7a711383c3247b410b39962263576cd4",
"sha256:0def91f8af6ec4bb94c370e38c575855bf1d0be8a8fbfba42ef9c073faf2cf19", "sha256:201b4d0552831f7250a08d3b38de0d989d6f6e4658b709a02a73c524ccc6ffce",
"sha256:1a180429394f81c7933634ae49b37b472d343cccb5bb0c4a575ac8bbc433722f", "sha256:2c10a93606e0b4b95c9b04b77dc349b398fdfbda382d2a39ba5a822f669a0123",
"sha256:1d5d3c68e443c90b38fdf8ef40e60e2538a27548b39b12b73132456847f4b631", "sha256:3ca688e1b9b95d80250bca34b11a05e389b1420d00e87a0d12dc45f131f704a1",
"sha256:20e1266411120a4f16fad8efa8e0454d21d00b8c7cee5b5ccad7565d95eb42dd", "sha256:48a3aecd3b997bf452a2dedb11f4e79bc5bfd21a1d4cc760e703c31d57c84b3e",
"sha256:247d3ffdd7775bdf191f848be8d49100495114c82c2bd134e8d5d075fb386a1c", "sha256:568dfd16224abddafb1cbcce2ff14f522abe037268514dd7e42c6776a1c3f8e5",
"sha256:35a9527c977b924042170a0887de727cd84ff179e478481404c5dc66b4170009", "sha256:5bfb1bb598e8229c2d5d48db1860bcf4311337864ea3efdbe1171fb0c5da515d",
"sha256:38eb6548bb91c421261b4805dc44def9ca1a6eef6444ce35ad1669c0f1a3fc5d", "sha256:639b54cdf6aa4f82fe37ebf70401bbb74b8508fddcf4797f9fe59615b8c5813a",
"sha256:3d7abcdd85aea3e6cdddb59af2350c7ab1ed764397f8eec97a038ad244d2d105", "sha256:8251ed96f38b47b4295b1ae51631de7ffa8260b5b087808ef09a39a9d66c97ab",
"sha256:41a56b70e8139884eccb2f733c2f7378af06c82304959e174f8e7370af112e09", "sha256:92bfa69cfbdf7dfc3040978ad09a48091143cffb778ec3b03fa170c494118d75",
"sha256:4a90725800caeaa160732d6b31f3f843ebd45d6b5f3eec9e8cc287e30f2805bf", "sha256:97098b95aa4e418529099c26558eeb8486e66bd1e53a6b606d684d0c3616b168",
"sha256:6b82655dd8efeea69dbf85d00fca40013d7f503212bc5259056244961268b66e", "sha256:a3bae1a2ed00e90b3ba5f7bd0a7c7999b55d609e0c54ceb2b076a25e345fa9f4",
"sha256:6c6c9261d21e617c6dc5eacba35cb68ec36bb72adcff0dee63f8fbc899362588", "sha256:c34ea7e9d13a70bf2ab64a2532fe149a9aced424cd05a2c4ba662fd989e3e45f",
"sha256:77d339465dff3eb33c701430bcb9c325b60354698340229e1dff97745e6b3efa", "sha256:dbc7601a3b7472d559dc7b933b18b4b66f9aa7452c120e87dfb33d02008c8a18",
"sha256:791f409064d0a69dd20579345d852c59822c6aa087f23b07b1b4e28ff5880fcb", "sha256:e7927a589df200c5e23c57970bafbd0cd322459aa7b1ff73b7c2e84d6e3eae62",
"sha256:9a3a9f3a61480cc086117b426a8bd86869c213fc4072e606f01c4e4b66eb92bf", "sha256:f8c1f39caad2c896bc0018f699882b345b2a63708008be29b1f355ebf6f933fe",
"sha256:c1516db588987450b85595586605742879e50dcce923e8973f79529651545b57", "sha256:f950f8845b480cffe522913d35567e29dd381b0dc7e4ce6a4a9f9156417d2430",
"sha256:c40571fe966393b212689aa17e32ed905924120737194b5d5c1b20b9ed0fb171", "sha256:fade0d4f4d292b6f39951b6836d7a3c7ef5b2347f3c420cd9820a1d90d794802",
"sha256:d412c1697c3853c6fc3cb9751b4915859c7afe6a277c2bf00acf287d56c4e625", "sha256:fdf3c08bce27132395d3c3ba1503cac12e17282358cb4bddc25cc46b0aca07aa"
"sha256:d5154b1a25ec796b1aee12ac1b22f414f94752c5f94832f14d8d6c9ac40bcca6",
"sha256:d736b75c3f2cb96843a5c7f8d8ccc414768d34b0a75f466c05f3a739b406f10b",
"sha256:e8f6049c4878cb16960fbbfb22105e49d13d752d4d8371b55110941fb3b17800",
"sha256:f76aebc3358ade9eacf9bc2bb8ae589863a4f911611694103af05346637df1b7",
"sha256:fd67b306320dcadea700a8f79b9e671e607f8696e98ec255915c0c6d6b818503"
], ],
"index": "pypi", "index": "pypi",
"version": "==1.25.1" "version": "==1.22.3"
}, },
"pycodestyle": { "pandas": {
"hashes": [ "hashes": [
"sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053", "sha256:0010771bd9223f7afe5f051eb47c4a49534345dfa144f2f5470b27189a4dd3b5",
"sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610" "sha256:061609334a8182ab500a90fe66d46f6f387de62d3a9cb9aa7e62e3146c712167",
"sha256:09d8be7dd9e1c4c98224c4dfe8abd60d145d934e9fc1f5f411266308ae683e6a",
"sha256:295872bf1a09758aba199992c3ecde455f01caf32266d50abc1a073e828a7b9d",
"sha256:3228198333dd13c90b6434ddf61aa6d57deaca98cf7b654f4ad68a2db84f8cfe",
"sha256:385c52e85aaa8ea6a4c600a9b2821181a51f8be0aee3af6f2dcb41dafc4fc1d0",
"sha256:51649ef604a945f781105a6d2ecf88db7da0f4868ac5d45c51cb66081c4d9c73",
"sha256:5586cc95692564b441f4747c47c8a9746792e87b40a4680a2feb7794defb1ce3",
"sha256:5a206afa84ed20e07603f50d22b5f0db3fb556486d8c2462d8bc364831a4b417",
"sha256:5b79af3a69e5175c6fa7b4e046b21a646c8b74e92c6581a9d825687d92071b51",
"sha256:5c54ea4ef3823108cd4ec7fb27ccba4c3a775e0f83e39c5e17f5094cb17748bc",
"sha256:8c5bf555b6b0075294b73965adaafb39cf71c312e38c5935c93d78f41c19828a",
"sha256:92bc1fc585f1463ca827b45535957815b7deb218c549b7c18402c322c7549a12",
"sha256:95c1e422ced0199cf4a34385ff124b69412c4bc912011ce895582bee620dfcaa",
"sha256:b8134651258bce418cb79c71adeff0a44090c98d955f6953168ba16cc285d9f7",
"sha256:be67c782c4f1b1f24c2f16a157e12c2693fd510f8df18e3287c77f33d124ed07",
"sha256:c072c7f06b9242c855ed8021ff970c0e8f8b10b35e2640c657d2a541c5950f59",
"sha256:d0d4f13e4be7ce89d7057a786023c461dd9370040bdb5efa0a7fe76b556867a0",
"sha256:df82739e00bb6daf4bba4479a40f38c718b598a84654cbd8bb498fd6b0aa8c16",
"sha256:f549097993744ff8c41b5e8f2f0d3cbfaabe89b4ae32c8c08ead6cc535b80139",
"sha256:ff08a14ef21d94cdf18eef7c569d66f2e24e0bc89350bcd7d243dd804e3b5eb2"
], ],
"markers": "python_version >= '3.6'", "index": "pypi",
"version": "==2.10.0" "version": "==1.4.2"
}, },
"pyflakes": { "python-dateutil": {
"hashes": [ "hashes": [
"sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf", "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd" "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
], ],
"markers": "python_version >= '3.6'", "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==3.0.1" "version": "==2.8.2"
},
"pytz": {
"hashes": [
"sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7",
"sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"
],
"version": "==2022.1"
},
"six": {
"hashes": [
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==1.16.0"
} }
}, },
"develop": {} "develop": {}

File diff suppressed because it is too large Load diff

View file

@ -1 +0,0 @@
../poetry.lock

View file

@ -1 +0,0 @@
../pyproject.toml

View file

@ -1,2 +1,2 @@
numpy==1.22.3 numpy==1.22.3
flake8==6.0.0 pandas==1.4.2

View file

@ -1,15 +0,0 @@
[tool.poetry]
name = "testactiontasks"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.8"
flake8 = "^4.0.1"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View file

@ -1,94 +1,4 @@
[ [
{
"pypy_version": "7.3.8rc2",
"python_version": "3.8.12",
"stable": false,
"latest_pypy": false,
"date": "2022-02-11",
"files": [
{
"filename": "pypy3.8-v7.3.8rc2-linux32.tar.bz2",
"arch": "i686",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-linux32.tar.bz2"
},
{
"filename": "pypy3.8-v7.3.8rc2-linux64.tar.bz2",
"arch": "x64",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-linux64.tar.bz2"
},
{
"filename": "pypy3.8-v7.3.8rc2-darwin64.tar.bz2",
"arch": "x64",
"platform": "darwin",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-darwin64.tar.bz2"
},
{
"filename": "pypy3.8-v7.3.8rc2-s390x.tar.bz2",
"arch": "s390x",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-s390x.tar.bz2"
},
{
"filename": "pypy3.8-v7.3.8rc2-win64.zip",
"arch": "x64",
"platform": "win64",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-win64.zip"
},
{
"filename": "pypy3.8-v7.3.8rc2-win32.zip",
"arch": "x86",
"platform": "win32",
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-win32.zip"
}
]
},
{
"pypy_version": "7.4.0rc1",
"python_version": "3.6.12",
"stable": false,
"latest_pypy": false,
"date": "2021-11-11",
"files": [
{
"filename": "pypy3.6-v7.4.0rc1-aarch64.tar.bz2",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-aarch64.tar.bz2"
},
{
"filename": "pypy3.6-v7.4.0rc1-linux32.tar.bz2",
"arch": "i686",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-linux32.tar.bz2"
},
{
"filename": "pypy3.6-v7.4.0rc1-linux64.tar.bz2",
"arch": "x64",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-linux64.tar.bz2"
},
{
"filename": "pypy3.6-v7.4.0rc1-darwin64.tar.bz2",
"arch": "x64",
"platform": "darwin",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-darwin64.tar.bz2"
},
{
"filename": "pypy3.6-v7.4.0rc1-win32.zip",
"arch": "x86",
"platform": "win32",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-win32.zip"
},
{
"filename": "pypy3.6-v7.4.0rc1-s390x.tar.bz2",
"arch": "s390x",
"platform": "linux",
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-s390x.tar.bz2"
}
]
},
{ {
"pypy_version": "7.3.3", "pypy_version": "7.3.3",
"python_version": "3.6.12", "python_version": "3.6.12",
@ -620,4 +530,4 @@
} }
] ]
} }
] ]

View file

@ -1,29 +1,4 @@
[ [
{
"version": "1.2.4-beta.2",
"stable": false,
"release_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5",
"files": [
{
"filename": "sometool-1.2.4-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-linux-x64.tar.gz"
},
{
"filename": "sometool-1.2.4-darwin-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-darwin-x64.tar.gz"
},
{
"filename": "sometool-1.2.4-win32-x64.tar.gz",
"arch": "x64",
"platform": "win32",
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-win32-x64.tar.gz"
}
]
},
{ {
"version": "1.2.3", "version": "1.2.3",
"stable": true, "stable": true,
@ -50,28 +25,28 @@
] ]
}, },
{ {
"version": "1.1.0-beta.2", "version": "1.2.3-beta.2",
"stable": false, "stable": false,
"release_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5", "release_url": "https://github.com/actions/sometool/releases/tag/1.2.3-beta.2-20200402.5",
"files": [ "files": [
{ {
"filename": "sometool-1.1.0-linux-x64.tar.gz", "filename": "sometool-1.2.3-linux-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "linux", "platform": "linux",
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-linux-x64.tar.gz" "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.1.0-darwin-x64.tar.gz", "filename": "sometool-1.2.3-darwin-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "darwin", "platform": "darwin",
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-darwin-x64.tar.gz" "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.1.0-win32-x64.tar.gz", "filename": "sometool-1.2.3-win32-x64.tar.gz",
"arch": "x64", "arch": "x64",
"platform": "win32", "platform": "win32",
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-win32-x64.tar.gz" "download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.5/sometool-1.2.3-win32-x64.tar.gz"
} }
] ]
} }
] ]

View file

@ -1,378 +0,0 @@
import fs from 'fs';
import {HttpClient} from '@actions/http-client';
import * as ifm from '@actions/http-client/lib/interfaces';
import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as path from 'path';
import * as semver from 'semver';
import * as finder from '../src/find-graalpy';
import {IGraalPyManifestRelease, IS_WINDOWS} from '../src/utils';
import manifestData from './data/graalpy.json';
const architecture = 'x64';
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
/* GraalPy doesn't have a windows release yet */
const describeSkipOnWindows = IS_WINDOWS ? describe.skip : describe;
describe('parseGraalPyVersion', () => {
it.each([
['graalpy-23', '23'],
['graalpy-23.0', '23.0'],
['graalpy23.0', '23.0']
])('%s -> %s', (input, expected) => {
expect(finder.parseGraalPyVersion(input)).toEqual(expected);
});
it.each(['', 'graalpy-', 'graalpy', 'p', 'notgraalpy-'])(
'throw on invalid input "%s"',
input => {
expect(() => finder.parseGraalPyVersion(input)).toThrow(
"Invalid 'version' property for GraalPy. GraalPy version should be specified as 'graalpy<python-version>' or 'graalpy-<python-version>'. See README for examples and documentation."
);
}
);
});
describe('findGraalPyToolCache', () => {
const actualGraalPyVersion = '23.0.0';
const graalpyPath = path.join('GraalPy', actualGraalPyVersion, architecture);
let tcFind: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let addPathSpy: jest.SpyInstance;
let exportVariableSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance;
beforeEach(() => {
tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation((toolname: string, pythonVersion: string) => {
const semverVersion = new semver.Range(pythonVersion);
return semver.satisfies(actualGraalPyVersion, semverVersion)
? graalpyPath
: '';
});
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => null);
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
addPathSpy = jest.spyOn(core, 'addPath');
addPathSpy.mockImplementation(() => null);
exportVariableSpy = jest.spyOn(core, 'exportVariable');
exportVariableSpy.mockImplementation(() => null);
setOutputSpy = jest.spyOn(core, 'setOutput');
setOutputSpy.mockImplementation(() => null);
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it('GraalPy exists on the path and versions are satisfied', () => {
expect(finder.findGraalPyToolCache('23.0.0', architecture)).toEqual({
installDir: graalpyPath,
resolvedGraalPyVersion: actualGraalPyVersion
});
});
it('GraalPy exists on the path and versions are satisfied with semver', () => {
expect(finder.findGraalPyToolCache('23.0', architecture)).toEqual({
installDir: graalpyPath,
resolvedGraalPyVersion: actualGraalPyVersion
});
});
it("GraalPy exists on the path, but version doesn't match", () => {
expect(finder.findGraalPyToolCache('22.3', architecture)).toEqual({
installDir: '',
resolvedGraalPyVersion: ''
});
});
});
describeSkipOnWindows('findGraalPyVersion', () => {
let getBooleanInputSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let addPathSpy: jest.SpyInstance;
let exportVariableSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance;
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 spyFsReadDir: jest.SpyInstance;
let spyCacheDir: jest.SpyInstance;
let spyChmodSync: jest.SpyInstance;
let spyCoreAddPath: jest.SpyInstance;
let spyCoreExportVariable: jest.SpyInstance;
const env = process.env;
beforeEach(() => {
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(() => false);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
addPathSpy = jest.spyOn(core, 'addPath');
addPathSpy.mockImplementation(() => null);
exportVariableSpy = jest.spyOn(core, 'exportVariable');
exportVariableSpy.mockImplementation(() => null);
setOutputSpy = jest.spyOn(core, 'setOutput');
setOutputSpy.mockImplementation(() => null);
jest.resetModules();
process.env = {...env};
tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation((tool: string, version: string) => {
const semverRange = new semver.Range(version);
let graalpyPath = '';
if (semver.satisfies('23.0.0', semverRange)) {
graalpyPath = path.join(toolDir, 'GraalPy', '23.0.0', architecture);
}
return graalpyPath;
});
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy'));
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) => ['GraalPyTest']);
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockImplementation(
async (): Promise<ifm.TypedResponse<IGraalPyManifestRelease[]>> => {
const result = JSON.stringify(manifestData);
return {
statusCode: 200,
headers: {},
result: JSON.parse(result) as IGraalPyManifestRelease[]
};
}
);
spyExec = jest.spyOn(exec, 'exec');
spyExec.mockImplementation(() => undefined);
spySymlinkSync = jest.spyOn(fs, 'symlinkSync');
spySymlinkSync.mockImplementation(() => undefined);
spyExistsSync = jest.spyOn(fs, 'existsSync');
spyExistsSync.mockReturnValue(true);
spyCoreAddPath = jest.spyOn(core, 'addPath');
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
process.env = env;
});
it('found GraalPy in toolcache', async () => {
await expect(
finder.findGraalPyVersion(
'graalpy-23.0',
architecture,
true,
false,
false
)
).resolves.toEqual('23.0.0');
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
});
it('throw on invalid input format', async () => {
await expect(
finder.findGraalPyVersion('graalpy-x23', architecture, true, false, false)
).rejects.toThrow();
});
it('found and install successfully', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.0.0', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion(
'graalpy-23.0.0',
architecture,
true,
false,
false
)
).resolves.toEqual('23.0.0');
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
});
it('found and install successfully without environment update', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.0.0', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion(
'graalpy-23.0.0',
architecture,
false,
false,
false
)
).resolves.toEqual('23.0.0');
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
});
it('throw if release is not found', async () => {
await expect(
finder.findGraalPyVersion(
'graalpy-19.0.0',
architecture,
true,
false,
false
)
).rejects.toThrow(
`GraalPy version 19.0.0 with arch ${architecture} not found`
);
});
it('check-latest enabled version found and used from toolcache', async () => {
await expect(
finder.findGraalPyVersion(
'graalpy-23.0.0',
architecture,
false,
true,
false
)
).resolves.toEqual('23.0.0');
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});
it('check-latest enabled version found and install successfully', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.0.0', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion(
'graalpy-23.0.0',
architecture,
false,
true,
false
)
).resolves.toEqual('23.0.0');
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});
it('check-latest enabled version is not found and used from toolcache', async () => {
tcFind.mockImplementationOnce((tool: string, version: string) => {
const semverRange = new semver.Range(version);
let graalpyPath = '';
if (semver.satisfies('22.3.4', semverRange)) {
graalpyPath = path.join(toolDir, 'GraalPy', '22.3.4', architecture);
}
return graalpyPath;
});
await expect(
finder.findGraalPyVersion(
'graalpy-22.3.4',
architecture,
false,
true,
false
)
).resolves.toEqual('22.3.4');
expect(infoSpy).toHaveBeenCalledWith(
'Failed to resolve GraalPy 22.3.4 from manifest'
);
});
it('found and install successfully, pre-release fallback', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.1', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion(
'graalpy23.1',
architecture,
false,
false,
false
)
).rejects.toThrow();
await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true)
).resolves.toEqual('23.1.0-a.1');
});
});

View file

@ -2,10 +2,9 @@ import fs from 'fs';
import * as utils from '../src/utils'; import * as utils from '../src/utils';
import {HttpClient} from '@actions/http-client'; import {HttpClient} from '@actions/http-client';
import * as ifm from '@actions/http-client/lib/interfaces'; import * as ifm from '@actions/http-client/interfaces';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as path from 'path'; import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
@ -14,10 +13,11 @@ import * as finder from '../src/find-pypy';
import { import {
IPyPyManifestRelease, IPyPyManifestRelease,
IS_WINDOWS, IS_WINDOWS,
validateVersion,
getPyPyVersionFromPath getPyPyVersionFromPath
} from '../src/utils'; } from '../src/utils';
import manifestData from './data/pypy.json'; const manifestData = require('./data/pypy.json');
let architecture: string; let architecture: string;
@ -37,34 +37,16 @@ describe('parsePyPyVersion', () => {
['pypy-3.6-v7.x', {pythonVersion: '3.6', pypyVersion: 'v7.x'}], ['pypy-3.6-v7.x', {pythonVersion: '3.6', pypyVersion: 'v7.x'}],
['pypy-3.6', {pythonVersion: '3.6', pypyVersion: 'x'}], ['pypy-3.6', {pythonVersion: '3.6', pypyVersion: 'x'}],
['pypy-3.6-nightly', {pythonVersion: '3.6', pypyVersion: 'nightly'}], ['pypy-3.6-nightly', {pythonVersion: '3.6', pypyVersion: 'nightly'}],
['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}], ['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}]
['pypy3.8-v7.3.7', {pythonVersion: '3.8', pypyVersion: 'v7.3.7'}],
['pypy3.8-v7.3.x', {pythonVersion: '3.8', pypyVersion: 'v7.3.x'}],
['pypy3.8-v7.x', {pythonVersion: '3.8', pypyVersion: 'v7.x'}],
['pypy3.8', {pythonVersion: '3.8', pypyVersion: 'x'}],
['pypy3.9-nightly', {pythonVersion: '3.9', pypyVersion: 'nightly'}],
['pypy3.9-v7.3.8rc1', {pythonVersion: '3.9', pypyVersion: 'v7.3.8-rc.1'}]
])('%s -> %s', (input, expected) => { ])('%s -> %s', (input, expected) => {
expect(finder.parsePyPyVersion(input)).toEqual(expected); expect(finder.parsePyPyVersion(input)).toEqual(expected);
}); });
it.each(['', 'pypy-', 'pypy', 'p', 'notpypy-'])( it('throw on invalid input', () => {
'throw on invalid input "%s"', expect(() => finder.parsePyPyVersion('pypy-')).toThrowError(
input => { "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
expect(() => finder.parsePyPyVersion(input)).toThrow( );
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy<python-version>' or 'pypy-<python-version>'. See README for examples and documentation." });
);
}
);
it.each(['pypy-2', 'pypy-3', 'pypy2', 'pypy3', 'pypy3.x', 'pypy3.8.10'])(
'throw on invalid input "%s"',
input => {
expect(() => finder.parsePyPyVersion(input)).toThrow(
"Invalid format of Python version for PyPy. Python version should be specified in format 'x.y'. See README for examples and documentation."
);
}
);
}); });
describe('getPyPyVersionFromPath', () => { describe('getPyPyVersionFromPath', () => {
@ -81,12 +63,6 @@ describe('findPyPyToolCache', () => {
const pypyPath = path.join('PyPy', actualPythonVersion, architecture); const pypyPath = path.join('PyPy', actualPythonVersion, architecture);
let tcFind: jest.SpyInstance; let tcFind: jest.SpyInstance;
let spyReadExactPyPyVersion: jest.SpyInstance; let spyReadExactPyPyVersion: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let addPathSpy: jest.SpyInstance;
let exportVariableSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
tcFind = jest.spyOn(tc, 'find'); tcFind = jest.spyOn(tc, 'find');
@ -99,24 +75,6 @@ describe('findPyPyToolCache', () => {
spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile'); spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile');
spyReadExactPyPyVersion.mockImplementation(() => actualPyPyVersion); spyReadExactPyPyVersion.mockImplementation(() => actualPyPyVersion);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => null);
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
addPathSpy = jest.spyOn(core, 'addPath');
addPathSpy.mockImplementation(() => null);
exportVariableSpy = jest.spyOn(core, 'exportVariable');
exportVariableSpy.mockImplementation(() => null);
setOutputSpy = jest.spyOn(core, 'setOutput');
setOutputSpy.mockImplementation(() => null);
}); });
afterEach(() => { afterEach(() => {
@ -159,13 +117,6 @@ describe('findPyPyToolCache', () => {
}); });
describe('findPyPyVersion', () => { describe('findPyPyVersion', () => {
let getBooleanInputSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let addPathSpy: jest.SpyInstance;
let exportVariableSpy: jest.SpyInstance;
let setOutputSpy: jest.SpyInstance;
let tcFind: jest.SpyInstance; let tcFind: jest.SpyInstance;
let spyExtractZip: jest.SpyInstance; let spyExtractZip: jest.SpyInstance;
let spyExtractTar: jest.SpyInstance; let spyExtractTar: jest.SpyInstance;
@ -179,34 +130,8 @@ describe('findPyPyVersion', () => {
let spyWriteExactPyPyVersionFile: jest.SpyInstance; let spyWriteExactPyPyVersionFile: jest.SpyInstance;
let spyCacheDir: jest.SpyInstance; let spyCacheDir: jest.SpyInstance;
let spyChmodSync: jest.SpyInstance; let spyChmodSync: jest.SpyInstance;
let spyCoreAddPath: jest.SpyInstance;
let spyCoreExportVariable: jest.SpyInstance;
const env = process.env;
beforeEach(() => { beforeEach(() => {
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(() => false);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
addPathSpy = jest.spyOn(core, 'addPath');
addPathSpy.mockImplementation(() => null);
exportVariableSpy = jest.spyOn(core, 'exportVariable');
exportVariableSpy.mockImplementation(() => null);
setOutputSpy = jest.spyOn(core, 'setOutput');
setOutputSpy.mockImplementation(() => null);
jest.resetModules();
process.env = {...env};
tcFind = jest.spyOn(tc, 'find'); tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation((tool: string, version: string) => { tcFind.mockImplementation((tool: string, version: string) => {
const semverRange = new semver.Range(version); const semverRange = new semver.Range(version);
@ -240,7 +165,7 @@ describe('findPyPyVersion', () => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockImplementation( spyHttpClient.mockImplementation(
async (): Promise<ifm.TypedResponse<IPyPyManifestRelease[]>> => { async (): Promise<ifm.ITypedResponse<IPyPyManifestRelease[]>> => {
const result = JSON.stringify(manifestData); const result = JSON.stringify(manifestData);
return { return {
statusCode: 200, statusCode: 200,
@ -258,52 +183,32 @@ describe('findPyPyVersion', () => {
spyExistsSync = jest.spyOn(fs, 'existsSync'); spyExistsSync = jest.spyOn(fs, 'existsSync');
spyExistsSync.mockReturnValue(true); spyExistsSync.mockReturnValue(true);
spyCoreAddPath = jest.spyOn(core, 'addPath');
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
}); });
afterEach(() => { afterEach(() => {
jest.resetAllMocks(); jest.resetAllMocks();
jest.clearAllMocks(); jest.clearAllMocks();
jest.restoreAllMocks(); jest.restoreAllMocks();
process.env = env;
}); });
it('found PyPy in toolcache', async () => { it('found PyPy in toolcache', async () => {
await expect( await expect(
finder.findPyPyVersion( finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture)
'pypy-3.6-v7.3.x',
architecture,
true,
false,
false
)
).resolves.toEqual({ ).resolves.toEqual({
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.3.3' resolvedPyPyVersion: '7.3.3'
}); });
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
}); });
it('throw on invalid input format', async () => { it('throw on invalid input format', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false, false) finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
).rejects.toThrow(); ).rejects.toThrow();
}); });
it('throw on invalid input format pypy3.7-7.3.x', async () => { it('throw on invalid input format pypy3.7-7.3.x', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false, false) finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
).rejects.toThrow(); ).rejects.toThrow();
}); });
@ -315,150 +220,18 @@ describe('findPyPyVersion', () => {
spyChmodSync = jest.spyOn(fs, 'chmodSync'); spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined); spyChmodSync.mockImplementation(() => undefined);
await expect( await expect(
finder.findPyPyVersion( finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture)
'pypy-3.7-v7.3.x',
architecture,
true,
false,
false
)
).resolves.toEqual({ ).resolves.toEqual({
resolvedPythonVersion: '3.7.9', resolvedPythonVersion: '3.7.9',
resolvedPyPyVersion: '7.3.3' resolvedPyPyVersion: '7.3.3'
}); });
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
});
it('found and install successfully without environment update', 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,
false,
false,
false
)
).resolves.toEqual({
resolvedPythonVersion: '3.7.9',
resolvedPyPyVersion: '7.3.3'
});
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
}); });
it('throw if release is not found', async () => { it('throw if release is not found', async () => {
await expect( await expect(
finder.findPyPyVersion( finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture)
'pypy-3.7-v7.5.x', ).rejects.toThrowError(
architecture,
true,
false,
false
)
).rejects.toThrow(
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found` `PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
); );
}); });
it('check-latest enabled version found and used from toolcache', async () => {
await expect(
finder.findPyPyVersion(
'pypy-3.6-v7.3.x',
architecture,
false,
true,
false
)
).resolves.toEqual({
resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as PyPy 7.3.3 with Python (3.6.12)'
);
});
it('check-latest enabled version 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,
false,
true,
false
)
).resolves.toEqual({
resolvedPythonVersion: '3.7.9',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as PyPy 7.3.3 with Python (3.7.9)'
);
});
it('check-latest enabled version is not found and used from toolcache', async () => {
tcFind.mockImplementationOnce((tool: string, version: string) => {
const semverRange = new semver.Range(version);
let pypyPath = '';
if (semver.satisfies('3.8.8', semverRange)) {
pypyPath = path.join(toolDir, 'PyPy', '3.8.8', architecture);
}
return pypyPath;
});
await expect(
finder.findPyPyVersion(
'pypy-3.8-v7.3.x',
architecture,
false,
true,
false
)
).resolves.toEqual({
resolvedPythonVersion: '3.8.8',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Failed to resolve PyPy v7.3.x with Python (3.8) from manifest'
);
});
it('found and install successfully, pre-release fallback', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'PyPy', '3.8.12', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findPyPyVersion('pypy3.8', architecture, false, false, false)
).rejects.toThrow();
await expect(
finder.findPyPyVersion('pypy3.8', architecture, false, false, true)
).resolves.toEqual({
resolvedPythonVersion: '3.8.12',
resolvedPyPyVersion: '7.3.8rc2'
});
});
}); });

View file

@ -1,7 +1,6 @@
import * as io from '@actions/io'; import io = require('@actions/io');
import os from 'os'; import fs = require('fs');
import fs from 'fs'; import path = require('path');
import path from 'path';
const toolDir = path.join( const toolDir = path.join(
__dirname, __dirname,
@ -20,71 +19,29 @@ process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir; process.env['RUNNER_TEMP'] = tempDir;
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as core from '@actions/core';
import * as finder from '../src/find-python'; import * as finder from '../src/find-python';
import * as installer from '../src/install-python'; import * as installer from '../src/install-python';
import manifestData from './data/versions-manifest.json'; const manifestData = require('./data/versions-manifest.json');
describe('Finder tests', () => { describe('Finder tests', () => {
let writeSpy: jest.SpyInstance;
let spyCoreAddPath: jest.SpyInstance;
let spyCoreExportVariable: jest.SpyInstance;
const env = process.env;
beforeEach(() => {
writeSpy = jest.spyOn(process.stdout, 'write');
writeSpy.mockImplementation(() => {});
jest.resetModules();
process.env = {...env};
spyCoreAddPath = jest.spyOn(core, 'addPath');
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
});
afterEach(() => { afterEach(() => {
jest.resetAllMocks(); jest.resetAllMocks();
jest.clearAllMocks(); jest.clearAllMocks();
jest.restoreAllMocks();
process.env = env;
}); });
it('Finds Python if it is installed', async () => { it('Finds Python if it is installed', async () => {
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(input => false);
const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64');
await io.mkdirP(pythonDir); await io.mkdirP(pythonDir);
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); 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) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
await finder.useCpythonVersion('3.x', 'x64', true, false, false); await finder.useCpythonVersion('3.x', 'x64');
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
});
it('Finds Python if it is installed without environment update', 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 and in the manifest (because no such version exists)
await finder.useCpythonVersion('3.x', 'x64', false, false, false);
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
}); });
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => { it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo'); const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData); findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(input => false);
const installSpy: jest.SpyInstance = jest.spyOn( const installSpy: jest.SpyInstance = jest.spyOn(
installer, installer,
'installCpythonFromRelease' 'installCpythonFromRelease'
@ -95,30 +52,13 @@ describe('Finder tests', () => {
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); 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) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
await expect( await finder.useCpythonVersion('1.2.3', 'x64');
finder.useCpythonVersion('1.2.3', 'x64', true, false, false)
).resolves.toEqual({
impl: 'CPython',
version: '1.2.3'
});
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
}); });
it('Finds pre-release Python version in the manifest', async () => { it('Finds pre-release Python version in the manifest', async () => {
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo'); const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData); findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(input => false);
const installSpy: jest.SpyInstance = jest.spyOn( const installSpy: jest.SpyInstance = jest.spyOn(
installer, installer,
'installCpythonFromRelease' 'installCpythonFromRelease'
@ -127,154 +67,24 @@ describe('Finder tests', () => {
const pythonDir: string = path.join( const pythonDir: string = path.join(
toolDir, toolDir,
'Python', 'Python',
'1.2.4-beta.2', '1.2.3-beta.2',
'x64' 'x64'
); );
await io.mkdirP(pythonDir); await io.mkdirP(pythonDir);
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); fs.writeFileSync(`${pythonDir}.complete`, 'hello');
}); });
// This will throw if it doesn't find it in the manifest (because no such version exists) // This will throw if it doesn't find it in the manifest (because no such version exists)
await expect( await finder.useCpythonVersion('1.2.3-beta.2', 'x64');
finder.useCpythonVersion('1.2.4-beta.2', 'x64', false, false, false)
).resolves.toEqual({
impl: 'CPython',
version: '1.2.4-beta.2'
});
});
it('Check-latest true, finds the latest version in the manifest', async () => {
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(input => true);
const cnSpy: jest.SpyInstance = jest.spyOn(process.stdout, 'write');
cnSpy.mockImplementation(line => {
// uncomment to debug
// process.stderr.write('write:' + line + '\n');
});
const addPathSpy: jest.SpyInstance = jest.spyOn(core, 'addPath');
addPathSpy.mockImplementation(() => null);
const infoSpy: jest.SpyInstance = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
const debugSpy: jest.SpyInstance = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => {});
const pythonDir: string = path.join(toolDir, 'Python', '1.2.2', 'x64');
const expPath: string = path.join(toolDir, 'Python', '1.2.3', 'x64');
const installSpy: jest.SpyInstance = jest.spyOn(
installer,
'installCpythonFromRelease'
);
installSpy.mockImplementation(async () => {
await io.mkdirP(expPath);
fs.writeFileSync(`${expPath}.complete`, 'hello');
});
const tcFindSpy: jest.SpyInstance = jest.spyOn(tc, 'find');
tcFindSpy
.mockImplementationOnce(() => '')
.mockImplementationOnce(() => expPath);
await io.mkdirP(pythonDir);
await io.rmRF(path.join(toolDir, 'Python', '1.2.3'));
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.useCpythonVersion('1.2', 'x64', true, true, false);
expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'");
expect(infoSpy).toHaveBeenCalledWith(
'Version 1.2.3 was not found in the local cache'
);
expect(infoSpy).toHaveBeenCalledWith(
'Version 1.2.3 is available for downloading'
);
expect(installSpy).toHaveBeenCalled();
expect(addPathSpy).toHaveBeenCalledWith(expPath);
await finder.useCpythonVersion('1.2.4-beta.2', 'x64', false, true, false);
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'pythonLocation',
expect.anything()
);
expect(spyCoreExportVariable).toHaveBeenCalledWith(
'PKG_CONFIG_PATH',
expect.anything()
);
});
it('Finds stable Python version if it is not installed, but exists in the manifest, skipping newer pre-release', 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 expect(
finder.useCpythonVersion('1.2', 'x64', false, false, false)
).resolves.toEqual({
impl: 'CPython',
version: '1.2.3'
});
});
it('Finds Python version if it is not installed, but exists in the manifest, pre-release fallback', 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.1.0-beta.2',
'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 expect(
finder.useCpythonVersion('1.1', 'x64', false, false, false)
).rejects.toThrow();
await expect(
finder.useCpythonVersion('1.1', 'x64', false, false, true)
).resolves.toEqual({
impl: 'CPython',
version: '1.1.0-beta.2'
});
// Check 1.1.0 version specifier does not fallback to '1.1.0-beta.2'
await expect(
finder.useCpythonVersion('1.1.0', 'x64', false, false, true)
).rejects.toThrow();
}); });
it('Errors if Python is not installed', async () => { it('Errors if Python is not installed', async () => {
// This will throw if it doesn't find it in the cache and in the manifest (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; let thrown = false;
try { try {
await finder.useCpythonVersion('3.300000', 'x64', true, false, false); await finder.useCpythonVersion('3.300000', 'x64');
} catch { } catch {
thrown = true; thrown = true;
} }
expect(thrown).toBeTruthy(); expect(thrown).toBeTruthy();
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
}); });
}); });

View file

@ -1,256 +0,0 @@
import fs from 'fs';
import {HttpClient} from '@actions/http-client';
import * as ifm from '@actions/http-client/lib/interfaces';
import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as path from 'path';
import * as installer from '../src/install-graalpy';
import {
IGraalPyManifestRelease,
IGraalPyManifestAsset,
IS_WINDOWS
} from '../src/utils';
import manifestData from './data/graalpy.json';
const architecture = 'x64';
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
/* GraalPy doesn't have a windows release yet */
const describeSkipOnWindows = IS_WINDOWS ? describe.skip : describe;
describe('graalpyVersionToSemantic', () => {
it.each([
['23.0.0a1', '23.0.0a1'],
['23.0.0', '23.0.0'],
['23.0.x', '23.0.x'],
['23.x', '23.x']
])('%s -> %s', (input, expected) => {
expect(installer.graalPyTagToVersion(input)).toEqual(expected);
});
});
describeSkipOnWindows('findRelease', () => {
const result = JSON.stringify(manifestData);
const releases = JSON.parse(result) as IGraalPyManifestRelease[];
const extension = 'tar.gz';
const arch = installer.toGraalPyArchitecture(architecture);
const platform = installer.toGraalPyPlatform(process.platform);
const extensionName = `${platform}-${arch}.${extension}`;
const files: IGraalPyManifestAsset = {
name: `graalpython-23.0.0-${extensionName}`,
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.0.0/graalpython-23.0.0-${extensionName}`
};
const filesRC1: IGraalPyManifestAsset = {
name: `graalpython-23.1.0a1-${extensionName}`,
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.1.0a1/graalpython-23.1.0a1-${extensionName}`
};
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
beforeEach(() => {
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
});
it("GraalPy version doesn't match", () => {
const graalpyVersion = '12.0.0';
expect(
installer.findRelease(releases, graalpyVersion, architecture, false)
).toEqual(null);
});
it('GraalPy version matches', () => {
const graalpyVersion = '23.0.0';
expect(
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: graalpyVersion
});
});
it('Preview version of GraalPy is found', () => {
const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1');
expect(
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: {
name: `graalpython-23.1.0a1-${extensionName}`,
browser_download_url: `https://github.com/oracle/graalpython/releases/download/graal-23.1.0a1/graalpython-23.1.0a1-${extensionName}`
},
resolvedGraalPyVersion: '23.1.0-a.1'
});
});
it('Latest GraalPy is found', () => {
const graalpyVersion = 'x';
expect(
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: '23.0.0'
});
});
it('GraalPy version matches semver (pre-release)', () => {
const graalpyVersion = '23.1.x';
expect(
installer.findRelease(releases, graalpyVersion, architecture, false)
).toBeNull();
expect(
installer.findRelease(releases, graalpyVersion, architecture, true)
).toMatchObject({
foundAsset: filesRC1,
resolvedGraalPyVersion: '23.1.0-a.1'
});
});
});
describeSkipOnWindows('installGraalPy', () => {
let tcFind: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: 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('GraalPy', '3.6.12', architecture)
);
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy'));
spyExtractZip = jest.spyOn(tc, 'extractZip');
spyExtractZip.mockImplementation(() => tempDir);
spyExtractTar = jest.spyOn(tc, 'extractTar');
spyExtractTar.mockImplementation(() => tempDir);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
spyFsReadDir = jest.spyOn(fs, 'readdirSync');
spyFsReadDir.mockImplementation(() => ['GraalPyTest']);
spyFsWriteFile = jest.spyOn(fs, 'writeFileSync');
spyFsWriteFile.mockImplementation(() => undefined);
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockImplementation(
async (): Promise<ifm.TypedResponse<IGraalPyManifestRelease[]>> => {
const result = JSON.stringify(manifestData);
return {
statusCode: 200,
headers: {},
result: JSON.parse(result) as IGraalPyManifestRelease[]
};
}
);
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.installGraalPy('7.3.3', architecture, false, undefined)
).rejects.toThrow(
`GraalPy version 7.3.3 with arch ${architecture} not found`
);
expect(spyHttpClient).toHaveBeenCalled();
expect(spyDownloadTool).not.toHaveBeenCalled();
expect(spyExec).not.toHaveBeenCalled();
});
it('found and install GraalPy', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '21.3.0', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
installer.installGraalPy('21.x', architecture, false, undefined)
).resolves.toEqual({
installDir: path.join(toolDir, 'GraalPy', '21.3.0', architecture),
resolvedGraalPyVersion: '21.3.0'
});
expect(spyHttpClient).toHaveBeenCalled();
expect(spyDownloadTool).toHaveBeenCalled();
expect(spyCacheDir).toHaveBeenCalled();
expect(spyExec).toHaveBeenCalled();
});
it('found and install GraalPy, pre-release fallback', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'GraalPy', '23.1.0', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
installer.installGraalPy('23.1.x', architecture, false, undefined)
).rejects.toThrow();
await expect(
installer.installGraalPy('23.1.x', architecture, true, undefined)
).resolves.toEqual({
installDir: path.join(toolDir, 'GraalPy', '23.1.0', architecture),
resolvedGraalPyVersion: '23.1.0-a.1'
});
expect(spyHttpClient).toHaveBeenCalled();
expect(spyDownloadTool).toHaveBeenCalled();
expect(spyCacheDir).toHaveBeenCalled();
expect(spyExec).toHaveBeenCalled();
});
});

View file

@ -1,10 +1,9 @@
import fs from 'fs'; import fs from 'fs';
import {HttpClient} from '@actions/http-client'; import {HttpClient} from '@actions/http-client';
import * as ifm from '@actions/http-client/lib/interfaces'; import * as ifm from '@actions/http-client/interfaces';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as path from 'path'; import * as path from 'path';
import * as installer from '../src/install-pypy'; import * as installer from '../src/install-pypy';
@ -14,7 +13,7 @@ import {
IS_WINDOWS IS_WINDOWS
} from '../src/utils'; } from '../src/utils';
import manifestData from './data/pypy.json'; const manifestData = require('./data/pypy.json');
let architecture: string; let architecture: string;
if (IS_WINDOWS) { if (IS_WINDOWS) {
@ -51,40 +50,12 @@ describe('findRelease', () => {
platform: process.platform, platform: process.platform,
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}` download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}`
}; };
const filesRC1: IPyPyManifestAsset = {
filename: `pypy3.6-v7.4.0rc1-${extensionName}`,
arch: architecture,
platform: process.platform,
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-${extensionName}`
};
let getBooleanInputSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
beforeEach(() => {
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
});
it("Python version is found, but PyPy version doesn't match", () => { it("Python version is found, but PyPy version doesn't match", () => {
const pythonVersion = '3.6'; const pythonVersion = '3.6';
const pypyVersion = '7.3.7'; const pypyVersion = '7.3.7';
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual(null); ).toEqual(null);
}); });
@ -92,13 +63,7 @@ describe('findRelease', () => {
const pythonVersion = '3.6'; const pythonVersion = '3.6';
const pypyVersion = '7.3.3'; const pypyVersion = '7.3.3';
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual({ ).toEqual({
foundAsset: files, foundAsset: files,
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
@ -110,13 +75,7 @@ describe('findRelease', () => {
const pythonVersion = '3.6'; const pythonVersion = '3.6';
const pypyVersion = '7.x'; const pypyVersion = '7.x';
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual({ ).toEqual({
foundAsset: files, foundAsset: files,
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
@ -128,13 +87,7 @@ describe('findRelease', () => {
const pythonVersion = '3.7'; const pythonVersion = '3.7';
const pypyVersion = installer.pypyVersionToSemantic('7.3.3rc2'); const pypyVersion = installer.pypyVersionToSemantic('7.3.3rc2');
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual({ ).toEqual({
foundAsset: { foundAsset: {
filename: `test${extension}`, filename: `test${extension}`,
@ -151,13 +104,7 @@ describe('findRelease', () => {
const pythonVersion = '3.6'; const pythonVersion = '3.6';
const pypyVersion = 'x'; const pypyVersion = 'x';
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual({ ).toEqual({
foundAsset: files, foundAsset: files,
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
@ -165,45 +112,12 @@ describe('findRelease', () => {
}); });
}); });
it('Python version and PyPy version matches semver (pre-release)', () => {
const pythonVersion = '3.6';
const pypyVersion = '7.4.x';
expect(
installer.findRelease(
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toBeNull();
expect(
installer.findRelease(
releases,
pythonVersion,
pypyVersion,
architecture,
true
)
).toEqual({
foundAsset: filesRC1,
resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.4.0rc1'
});
});
it('Nightly release is found', () => { it('Nightly release is found', () => {
const pythonVersion = '3.6'; const pythonVersion = '3.6';
const pypyVersion = 'nightly'; const pypyVersion = 'nightly';
const filename = IS_WINDOWS ? 'filename.zip' : 'filename.tar.bz2'; const filename = IS_WINDOWS ? 'filename.zip' : 'filename.tar.bz2';
expect( expect(
installer.findRelease( installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
releases,
pythonVersion,
pypyVersion,
architecture,
false
)
).toEqual({ ).toEqual({
foundAsset: { foundAsset: {
filename: filename, filename: filename,
@ -219,10 +133,6 @@ describe('findRelease', () => {
describe('installPyPy', () => { describe('installPyPy', () => {
let tcFind: jest.SpyInstance; let tcFind: jest.SpyInstance;
let getBooleanInputSpy: jest.SpyInstance;
let warningSpy: jest.SpyInstance;
let debugSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let spyExtractZip: jest.SpyInstance; let spyExtractZip: jest.SpyInstance;
let spyExtractTar: jest.SpyInstance; let spyExtractTar: jest.SpyInstance;
let spyFsReadDir: jest.SpyInstance; let spyFsReadDir: jest.SpyInstance;
@ -248,15 +158,6 @@ describe('installPyPy', () => {
spyExtractTar = jest.spyOn(tc, 'extractTar'); spyExtractTar = jest.spyOn(tc, 'extractTar');
spyExtractTar.mockImplementation(() => tempDir); spyExtractTar.mockImplementation(() => tempDir);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
warningSpy = jest.spyOn(core, 'warning');
warningSpy.mockImplementation(() => null);
debugSpy = jest.spyOn(core, 'debug');
debugSpy.mockImplementation(() => null);
spyFsReadDir = jest.spyOn(fs, 'readdirSync'); spyFsReadDir = jest.spyOn(fs, 'readdirSync');
spyFsReadDir.mockImplementation(() => ['PyPyTest']); spyFsReadDir.mockImplementation(() => ['PyPyTest']);
@ -265,7 +166,7 @@ describe('installPyPy', () => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockImplementation( spyHttpClient.mockImplementation(
async (): Promise<ifm.TypedResponse<IPyPyManifestRelease[]>> => { async (): Promise<ifm.ITypedResponse<IPyPyManifestRelease[]>> => {
const result = JSON.stringify(manifestData); const result = JSON.stringify(manifestData);
return { return {
statusCode: 200, statusCode: 200,
@ -293,8 +194,8 @@ describe('installPyPy', () => {
it('throw if release is not found', async () => { it('throw if release is not found', async () => {
await expect( await expect(
installer.installPyPy('7.3.3', '3.6.17', architecture, false, undefined) installer.installPyPy('7.3.3', '3.6.17', architecture)
).rejects.toThrow( ).rejects.toThrowError(
`PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found` `PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found`
); );
@ -313,7 +214,7 @@ describe('installPyPy', () => {
spyChmodSync.mockImplementation(() => undefined); spyChmodSync.mockImplementation(() => undefined);
await expect( await expect(
installer.installPyPy('7.x', '3.6.12', architecture, false, undefined) installer.installPyPy('7.3.x', '3.6.12', architecture)
).resolves.toEqual({ ).resolves.toEqual({
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture), installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
@ -326,31 +227,4 @@ describe('installPyPy', () => {
expect(spyCacheDir).toHaveBeenCalled(); expect(spyCacheDir).toHaveBeenCalled();
expect(spyExec).toHaveBeenCalled(); expect(spyExec).toHaveBeenCalled();
}); });
it('found and install PyPy, pre-release fallback', 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.4.x', '3.6.12', architecture, false, undefined)
).rejects.toThrow();
await expect(
installer.installPyPy('7.4.x', '3.6.12', architecture, true, undefined)
).resolves.toEqual({
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.4.0rc1'
});
expect(spyHttpClient).toHaveBeenCalled();
expect(spyDownloadTool).toHaveBeenCalled();
expect(spyExistsSync).toHaveBeenCalled();
expect(spyCacheDir).toHaveBeenCalled();
expect(spyExec).toHaveBeenCalled();
});
}); });

View file

@ -1,7 +0,0 @@
import numpy as np
a = np.array([2, 3, 4])
print(type(a))
b = np.array([1.2, 3.5, 5.1])
print(type(b))

View file

@ -1,18 +1,9 @@
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as io from '@actions/io';
import fs from 'fs';
import path from 'path';
import { import {
validateVersion, validateVersion,
validatePythonVersionFormatForPyPy, validatePythonVersionFormatForPyPy,
isCacheFeatureAvailable, isCacheFeatureAvailable
getVersionInputFromFile,
getVersionInputFromPlainFile,
getVersionInputFromTomlFile,
getNextPageUrl
} from '../src/utils'; } from '../src/utils';
jest.mock('@actions/cache'); jest.mock('@actions/cache');
@ -51,13 +42,14 @@ describe('validateVersion', () => {
describe('isCacheFeatureAvailable', () => { describe('isCacheFeatureAvailable', () => {
it('isCacheFeatureAvailable disabled on GHES', () => { it('isCacheFeatureAvailable disabled on GHES', () => {
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false); jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
const infoMock = jest.spyOn(core, 'warning');
const message =
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.';
try { try {
process.env['GITHUB_SERVER_URL'] = 'http://example.com'; process.env['GITHUB_SERVER_URL'] = 'http://example.com';
expect(isCacheFeatureAvailable()).toBeFalsy(); isCacheFeatureAvailable();
expect(infoMock).toHaveBeenCalledWith(message); } catch (error) {
expect(error).toHaveProperty(
'message',
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
} finally { } finally {
delete process.env['GITHUB_SERVER_URL']; delete process.env['GITHUB_SERVER_URL'];
} }
@ -82,80 +74,3 @@ describe('isCacheFeatureAvailable', () => {
expect(isCacheFeatureAvailable()).toBe(true); expect(isCacheFeatureAvailable()).toBe(true);
}); });
}); });
const tempDir = path.join(
__dirname,
'runner',
path.join(Math.random().toString(36).substring(7)),
'temp'
);
describe('Version from file test', () => {
it.each([getVersionInputFromPlainFile, getVersionInputFromFile])(
'Version from plain file test',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'python-version.file';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersionFileContent = '3.7';
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersionFileContent]);
}
);
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
'Version from standard pyproject.toml test',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'pyproject.toml';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '>=3.7.0';
const pythonVersionFileContent = `[project]\nrequires-python = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
'Version from poetry pyproject.toml test',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'pyproject.toml';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '>=3.7.0';
const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
'Version undefined',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'pyproject.toml';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
fs.writeFileSync(pythonVersionFilePath, ``);
expect(_fn(pythonVersionFilePath)).toEqual([]);
}
);
});
describe('getNextPageUrl', () => {
it('GitHub API pagination next page is parsed correctly', () => {
function generateResponse(link: string) {
return {
statusCode: 200,
result: null,
headers: {
link: link
}
};
}
const page1Links =
'<https://api.github.com/repositories/129883600/releases?page=2>; rel="next", <https://api.github.com/repositories/129883600/releases?page=3>; rel="last"';
expect(getNextPageUrl(generateResponse(page1Links))).toStrictEqual(
'https://api.github.com/repositories/129883600/releases?page=2'
);
const page2Links =
'<https://api.github.com/repositories/129883600/releases?page=1>; rel="prev", <https://api.github.com/repositories/129883600/releases?page=1>; rel="first"';
expect(getNextPageUrl(generateResponse(page2Links))).toBeNull();
});
});

View file

@ -1,40 +1,28 @@
--- ---
name: "Setup Python" name: 'Setup Python'
description: "Set up a specific version of Python and add the command-line tools to the PATH." description: 'Set up a specific version of Python and add the command-line tools to the PATH.'
author: "GitHub" author: 'GitHub'
inputs: inputs:
python-version: python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset." description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
python-version-file: default: '3.x'
description: "File containing the Python version to use. Example: .python-version"
cache: cache:
description: "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry." description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry.'
required: false required: false
architecture: architecture:
description: "The target architecture (x86, x64) of the Python or PyPy interpreter." description: 'The target architecture (x86, x64) of the Python interpreter.'
check-latest:
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
default: false
token: token:
description: "The token used to authenticate when fetching Python distributions from https://github.com/actions/python-versions. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting." 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.server_url == 'https://github.com' && github.token || '' }} default: ${{ github.token }}
cache-dependency-path: cache-dependency-path:
description: "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies." description: 'Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies.'
update-environment:
description: "Set this option if you want the action to update environment variables."
default: true
allow-prereleases:
description: "When 'true', a version range passed to 'python-version' input will match prerelease versions if no GA versions are found. Only 'x.y' version range is supported for CPython."
default: false
outputs: outputs:
python-version: python-version:
description: "The installed Python or PyPy version. Useful when given a version range as input." description: "The installed python version. Useful when given a version range as input."
cache-hit: cache-hit:
description: "A boolean value to indicate a cache entry was found" description: 'A boolean value to indicate a cache entry was found'
python-path:
description: "The absolute path to the Python or PyPy executable."
runs: runs:
using: 'node20' using: 'node16'
main: 'dist/setup/index.js' main: 'dist/setup/index.js'
post: 'dist/cache-save/index.js' post: 'dist/cache-save/index.js'
post-if: success() post-if: success()

78493
dist/cache-save/index.js vendored

File diff suppressed because one or more lines are too long

96341
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -45,8 +45,8 @@ We won't pursue the goal to provide wide customization of caching in the scope o
``` ```
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-python@v4 - uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: 3.9
cache: pip cache: pip
@ -56,8 +56,8 @@ steps:
``` ```
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-python@v4 - uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: 3.9
cache: pipenv cache: pipenv
@ -66,8 +66,8 @@ steps:
``` ```
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-python@v4 - uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: 3.9
cache: pip cache: pip
@ -80,8 +80,8 @@ steps:
``` ```
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-python@v4 - uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: 3.9
cache: pip cache: pip

View file

@ -1,627 +0,0 @@
# Advanced Usage
- [Using the python-version input](advanced-usage.md#using-the-python-version-input)
- [Specifying a Python version](advanced-usage.md#specifying-a-python-version)
- [Specifying a PyPy version](advanced-usage.md#specifying-a-pypy-version)
- [Specifying multiple Python/PyPy versions](advanced-usage.md#specifying-multiple-pythonpypy-versions)
- [Matrix Testing](advanced-usage.md#matrix-testing)
- [Using the python-version-file input](advanced-usage.md#using-the-python-version-file-input)
- [Check latest version](advanced-usage.md#check-latest-version)
- [Caching packages](advanced-usage.md#caching-packages)
- [Outputs and environment variables](advanced-usage.md#outputs-and-environment-variables)
- [Outputs](advanced-usage.md#outputs)
- [Environment variables](advanced-usage.md#environment-variables)
- [Using update-environment flag](advanced-usage.md#using-update-environment-flag)
- [Available versions of Python and PyPy](advanced-usage.md#available-versions-of-python-pypy-and-graalpy)
- [Python](advanced-usage.md#python)
- [PyPy](advanced-usage.md#pypy)
- [GraalPy](advanced-usage.md#graalpy)
- [Hosted tool cache](advanced-usage.md#hosted-tool-cache)
- [Using `setup-python` with a self-hosted runner](advanced-usage.md#using-setup-python-with-a-self-hosted-runner)
- [Windows](advanced-usage.md#windows)
- [Linux](advanced-usage.md#linux)
- [macOS](advanced-usage.md#macos)
- [Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes)
- [Allow pre-releases](advanced-usage.md#allow-pre-releases)
## Using the `python-version` input
### 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`):
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7.5'
- run: python my_script.py
```
- The only downside to this is that setup may take a little longer. If the exact version is not already installed on the runner due to more recent versions, the exact version will have to be downloaded.
- MSI installers are used on Windows for this, so runs will take a little longer to set up vs macOS and Linux.
You can specify **only a major and minor version** if you are okay with the most recent patch version being used:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- run: python my_script.py
```
- 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 of Python on the runner will be used.
You can specify the version with **prerelease tag** to download and set up an accurate pre-release version of Python:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12.0-alpha.1'
- run: python my_script.py
```
It's also possible to use **x.y-dev syntax** to download and set up the latest patch version of Python, alpha, beta and rc (release candidate) releases included. (for specified major & minor versions):
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12-dev'
- run: python my_script.py
```
You can also use several types of ranges that are specified in [semver](https://github.com/npm/node-semver#ranges), for instance:
- **[ranges](https://github.com/npm/node-semver#ranges)** to download and set up the latest available version of Python satisfying a range:
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '>=3.9 <3.10'
- run: python my_script.py
```
- **[hyphen ranges](https://github.com/npm/node-semver#hyphen-ranges-xyz---abc)** to download and set up the latest available version of Python (includes both pre-release and stable versions):
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12.0-alpha - 3.12.0'
- run: python my_script.py
```
- **[x-ranges](https://github.com/npm/node-semver#x-ranges-12x-1x-12-)** to specify the latest stable version of Python (for specified major version):
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- run: python my_script.py
```
Please refer to the [Advanced range syntax section](https://github.com/npm/node-semver#advanced-range-syntax) of the [semver](https://github.com/npm/node-semver) to check other available range syntaxes.
### Specifying a PyPy version
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy version will be used in this case.
```
pypy3.9 or pypy-3.9 # the latest available version of PyPy that supports Python 3.9
pypy2.7 or pypy-2.7 # the latest available version of PyPy that supports Python 2.7
pypy3.7-v7.3.3 or pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
pypy3.7-v7.x or pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
pypy3.7-v7.3.3rc1 or pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
pypy3.7-nightly or pypy-3.7-nightly # Python 3.7 and nightly PyPy
```
Download and set up PyPy:
```yaml
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 'pypy3.7' # the latest available version of PyPy that supports Python 3.7
- 'pypy3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python my_script.py
```
More details on PyPy syntax can be found in the [Available versions of PyPy](#pypy) section.
### Specifying multiple Python/PyPy versions
The python-version input can get multiple python/pypy versions. The last specified version will be used as a default one.
Download and set up multiple Python versions:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
- run: python my_script.py
```
Download and set up multiple PyPy versions:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
pypy-3.7-v7.3.x
pypy3.9-nightly
pypy3.8
- run: python my_script.py
```
Download and set up multiple Python/PyPy versions:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
pypy3.9-nightly
pypy3.8
3.10
- run: python my_script.py
```
### Matrix Testing
Using `setup-python` it's possible to use [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
```yaml
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '2.x', '3.x', 'pypy2.7', 'pypy3.8', 'pypy3.9' ]
name: Python ${{ matrix.python-version }} sample
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: python my_script.py
```
Exclude a specific Python version:
```yaml
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy2.7', 'pypy3.9']
exclude:
- os: macos-latest
python-version: '3.8'
- os: windows-latest
python-version: '3.6'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python --version
```
## Using the `python-version-file` input
`setup-python` action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.
>In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version' # Read python version from a file .python-version
- run: python my_script.py
```
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml' # Read python version from a file pyproject.toml
- run: python my_script.py
```
## Check latest version
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific `Python or PyPy` version is always used.
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a `Python or PyPy` version will then be downloaded. Set `check-latest` to `true` if you want the most up-to-date `Python or PyPy` version to always be used.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
check-latest: true
- run: python my_script.py
```
> Setting `check-latest` to `true` has performance implications as downloading `Python or PyPy` versions is slower than using cached versions.
## Caching packages
**Caching pipenv dependencies:**
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pipenv'
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
- run: pipenv install
```
**Caching poetry dependencies:**
```yaml
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'poetry'
- run: poetry install
- run: poetry run pytest
```
**Using a list of file paths to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pipenv'
cache-dependency-path: |
server/app/Pipfile.lock
__test__/app/Pipfile.lock
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
- run: pipenv install
```
**Using wildcard patterns to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: '**/requirements-dev.txt'
- run: pip install -r subdirectory/requirements-dev.txt
```
**Using a list of wildcard patterns to cache dependencies**
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
- run: pip install -e . -r subdirectory/requirements-dev.txt
```
**Caching projects that use setup.py:**
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: setup.py
- run: pip install -e .
# Or pip install -e '.[test]' to install test dependencies
```
# Outputs and environment variables
## Outputs
### `python-version`
Using **python-version** output it's possible to get the installed by action Python or PyPy version. This output is useful when the input `python-version` is given as a range (e.g. 3.8.0 - 3.10.0 ), but down in a workflow you need to operate with the exact installed version (e.g. 3.10.1).
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cp310
with:
python-version: "3.8.0 - 3.10.0"
- run: echo '${{ steps.cp310.outputs.python-version }}'
```
### `python-path`
**python-path** output is available with the absolute path of the Python or PyPy interpreter executable if you need it:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cp310
with:
python-version: "3.10"
- run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version
```
### `cache-hit`
**cache-hit** output is available with a boolean value that indicates whether a cache hit occurred on the primary key:
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cp310
with:
python-version: "3.8.0"
cache: "poetry"
- run: echo '${{ steps.cp310.outputs.cache-hit }}' # true if cache-hit occurred on the primary key
```
## Environment variables
These environment variables become available after setup-python action execution:
| **Env.variable** | **Description** |
| ----------- | ----------- |
| pythonLocation |Contains the absolute path to the folder where the requested version of Python or PyPy is installed|
| Python_ROOT_DIR | https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython |
| Python2_ROOT_DIR |https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2|
| Python3_ROOT_DIR |https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3|
## Using `update-environment` flag
The `update-environment` flag defaults to `true`.
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for Python or PyPy to just work out of the box.
If `update-environment` is set to `false`, the action will not add/update environment variables.
This can prove useful if you want the only side-effect to be to ensure Python or PyPy is installed and rely on the `python-path` output to run executable.
Such a requirement on side-effect could be because you don't want your composite action messing with your user's workflows.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: cp310
with:
python-version: '3.10'
update-environment: false
- run: ${{ steps.cp310.outputs.python-path }} my_script.py
```
## Available versions of Python, PyPy and GraalPy
### Python
`setup-python` is able to configure **Python** from two sources:
- Preinstalled versions of Python in the tool 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 tool cache.
- If the exact patch version doesn't matter to you, specifying just the major and minor versions will get you the latest preinstalled patch version. In the previous example, the version spec `3.8` will use the `3.8.2` Python version found in the cache.
- Use `-dev` instead of a patch number (e.g., `3.12-dev`) to install the latest patch version release for a given minor version, *alpha and beta releases included*.
- 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
>**Note:** Python versions used in this action are generated in the [python-versions](https://github.com/actions/python-versions) repository. For macOS and Ubuntu images, python versions are built from the source code. For Windows, the python-versions repository uses installation executable. For more information please refer to the [python-versions](https://github.com/actions/python-versions) repository.
### PyPy
`setup-python` is able to configure **PyPy** from two sources:
- Preinstalled versions of PyPy in the tool 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 `pypy3.7` or `pypy-3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy3.7-v7.3.3` or `pypy-3.7-v7.3.3`.
- 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/
### GraalPy
`setup-python` is able to download GraalPy versions from the [official GraalPy repository](https://github.com/oracle/graalpython).
- All available versions that we can download are listed in [releases](https://github.com/oracle/graalpython/releases).
## Hosted tool cache
GitHub hosted runners have a tool cache that comes with a few versions of Python + PyPy already installed. This tool 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 the tool cache with Python and PyPy installed. `setup-python` works by taking a specific version of Python or PyPy from this tool cache and adding it to PATH.
|| Location |
|------|-------|
|**Tool cache Directory** |`RUNNER_TOOL_CACHE`|
|**Python tool cache**|`RUNNER_TOOL_CACHE/Python/*`|
|**PyPy tool cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
GitHub runner images are set up in [actions/runner-images](https://github.com/actions/runner-images). During the setup, the available versions of Python and PyPy are automatically downloaded, set up and documented.
- Tool cache setup for Ubuntu: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/Configure-Toolset.ps1)
- Tool cache setup for Windows: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Configure-Toolset.ps1)
## Using `setup-python` with a self-hosted runner
Python distributions are only available for the same [environments](https://github.com/actions/runner-images#available-images) 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` may 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.
### 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 the 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.
> By default runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Windows self-hosted runners.
>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 additional logs.
### Linux
By default runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Linux self-hosted runners:
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/path/to/folder`.
- More permanent way of setting the environment variable is to create an `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/path/to/folder`. This ensures the variable is always set if your runner is configured as a service.
If you're using a non-default tool cache directory be sure that the user starting the runner has write permission to the new tool cache directory. To check the current user and group that the runner belongs type `ls -l` inside the runner's root directory.
The runner can be granted write access to any 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 the non-default tool cache folder to be the same as the runners using `chown`:
`sudo chown runner-user:runner-group /path/to/folder`.
> 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://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service#checking-the-status-of-the-service).
### macOS
The Python packages for macOS that are downloaded from `actions/python-versions` are originally compiled from the source in `/Users/runner/hostedtoolcache`. Due to the fixed shared library path, these Python packages are non-relocatable and require to be installed only in `/Users/runner/hostedtoolcache`. Before the use of `setup-python` on the macOS self-hosted runner:
- Create a directory called `/Users/runner/hostedtoolcache`
- Change the permissions of `/Users/runner/hostedtoolcache` so that the runner has write access
You can check the current user and group that the runner belongs to by typing `ls -l` inside the runner's root directory.
The runner can be granted write access to the `/Users/runner/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 `/Users/runner/hostedtoolcache` to be the same as the runners using `chown`:
`sudo chown runner-user:runner-group /Users/runner/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://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service#checking-the-status-of-the-service).
## Using `setup-python` on GHES
### Avoiding rate limit issues
`setup-python` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Python distributions, `setup-python` downloads distributions from [`actions/python-versions`](https://github.com/actions/python-versions) on github.com (outside of the appliance). These calls to `actions/python-versions` are by default made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during downloading that look like this:
##[error]API rate limit exceeded for YOUR_IP. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
To get a higher rate limit, you can [generate a personal access token (PAT) on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action. It is important to understand that this needs to be a token from github.com and _not_ from your GHES instance. If you or your colleagues do not yet have a github.com account, you might need to create one.
Here are the steps you need to follow to avoid the rate limit:
1. Create a PAT on any github.com account by using [this link](https://github.com/settings/tokens/new) after logging into github.com (not your Enterprise instance). This PAT does _not_ need any rights, so make sure all the boxes are unchecked.
2. Store this PAT in the repository / organization where you run your workflow, e.g. as `GH_GITHUB_COM_TOKEN`. You can do this by navigating to your repository -> **Settings** -> **Secrets** -> **Actions** -> **New repository secret**.
3. To use this functionality, you need to use any version newer than `v4.3`. Also, change _python-version_ as needed.
```yml
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
token: ${{ secrets.GH_GITHUB_COM_TOKEN }}
```
Requests should now be authenticated. To verify that you are getting the higher rate limit, you can call GitHub's [rate limit API](https://docs.github.com/en/rest/rate-limit) from within your workflow ([example](https://github.com/actions/setup-python/pull/443#issuecomment-1206776401)).
### No access to github.com
If the runner is not able to access github.com, any Python versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
## Allow pre-releases
The `allow-prereleases` flag defaults to `false`.
If `allow-prereleases` is set to `true`, the action will allow falling back to pre-release versions of Python when a matching GA version of Python is not available.
This allows for example to simplify reuse of `python-version` as an input of nox for pre-releases of Python by not requiring manipulation of the `3.y-dev` specifier.
For CPython, `allow-prereleases` will only have effect for `x.y` version range (e.g. `3.12`).
Let's say that python 3.12 is not generally available, the following workflow will fallback to the most recent pre-release of python 3.12:
```yaml
jobs:
test:
name: ${{ matrix.os }} / ${{ matrix.python_version }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [Ubuntu, Windows, macOS]
python_version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python_version }}"
allow-prereleases: true
- run: pipx run nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }}
```

View file

@ -1,114 +1,37 @@
# Contributors # Contributors
Thank you for contributing! ### Checkin
We have prepared a short guide so that the process of making your contribution is as simple and clear as possible. Please check it out before you contribute! - Do check in source (`src/`)
- Do check in a single `index.js` file after running `ncc`
- Do not check in `node_modules/`
## How can I contribute... ### NCC
* [Contribute Documentation:green_book:](#contribute-documentation) 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/`.
* [Contribute Code :computer:](#contribute-code) ### Developing
* [Provide Support on Issues:pencil:](#provide-support-on-issues) If you're developing locally, you can run
* [Review Pull Requests:mag:](#review-pull-requests) ```sh
npm install
tsc
ncc build src/setup-python.ts
```
## Contribute documentation 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`.
Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies and how we tell others everything they need to be able to use this project or contribute to it. 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`).
Documentation contributions of any size are welcome! Feel free to contribute even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! ### Testing
**How to contribute:** 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.
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a convenient way of commenting and amending the proposed changes. ### Licensed
- Please check that no one else has already created a pull request with these or similar changes 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.
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
- Make sure your changes are formatted properly and consistently with the rest of the documentation
- Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
**Once you've filed the pull request:** ### Releases
- Maintainers will review your pull request 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.
- If a maintainer requests changes, first of all, try to think about this request critically and only after that implement and request another review
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action and updating the major tag
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
## Contribute code
We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others.
Code contributions of just about any size are acceptable!
The main difference between code contributions and documentation contributions is that contributing code requires the inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added unless the maintainers consider the specific tests to be either impossible or way too much of a burden for such a contribution.
**How to contribute:**
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a convenient way of commenting and amending the proposed changes.
- Please check that no one else has already created a pull request with these or similar changes
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
- Make sure your changes are well formatted and that all tests are passing
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
**Learn more about how to work with the repository:**
- To implement new features or fix bugs, you need to make changes to the `.ts` files, which are located in the `src` folder
- To comply with the code style, **you need to run the `format` script**
- To lint the code, **you need to run the `lint:fix` script**
- To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build
**Learn more about how to implement tests:**
Adding or changing tests is an integral part of making a change to the code.
Unit tests are in the `__tests__` folder, and end-to-end tests are in the `workflows` folder, particularly take a look at the files with `e2e` and `test` prefixes, for instance, [e2e-cache.yml](https://github.com/actions/setup-python/blob/main/.github/workflows/e2e-cache.yml).
- The contributor can add various types of tests (like unit tests or end-to-end tests), which, in his opinion, will be necessary and sufficient for testing new or changed functionality
- Tests should cover a successful execution, as well as some edge cases and possible errors
- As already mentioned, pull requests without tests will be considered more carefully by maintainers. If you are sure that in this situation the tests are not needed or cannot be implemented with a commensurate effort - please add this clarification message to your pull request
**Once you've filed the pull request:**
- CI will start automatically with some checks. Wait until the end of the execution and make sure that all checks passed successfully. If some checks fail, you can open them one by one, try to find the reason for failing and make changes to your code to resolve the problem
- Maintainers will review your pull request
- If a maintainer requests changes, first of all, try to think about his request critically and only after that implement and request another review
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action and updating the major tag
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
## Provide support on issues
Helping out other users with their questions is an awesome way of contributing to any community. It's not uncommon for most of the issues on open source projects to be support-related questions by users trying to understand something they ran into or find their way around a known bug.
**To help other folks out with their questions:**
- Go to the [issue tracker](https://github.com/actions/setup-python/issues)
- Read through the list until you find something that you're familiar enough with to answer to
- Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on
- Once the discussion wraps up and things are clarified, ask the original issue filer (or a maintainer) to close it for you
*Some notes on picking up support issues:*
- Avoid responding to issues you don't know you can answer accurately
- Try to refer to past issues with accepted answers as much as possible. Link to them from your replies
- Be kind and patient with users. Often, folks who have run into confusing things might be upset or impatient. This is natural. If you feel uncomfortable in conversation with them, it's better to stay away or withdraw from the issue.
> If some user is violating our code of conduct [standards](https://github.com/actions/setup-python/blob/main/CODE_OF_CONDUCT.md#our-standards), refer to the [enforcement](https://github.com/actions/setup-python/blob/main/CODE_OF_CONDUCT.md#enforcement) section of the Code of Conduct to resolve the conflict
## Review pull requests
Another great way to contribute is to review pull request. Please, be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) Please, always respond with respect, and be understanding, but don't feel like you need to sacrifice your standards for their sake, either.
**How to review:**
- Go to the [pull requests](https://github.com/actions/setup-python/pulls)
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
- Submit your review, which may include comments, an approval, or a changes request

7904
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,15 @@
{ {
"name": "setup-python", "name": "setup-python",
"version": "5.0.0", "version": "3.1.0",
"private": true, "private": true,
"description": "Setup python action", "description": "Setup python action",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts", "build": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts",
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"", "format": "prettier --write \"{,!(node_modules)/**/}*.ts\"",
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"", "format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
"release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/", "release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/",
"test": "jest --runInBand --coverage" "test": "jest"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -25,31 +23,30 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.0.4", "@actions/cache": "^2.0.2",
"@actions/core": "^1.10.0", "@actions/core": "^1.2.3",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/glob": "^0.4.0", "@actions/glob": "^0.2.0",
"@actions/http-client": "^2.2.0",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^1.5.5",
"@iarna/toml": "^2.2.5", "semver": "^7.1.3"
"semver": "^7.5.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.6", "@types/jest": "^27.0.2",
"@types/node": "^20.9.1", "@types/node": "^16.11.25",
"@types/semver": "^7.1.0", "@types/semver": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@zeit/ncc": "^0.22.0",
"@typescript-eslint/parser": "^5.54.0", "husky": "^7.0.2",
"@vercel/ncc": "^0.38.0", "jest": "^27.2.5",
"eslint": "^8.35.0", "jest-circus": "^27.2.5",
"eslint-config-prettier": "^8.6.0", "prettier": "^2.0.2",
"eslint-plugin-jest": "^27.2.1", "ts-jest": "^27.0.5",
"eslint-plugin-node": "^11.1.0", "typescript": "^4.2.3"
"jest": "^29.7.0", },
"jest-circus": "^29.7.0", "husky": {
"prettier": "^2.8.4", "skipCI": true,
"ts-jest": "^29.1.1", "hooks": {
"typescript": "^5.2.2" "pre-commit": "npm run build && npm run format-check"
}
} }
} }

View file

@ -1,6 +1,5 @@
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
export enum State { export enum State {
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key', STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
@ -20,39 +19,27 @@ abstract class CacheDistributor {
primaryKey: string; primaryKey: string;
restoreKey: string[] | undefined; restoreKey: string[] | undefined;
}>; }>;
protected async handleLoadedCache() {}
public async restoreCache() { public async restoreCache() {
const {primaryKey, restoreKey} = await this.computeKeys(); const {primaryKey, restoreKey} = await this.computeKeys();
if (primaryKey.endsWith('-')) { if (primaryKey.endsWith('-')) {
const file =
this.packageManager === 'pip'
? `${this.cacheDependencyPath
.split('\n')
.join(',')} or ${CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error( throw new Error(
`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository` `No file in ${process.cwd()} matched to [${this.cacheDependencyPath
.split('\n')
.join(',')}], make sure you have checked out the target repository`
); );
} }
const cachePath = await this.getCacheGlobalDirectories(); const cachePath = await this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath); core.saveState(State.CACHE_PATHS, cachePath);
let matchedKey: string | undefined;
try {
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
} catch (err) {
const message = (err as Error).message;
core.info(`[warning]${message}`);
core.setOutput('cache-hit', false);
return;
}
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey); core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
await this.handleLoadedCache(); const matchedKey = await cache.restoreCache(
cachePath,
primaryKey,
restoreKey
);
this.handleMatchResult(matchedKey, primaryKey); this.handleMatchResult(matchedKey, primaryKey);
} }

View file

@ -1 +0,0 @@
export const CACHE_DEPENDENCY_BACKUP_PATH = '**/pyproject.toml';

View file

@ -7,15 +7,12 @@ import * as path from 'path';
import os from 'os'; import os from 'os';
import CacheDistributor from './cache-distributor'; import CacheDistributor from './cache-distributor';
import {getLinuxInfo, IS_LINUX, IS_WINDOWS} from '../utils'; import {IS_WINDOWS} from '../utils';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
class PipCache extends CacheDistributor { class PipCache extends CacheDistributor {
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
constructor( constructor(
private pythonVersion: string, private pythonVersion: string,
cacheDependencyPath = '**/requirements.txt' cacheDependencyPath: string = '**/requirements.txt'
) { ) {
super('pip', cacheDependencyPath); super('pip', cacheDependencyPath);
} }
@ -59,20 +56,9 @@ class PipCache extends CacheDistributor {
} }
protected async computeKeys() { protected async computeKeys() {
const hash = const hash = await glob.hashFiles(this.cacheDependencyPath);
(await glob.hashFiles(this.cacheDependencyPath)) || const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
(await glob.hashFiles(this.cacheDependencyBackupPath)); const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
let primaryKey = '';
let restoreKey = '';
if (IS_LINUX) {
const osInfo = await getLinuxInfo();
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}`;
} else {
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
}
return { return {
primaryKey, primaryKey,

View file

@ -1,53 +1,39 @@
import * as glob from '@actions/glob'; import * as glob from '@actions/glob';
import * as io from '@actions/io'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as core from '@actions/core';
import CacheDistributor from './cache-distributor'; import CacheDistributor from './cache-distributor';
import {logWarning} from '../utils';
class PoetryCache extends CacheDistributor { class PoetryCache extends CacheDistributor {
constructor( constructor(
private pythonVersion: string, private pythonVersion: string,
protected patterns: string = '**/poetry.lock', protected patterns: string = '**/poetry.lock'
protected poetryProjects: Set<string> = new Set<string>()
) { ) {
super('poetry', patterns); super('poetry', patterns);
} }
protected async getCacheGlobalDirectories() { protected async getCacheGlobalDirectories() {
// Same virtualenvs path may appear for different projects, hence we use a Set const poetryConfig = await this.getPoetryConfiguration();
const paths = new Set<string>();
const globber = await glob.create(this.patterns);
for await (const file of globber.globGenerator()) { const cacheDir = poetryConfig['cache-dir'];
const basedir = path.dirname(file); const virtualenvsPath = poetryConfig['virtualenvs.path'].replace(
core.debug(`Processing Poetry project at ${basedir}`); '{cache-dir}',
this.poetryProjects.add(basedir); cacheDir
);
const poetryConfig = await this.getPoetryConfiguration(basedir); const paths = [virtualenvsPath];
const cacheDir = poetryConfig['cache-dir']; if (poetryConfig['virtualenvs.in-project'] === true) {
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace( paths.push(path.join(process.cwd(), '.venv'));
'{cache-dir}',
cacheDir
);
paths.add(virtualenvsPath);
if (poetryConfig['virtualenvs.in-project']) {
paths.add(path.join(basedir, '.venv'));
}
} }
return [...paths]; return paths;
} }
protected async computeKeys() { protected async computeKeys() {
const hash = await glob.hashFiles(this.patterns); const hash = await glob.hashFiles(this.patterns);
// "v2" is here to invalidate old caches of this cache distributor, which were created broken: const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-v2-${hash}`;
const restoreKey = undefined; const restoreKey = undefined;
return { return {
primaryKey, primaryKey,
@ -55,39 +41,11 @@ class PoetryCache extends CacheDistributor {
}; };
} }
protected async handleLoadedCache() { private async getPoetryConfiguration() {
await super.handleLoadedCache(); const {stdout, stderr, exitCode} = await exec.getExecOutput('poetry', [
'config',
// After the cache is loaded -- make sure virtualenvs use the correct Python version (the one that we have just installed). '--list'
// This will handle invalid caches, recreating virtualenvs if necessary. ]);
const pythonLocation = await io.which('python');
if (pythonLocation) {
core.debug(`pythonLocation is ${pythonLocation}`);
} else {
logWarning('python binaries were not found in PATH');
return;
}
for (const poetryProject of this.poetryProjects) {
const {exitCode, stderr} = await exec.getExecOutput(
'poetry',
['env', 'use', pythonLocation],
{ignoreReturnCode: true, cwd: poetryProject}
);
if (exitCode) {
logWarning(stderr);
}
}
}
private async getPoetryConfiguration(basedir: string) {
const {stdout, stderr, exitCode} = await exec.getExecOutput(
'poetry',
['config', '--list'],
{cwd: basedir}
);
if (exitCode && stderr) { if (exitCode && stderr) {
throw new Error( throw new Error(
@ -100,7 +58,7 @@ class PoetryCache extends CacheDistributor {
const config: any = {}; const config: any = {};
for (let line of lines) { for (let line of lines) {
line = line.replace(/#.*$/gm, ''); line = line.replace(/#.*$/, '');
const [key, value] = line.split('=').map(part => part.trim()); const [key, value] = line.split('=').map(part => part.trim());

View file

@ -4,18 +4,11 @@ import * as cache from '@actions/cache';
import fs from 'fs'; import fs from 'fs';
import {State} from './cache-distributions/cache-distributor'; import {State} from './cache-distributions/cache-distributor';
// Added early exit to resolve issue with slow post action step: export async function run() {
// - https://github.com/actions/setup-node/issues/878
// https://github.com/actions/cache/pull/1217
export async function run(earlyExit?: boolean) {
try { try {
const cache = core.getInput('cache'); const cache = core.getInput('cache');
if (cache) { if (cache) {
await saveCache(cache); await saveCache(cache);
if (earlyExit) {
process.exit(0);
}
} }
} catch (error) { } catch (error) {
const err = error as Error; const err = error as Error;
@ -24,16 +17,7 @@ export async function run(earlyExit?: boolean) {
} }
async function saveCache(packageManager: string) { async function saveCache(packageManager: string) {
const cachePathState = core.getState(State.CACHE_PATHS); const cachePaths = JSON.parse(core.getState(State.CACHE_PATHS)) as string[];
if (!cachePathState) {
core.warning(
'Cache paths are empty. Please check the previous logs and make sure that the python version is specified'
);
return;
}
const cachePaths = JSON.parse(cachePathState) as string[];
core.debug(`paths for caching are ${cachePaths.join(', ')}`); core.debug(`paths for caching are ${cachePaths.join(', ')}`);
@ -59,20 +43,17 @@ async function saveCache(packageManager: string) {
return; return;
} }
let cacheId = 0;
try { try {
cacheId = await cache.saveCache(cachePaths, primaryKey); await cache.saveCache(cachePaths, primaryKey);
} catch (err) { core.info(`Cache saved with the key: ${primaryKey}`);
const message = (err as Error).message; } catch (error) {
core.info(`[warning]${message}`); const err = error as Error;
return; if (err.name === cache.ReserveCacheError.name) {
core.info(err.message);
} else {
throw error;
}
} }
if (cacheId == -1) {
return;
}
core.info(`Cache saved with the key: ${primaryKey}`);
} }
function isCacheDirectoryExists(cacheDirectory: string[]) { function isCacheDirectoryExists(cacheDirectory: string[]) {
@ -83,4 +64,4 @@ function isCacheDirectoryExists(cacheDirectory: string[]) {
return result; return result;
} }
run(true); run();

View file

@ -1,146 +0,0 @@
import * as path from 'path';
import * as graalpyInstall from './install-graalpy';
import {
IS_WINDOWS,
validateVersion,
IGraalPyManifestRelease,
getBinaryDirectory
} from './utils';
import * as semver from 'semver';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
export async function findGraalPyVersion(
versionSpec: string,
architecture: string,
updateEnvironment: boolean,
checkLatest: boolean,
allowPreReleases: boolean
): Promise<string> {
let resolvedGraalPyVersion = '';
let installDir: string | null;
let releases: IGraalPyManifestRelease[] | undefined;
let graalpyVersionSpec = parseGraalPyVersion(versionSpec);
if (checkLatest) {
releases = await graalpyInstall.getAvailableGraalPyVersions();
if (releases && releases.length > 0) {
const releaseData = graalpyInstall.findRelease(
releases,
graalpyVersionSpec,
architecture,
false
);
if (releaseData) {
core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`);
graalpyVersionSpec = releaseData.resolvedGraalPyVersion;
} else {
core.info(
`Failed to resolve GraalPy ${graalpyVersionSpec} from manifest`
);
}
}
}
({installDir, resolvedGraalPyVersion} = findGraalPyToolCache(
graalpyVersionSpec,
architecture
));
if (!installDir) {
({installDir, resolvedGraalPyVersion} = await graalpyInstall.installGraalPy(
graalpyVersionSpec,
architecture,
allowPreReleases,
releases
));
}
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
const _binDir = path.join(installDir, pipDir);
const binaryExtension = IS_WINDOWS ? '.exe' : '';
const pythonPath = path.join(
IS_WINDOWS ? installDir : _binDir,
`python${binaryExtension}`
);
const pythonLocation = getBinaryDirectory(installDir);
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
core.exportVariable('Python_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
core.exportVariable('Python2_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
core.exportVariable('Python3_ROOT_DIR', installDir);
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
core.addPath(pythonLocation);
core.addPath(_binDir);
}
core.setOutput('python-version', 'graalpy' + resolvedGraalPyVersion);
core.setOutput('python-path', pythonPath);
return resolvedGraalPyVersion;
}
export function findGraalPyToolCache(
graalpyVersion: string,
architecture: string
) {
let resolvedGraalPyVersion = '';
let installDir: string | null = tc.find(
'GraalPy',
graalpyVersion,
architecture
);
if (installDir) {
// 'tc.find' finds tool based on Python version but we also need to check
// whether GraalPy version satisfies requested version.
resolvedGraalPyVersion = path.basename(path.dirname(installDir));
const isGraalPyVersionSatisfies = semver.satisfies(
resolvedGraalPyVersion,
graalpyVersion
);
if (!isGraalPyVersionSatisfies) {
installDir = null;
resolvedGraalPyVersion = '';
}
}
if (!installDir) {
core.info(
`GraalPy version ${graalpyVersion} was not found in the local cache`
);
}
return {installDir, resolvedGraalPyVersion};
}
export function parseGraalPyVersion(versionSpec: string): string {
const versions = versionSpec.split('-').filter(item => !!item);
if (/^(graalpy)(.+)/.test(versions[0])) {
const version = versions[0].replace('graalpy', '');
versions.splice(0, 1, 'graalpy', version);
}
if (versions.length < 2 || versions[0] != 'graalpy') {
throw new Error(
"Invalid 'version' property for GraalPy. GraalPy version should be specified as 'graalpy<python-version>' or 'graalpy-<python-version>'. See README for examples and documentation."
);
}
const pythonVersion = versions[1];
if (!validateVersion(pythonVersion)) {
throw new Error(
"Invalid 'version' property for GraalPy. GraalPy versions should satisfy SemVer notation. See README for examples and documentation."
);
}
return pythonVersion;
}

View file

@ -6,9 +6,7 @@ import {
validateVersion, validateVersion,
getPyPyVersionFromPath, getPyPyVersionFromPath,
readExactPyPyVersionFile, readExactPyPyVersionFile,
validatePythonVersionFormatForPyPy, validatePythonVersionFormatForPyPy
IPyPyManifestRelease,
getBinaryDirectory
} from './utils'; } from './utils';
import * as semver from 'semver'; import * as semver from 'semver';
@ -22,43 +20,14 @@ interface IPyPyVersionSpec {
export async function findPyPyVersion( export async function findPyPyVersion(
versionSpec: string, versionSpec: string,
architecture: string, architecture: string
updateEnvironment: boolean,
checkLatest: boolean,
allowPreReleases: boolean
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> { ): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
let resolvedPyPyVersion = ''; let resolvedPyPyVersion = '';
let resolvedPythonVersion = ''; let resolvedPythonVersion = '';
let installDir: string | null; let installDir: string | null;
let releases: IPyPyManifestRelease[] | undefined;
const pypyVersionSpec = parsePyPyVersion(versionSpec); const pypyVersionSpec = parsePyPyVersion(versionSpec);
if (checkLatest) {
releases = await pypyInstall.getAvailablePyPyVersions();
if (releases && releases.length > 0) {
const releaseData = pypyInstall.findRelease(
releases,
pypyVersionSpec.pythonVersion,
pypyVersionSpec.pypyVersion,
architecture,
false
);
if (releaseData) {
core.info(
`Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})`
);
pypyVersionSpec.pythonVersion = releaseData.resolvedPythonVersion;
pypyVersionSpec.pypyVersion = releaseData.resolvedPyPyVersion;
} else {
core.info(
`Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest`
);
}
}
}
({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache( ({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache(
pypyVersionSpec.pythonVersion, pypyVersionSpec.pythonVersion,
pypyVersionSpec.pypyVersion, pypyVersionSpec.pypyVersion,
@ -70,34 +39,17 @@ export async function findPyPyVersion(
await pypyInstall.installPyPy( await pypyInstall.installPyPy(
pypyVersionSpec.pypyVersion, pypyVersionSpec.pypyVersion,
pypyVersionSpec.pythonVersion, pypyVersionSpec.pythonVersion,
architecture, architecture
allowPreReleases,
releases
)); ));
} }
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
const _binDir = path.join(installDir, pipDir); const _binDir = path.join(installDir, pipDir);
const binaryExtension = IS_WINDOWS ? '.exe' : ''; const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
const pythonPath = path.join( core.exportVariable('pythonLocation', pythonLocation);
IS_WINDOWS ? installDir : _binDir, core.addPath(pythonLocation);
`python${binaryExtension}` core.addPath(_binDir);
); core.setOutput('python-version', 'pypy' + resolvedPyPyVersion.trim());
const pythonLocation = getBinaryDirectory(installDir);
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
core.exportVariable('Python_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
core.exportVariable('Python2_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
core.exportVariable('Python3_ROOT_DIR', installDir);
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
core.addPath(pythonLocation);
core.addPath(_binDir);
}
core.setOutput('python-version', 'pypy' + resolvedPyPyVersion);
core.setOutput('python-path', pythonPath);
return {resolvedPyPyVersion, resolvedPythonVersion}; return {resolvedPyPyVersion, resolvedPythonVersion};
} }
@ -142,14 +94,9 @@ export function findPyPyToolCache(
export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec { export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
const versions = versionSpec.split('-').filter(item => !!item); const versions = versionSpec.split('-').filter(item => !!item);
if (/^(pypy)(.+)/.test(versions[0])) {
const pythonVersion = versions[0].replace('pypy', '');
versions.splice(0, 1, 'pypy', pythonVersion);
}
if (versions.length < 2 || versions[0] != 'pypy') { if (versions.length < 2 || versions[0] != 'pypy') {
throw new Error( throw new Error(
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy<python-version>' or 'pypy-<python-version>'. See README for examples and documentation." "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
); );
} }

View file

@ -1,6 +1,6 @@
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils'; import {IS_WINDOWS, IS_LINUX} from './utils';
import * as semver from 'semver'; import * as semver from 'semver';
@ -11,7 +11,7 @@ import * as tc from '@actions/tool-cache';
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed. // 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. // This is where pip is, along with anything that pip installs.
// There is a separate directory for `pip install --user`. // There is a seperate directory for `pip install --user`.
// //
// For reference, these directories are as follows: // For reference, these directories are as follows:
// macOS / Linux: // macOS / Linux:
@ -32,39 +32,12 @@ function binDir(installDir: string): string {
export async function useCpythonVersion( export async function useCpythonVersion(
version: string, version: string,
architecture: string, architecture: string
updateEnvironment: boolean,
checkLatest: boolean,
allowPreReleases: boolean
): Promise<InstalledVersion> { ): Promise<InstalledVersion> {
let manifest: tc.IToolRelease[] | null = null;
const desugaredVersionSpec = desugarDevVersion(version); const desugaredVersionSpec = desugarDevVersion(version);
let semanticVersionSpec = pythonVersionToSemantic( const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
desugaredVersionSpec,
allowPreReleases
);
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`); core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
if (checkLatest) {
manifest = await installer.getManifest();
const resolvedVersion = (
await installer.findReleaseFromManifest(
semanticVersionSpec,
architecture,
manifest
)
)?.version;
if (resolvedVersion) {
semanticVersionSpec = resolvedVersion;
core.info(`Resolved as '${semanticVersionSpec}'`);
} else {
core.info(
`Failed to resolve version ${semanticVersionSpec} from manifest`
);
}
}
let installDir: string | null = tc.find( let installDir: string | null = tc.find(
'Python', 'Python',
semanticVersionSpec, semanticVersionSpec,
@ -76,8 +49,7 @@ export async function useCpythonVersion(
); );
const foundRelease = await installer.findReleaseFromManifest( const foundRelease = await installer.findReleaseFromManifest(
semanticVersionSpec, semanticVersionSpec,
architecture, architecture
manifest
); );
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) { if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
@ -89,80 +61,62 @@ export async function useCpythonVersion(
} }
if (!installDir) { if (!installDir) {
const osInfo = await getOSInfo();
throw new Error( throw new Error(
[ [
`The version '${version}' with architecture '${architecture}' was not found for ${ `Version ${version} with arch ${architecture} not found`,
osInfo
? `${osInfo.osName} ${osInfo.osVersion}`
: 'this operating system'
}.`,
`The list of all available versions can be found here: ${installer.MANIFEST_URL}` `The list of all available versions can be found here: ${installer.MANIFEST_URL}`
].join(os.EOL) ].join(os.EOL)
); );
} }
const _binDir = binDir(installDir); core.exportVariable('pythonLocation', installDir);
const binaryExtension = IS_WINDOWS ? '.exe' : '';
const pythonPath = path.join(
IS_WINDOWS ? installDir : _binDir,
`python${binaryExtension}`
);
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
core.exportVariable('pythonLocation', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
core.exportVariable('Python_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
core.exportVariable('Python2_ROOT_DIR', installDir);
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
core.exportVariable('Python3_ROOT_DIR', installDir);
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
if (IS_LINUX) { if (IS_LINUX) {
const libPath = process.env.LD_LIBRARY_PATH const libPath = process.env.LD_LIBRARY_PATH
? `:${process.env.LD_LIBRARY_PATH}` ? `:${process.env.LD_LIBRARY_PATH}`
: ''; : '';
const pyLibPath = path.join(installDir, 'lib'); const pyLibPath = path.join(installDir, 'lib');
if (!libPath.split(':').includes(pyLibPath)) { if (!libPath.split(':').includes(pyLibPath)) {
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath); core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
}
} }
core.addPath(installDir);
core.addPath(_binDir);
if (IS_WINDOWS) {
// Add --user directory
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
`Python${major}${minor}`,
'Scripts'
);
core.addPath(userScriptsDir);
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
} }
core.addPath(installDir);
core.addPath(binDir(installDir));
if (IS_WINDOWS) {
// Add --user directory
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
// So if `findLocalTool` succeeded above, we must have a conformant `installDir`
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
`Python${major}${minor}`,
'Scripts'
);
core.addPath(userScriptsDir);
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
const installed = versionFromPath(installDir); const installed = versionFromPath(installDir);
core.setOutput('python-version', installed); core.setOutput('python-version', installed);
core.setOutput('python-path', pythonPath);
return {impl: 'CPython', version: installed}; return {impl: 'CPython', version: installed};
} }
/** Convert versions like `3.8-dev` to a version like `~3.8.0-0`. */ /** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
function desugarDevVersion(versionSpec: string) { function desugarDevVersion(versionSpec: string) {
const devVersion = /^(\d+)\.(\d+)-dev$/; if (versionSpec.endsWith('-dev')) {
return versionSpec.replace(devVersion, '~$1.$2.0-0'); const versionRoot = versionSpec.slice(0, -'-dev'.length);
return `>= ${versionRoot}.0-a0`;
} else {
return versionSpec;
}
} }
/** Extracts python version from install path from hosted tool cache as described in README.md */ /** Extracts python version from install path from hosted tool cache as described in README.md */
@ -182,18 +136,8 @@ interface InstalledVersion {
* Python's prelease versions look like `3.7.0b2`. * Python's prelease versions look like `3.7.0b2`.
* This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`. * This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
* If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent. * If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent.
*
* For easier use of the action, we also map 'x.y' to allow pre-release before 'x.y.0' release if allowPreReleases is true
*/ */
export function pythonVersionToSemantic( export function pythonVersionToSemantic(versionSpec: string) {
versionSpec: string,
allowPreReleases: boolean
) {
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g; const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
const majorMinor = /^(\d+)\.(\d+)$/; return versionSpec.replace(prereleaseVersion, '$1-$2');
let result = versionSpec.replace(prereleaseVersion, '$1-$2');
if (allowPreReleases) {
result = result.replace(majorMinor, '~$1.$2.0-0');
}
return result;
} }

View file

@ -1,264 +0,0 @@
import * as os from 'os';
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 ifm from '@actions/http-client/lib/interfaces';
import * as exec from '@actions/exec';
import fs from 'fs';
import * as http from 'http';
import {
IS_WINDOWS,
IGraalPyManifestRelease,
createSymlinkInFolder,
isNightlyKeyword,
getBinaryDirectory,
getNextPageUrl
} from './utils';
const TOKEN = core.getInput('token');
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
export async function installGraalPy(
graalpyVersion: string,
architecture: string,
allowPreReleases: boolean,
releases: IGraalPyManifestRelease[] | undefined
) {
let downloadDir;
releases = releases ?? (await getAvailableGraalPyVersions());
if (!releases || !releases.length) {
throw new Error('No release was found in GraalPy version.json');
}
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
// check for pre-release
core.info(
[
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
`Trying pre-release versions`
].join(os.EOL)
);
releaseData = findRelease(releases, graalpyVersion, architecture, true);
}
if (!releaseData || !releaseData.foundAsset) {
throw new Error(
`GraalPy version ${graalpyVersion} with arch ${architecture} not found`
);
}
const {foundAsset, resolvedGraalPyVersion} = releaseData;
const downloadUrl = `${foundAsset.browser_download_url}`;
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
try {
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
core.info('Extracting downloaded archive...');
downloadDir = await tc.extractTar(graalpyPath);
// 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(resolvedGraalPyVersion)) {
installDir = await tc.cacheDir(
toolDir,
'GraalPy',
resolvedGraalPyVersion,
architecture
);
}
const binaryPath = getBinaryDirectory(installDir);
await createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
await installPip(binaryPath);
return {installDir, resolvedGraalPyVersion};
} catch (err) {
if (err instanceof Error) {
// Rate limit?
if (
err instanceof tc.HTTPError &&
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
) {
core.info(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
);
} else {
core.info(err.message);
}
if (err.stack !== undefined) {
core.debug(err.stack);
}
}
throw err;
}
}
export async function getAvailableGraalPyVersions() {
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
const headers: http.OutgoingHttpHeaders = {};
if (AUTH) {
headers.authorization = AUTH;
}
let url: string | null =
'https://api.github.com/repos/oracle/graalpython/releases';
const result: IGraalPyManifestRelease[] = [];
do {
const response: ifm.TypedResponse<IGraalPyManifestRelease[]> =
await http.getJson(url, headers);
if (!response.result) {
throw new Error(
`Unable to retrieve the list of available GraalPy versions from '${url}'`
);
}
result.push(...response.result);
url = getNextPageUrl(response);
} while (url);
return result;
}
async function createGraalPySymlink(
graalpyBinaryPath: string,
graalpyVersion: string
) {
const version = semver.coerce(graalpyVersion)!;
const pythonBinaryPostfix = semver.major(version);
const pythonMinor = semver.minor(version);
const graalpyMajorMinorBinaryPostfix = `${pythonBinaryPostfix}.${pythonMinor}`;
const binaryExtension = IS_WINDOWS ? '.exe' : '';
core.info('Creating symlinks...');
createSymlinkInFolder(
graalpyBinaryPath,
`graalpy${binaryExtension}`,
`python${pythonBinaryPostfix}${binaryExtension}`,
true
);
createSymlinkInFolder(
graalpyBinaryPath,
`graalpy${binaryExtension}`,
`python${binaryExtension}`,
true
);
createSymlinkInFolder(
graalpyBinaryPath,
`graalpy${binaryExtension}`,
`graalpy${graalpyMajorMinorBinaryPostfix}${binaryExtension}`,
true
);
}
async function installPip(pythonLocation: string) {
core.info(
"Installing pip (GraalPy doesn't update pip because it uses a patched version of pip)"
);
const pythonBinary = path.join(pythonLocation, 'python');
await exec.exec(`${pythonBinary} -m ensurepip --default-pip`);
}
export function graalPyTagToVersion(tag: string) {
const versionPattern = /.*-(\d+\.\d+\.\d+(?:\.\d+)?)((?:a|b|rc))?(\d*)?/;
const match = tag.match(versionPattern);
if (match && match[2]) {
return `${match[1]}-${match[2]}.${match[3]}`;
} else if (match) {
return match[1];
} else {
return tag.replace(/.*-/, '');
}
}
export function findRelease(
releases: IGraalPyManifestRelease[],
graalpyVersion: string,
architecture: string,
includePrerelease: boolean
) {
const options = {includePrerelease: includePrerelease};
const filterReleases = releases.filter(item => {
const isVersionSatisfied = semver.satisfies(
graalPyTagToVersion(item.tag_name),
graalpyVersion,
options
);
return (
isVersionSatisfied && !!findAsset(item, architecture, process.platform)
);
});
if (!filterReleases.length) {
return null;
}
const sortedReleases = filterReleases.sort((previous, current) =>
semver.compare(
semver.coerce(graalPyTagToVersion(current.tag_name))!,
semver.coerce(graalPyTagToVersion(previous.tag_name))!
)
);
const foundRelease = sortedReleases[0];
const foundAsset = findAsset(foundRelease, architecture, process.platform);
return {
foundAsset,
resolvedGraalPyVersion: graalPyTagToVersion(foundRelease.tag_name)
};
}
export function toGraalPyPlatform(platform: string) {
switch (platform) {
case 'win32':
return 'windows';
case 'darwin':
return 'macos';
}
return platform;
}
export function toGraalPyArchitecture(architecture: string) {
switch (architecture) {
case 'x64':
return 'amd64';
case 'arm64':
return 'aarch64';
}
return architecture;
}
export function findAsset(
item: IGraalPyManifestRelease,
architecture: string,
platform: string
) {
const graalpyArch = toGraalPyArchitecture(architecture);
const graalpyPlatform = toGraalPyPlatform(platform);
const found = item.assets.filter(
file =>
file.name.startsWith('graalpy') &&
file.name.endsWith(`-${graalpyPlatform}-${graalpyArch}.tar.gz`)
);
/*
In the future there could be more variants of GraalPy for a single release. Pick the shortest name, that one is the most likely to be the primary variant.
*/
found.sort((f1, f2) => f1.name.length - f2.name.length);
return found[0];
}

View file

@ -1,4 +1,3 @@
import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
@ -9,54 +8,33 @@ import fs from 'fs';
import { import {
IS_WINDOWS, IS_WINDOWS,
WINDOWS_ARCHS,
WINDOWS_PLATFORMS, WINDOWS_PLATFORMS,
IPyPyManifestRelease, IPyPyManifestRelease,
createSymlinkInFolder, createSymlinkInFolder,
isNightlyKeyword, isNightlyKeyword,
writeExactPyPyVersionFile, writeExactPyPyVersionFile
getBinaryDirectory
} from './utils'; } from './utils';
export async function installPyPy( export async function installPyPy(
pypyVersion: string, pypyVersion: string,
pythonVersion: string, pythonVersion: string,
architecture: string, architecture: string
allowPreReleases: boolean,
releases: IPyPyManifestRelease[] | undefined
) { ) {
let downloadDir; let downloadDir;
releases = releases ?? (await getAvailablePyPyVersions()); const releases = await getAvailablePyPyVersions();
if (!releases || releases.length === 0) { if (!releases || releases.length === 0) {
throw new Error('No release was found in PyPy version.json'); throw new Error('No release was found in PyPy version.json');
} }
let releaseData = findRelease( const releaseData = findRelease(
releases, releases,
pythonVersion, pythonVersion,
pypyVersion, pypyVersion,
architecture, architecture
false
); );
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
// check for pre-release
core.info(
[
`Stable PyPy version ${pythonVersion} (${pypyVersion}) with arch ${architecture} not found`,
`Trying pre-release versions`
].join(os.EOL)
);
releaseData = findRelease(
releases,
pythonVersion,
pypyVersion,
architecture,
true
);
}
if (!releaseData || !releaseData.foundAsset) { if (!releaseData || !releaseData.foundAsset) {
throw new Error( throw new Error(
`PyPy version ${pythonVersion} (${pypyVersion}) with arch ${architecture} not found` `PyPy version ${pythonVersion} (${pypyVersion}) with arch ${architecture} not found`
@ -64,64 +42,43 @@ export async function installPyPy(
} }
const {foundAsset, resolvedPythonVersion, resolvedPyPyVersion} = releaseData; const {foundAsset, resolvedPythonVersion, resolvedPyPyVersion} = releaseData;
const downloadUrl = `${foundAsset.download_url}`; let downloadUrl = `${foundAsset.download_url}`;
core.info(`Downloading PyPy from "${downloadUrl}" ...`); core.info(`Downloading PyPy from "${downloadUrl}" ...`);
const pypyPath = await tc.downloadTool(downloadUrl);
try { core.info('Extracting downloaded archive...');
const pypyPath = await tc.downloadTool(downloadUrl); if (IS_WINDOWS) {
downloadDir = await tc.extractZip(pypyPath);
core.info('Extracting downloaded archive...'); } else {
if (IS_WINDOWS) { downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
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 = getBinaryDirectory(installDir);
await createPyPySymlink(binaryPath, resolvedPythonVersion);
await installPip(binaryPath);
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
} catch (err) {
if (err instanceof Error) {
// Rate limit?
if (
err instanceof tc.HTTPError &&
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
) {
core.info(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
);
} else {
core.info(err.message);
}
if (err.stack !== undefined) {
core.debug(err.stack);
}
}
throw err;
} }
// 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};
} }
export async function getAvailablePyPyVersions() { async function getAvailablePyPyVersions() {
const url = 'https://downloads.python.org/pypy/versions.json'; const url = 'https://downloads.python.org/pypy/versions.json';
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache'); const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');
@ -141,10 +98,8 @@ async function createPyPySymlink(
) { ) {
const version = semver.coerce(pythonVersion)!; const version = semver.coerce(pythonVersion)!;
const pythonBinaryPostfix = semver.major(version); const pythonBinaryPostfix = semver.major(version);
const pythonMinor = semver.minor(version);
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3'; const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
const pypyMajorMinorBinaryPostfix = `${pythonBinaryPostfix}.${pythonMinor}`; let binaryExtension = IS_WINDOWS ? '.exe' : '';
const binaryExtension = IS_WINDOWS ? '.exe' : '';
core.info('Creating symlinks...'); core.info('Creating symlinks...');
createSymlinkInFolder( createSymlinkInFolder(
@ -160,13 +115,6 @@ async function createPyPySymlink(
`python${binaryExtension}`, `python${binaryExtension}`,
true true
); );
createSymlinkInFolder(
pypyBinaryPath,
`pypy${pypyBinaryPostfix}${binaryExtension}`,
`pypy${pypyMajorMinorBinaryPostfix}${binaryExtension}`,
true
);
} }
async function installPip(pythonLocation: string) { async function installPip(pythonLocation: string) {
@ -183,10 +131,8 @@ export function findRelease(
releases: IPyPyManifestRelease[], releases: IPyPyManifestRelease[],
pythonVersion: string, pythonVersion: string,
pypyVersion: string, pypyVersion: string,
architecture: string, architecture: string
includePrerelease: boolean
) { ) {
const options = {includePrerelease: includePrerelease};
const filterReleases = releases.filter(item => { const filterReleases = releases.filter(item => {
const isPythonVersionSatisfied = semver.satisfies( const isPythonVersionSatisfied = semver.satisfies(
semver.coerce(item.python_version)!, semver.coerce(item.python_version)!,
@ -196,15 +142,11 @@ export function findRelease(
isNightlyKeyword(pypyVersion) && isNightlyKeyword(item.pypy_version); isNightlyKeyword(pypyVersion) && isNightlyKeyword(item.pypy_version);
const isPyPyVersionSatisfied = const isPyPyVersionSatisfied =
isPyPyNightly || isPyPyNightly ||
semver.satisfies( semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion);
pypyVersionToSemantic(item.pypy_version),
pypyVersion,
options
);
const isArchPresent = const isArchPresent =
item.files && item.files &&
(IS_WINDOWS (IS_WINDOWS
? isArchPresentForWindows(item, architecture) ? isArchPresentForWindows(item)
: isArchPresentForMacOrLinux(item, architecture, process.platform)); : isArchPresentForMacOrLinux(item, architecture, process.platform));
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent; return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
}); });
@ -228,26 +170,35 @@ export function findRelease(
const foundRelease = sortedReleases[0]; const foundRelease = sortedReleases[0];
const foundAsset = IS_WINDOWS const foundAsset = IS_WINDOWS
? findAssetForWindows(foundRelease, architecture) ? findAssetForWindows(foundRelease)
: findAssetForMacOrLinux(foundRelease, architecture, process.platform); : findAssetForMacOrLinux(foundRelease, architecture, process.platform);
return { return {
foundAsset, foundAsset,
resolvedPythonVersion: foundRelease.python_version, resolvedPythonVersion: foundRelease.python_version,
resolvedPyPyVersion: foundRelease.pypy_version.trim() 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) { export function pypyVersionToSemantic(versionSpec: string) {
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc))(\d*)/g; const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc))(\d*)/g;
return versionSpec.replace(prereleaseVersion, '$1-$2.$3'); return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
} }
export function isArchPresentForWindows(item: any, architecture: string) { export function isArchPresentForWindows(item: any) {
architecture = replaceX32toX86(architecture);
return item.files.some( return item.files.some(
(file: any) => (file: any) =>
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture WINDOWS_ARCHS.includes(file.arch) &&
WINDOWS_PLATFORMS.includes(file.platform)
); );
} }
@ -261,11 +212,11 @@ export function isArchPresentForMacOrLinux(
); );
} }
export function findAssetForWindows(releases: any, architecture: string) { export function findAssetForWindows(releases: any) {
architecture = replaceX32toX86(architecture);
return releases.files.find( return releases.files.find(
(item: any) => (item: any) =>
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture WINDOWS_ARCHS.includes(item.arch) &&
WINDOWS_PLATFORMS.includes(item.platform)
); );
} }
@ -278,11 +229,3 @@ export function findAssetForMacOrLinux(
(item: any) => item.arch === architecture && item.platform === platform (item: any) => item.arch === architecture && item.platform === platform
); );
} }
function replaceX32toX86(architecture: string): string {
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
if (architecture === 'x32') {
architecture = 'x86';
}
return architecture;
}

View file

@ -3,10 +3,10 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import {ExecOptions} from '@actions/exec/lib/interfaces'; import {ExecOptions} from '@actions/exec/lib/interfaces';
import {IS_WINDOWS, IS_LINUX} from './utils'; import {IS_WINDOWS, IS_LINUX, isGhes} from './utils';
const TOKEN = core.getInput('token'); const TOKEN = core.getInput('token');
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`; const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`;
const MANIFEST_REPO_OWNER = 'actions'; const MANIFEST_REPO_OWNER = 'actions';
const MANIFEST_REPO_NAME = 'python-versions'; const MANIFEST_REPO_NAME = 'python-versions';
const MANIFEST_REPO_BRANCH = 'main'; const MANIFEST_REPO_BRANCH = 'main';
@ -14,33 +14,20 @@ export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_O
export async function findReleaseFromManifest( export async function findReleaseFromManifest(
semanticVersionSpec: string, semanticVersionSpec: string,
architecture: string, architecture: string
manifest: tc.IToolRelease[] | null
): Promise<tc.IToolRelease | undefined> { ): Promise<tc.IToolRelease | undefined> {
if (!manifest) { const manifest: tc.IToolRelease[] = await tc.getManifestFromRepo(
manifest = await getManifest();
}
const foundRelease = await tc.findFromManifest(
semanticVersionSpec,
false,
manifest,
architecture
);
return foundRelease;
}
export function getManifest(): Promise<tc.IToolRelease[]> {
core.debug(
`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`
);
return tc.getManifestFromRepo(
MANIFEST_REPO_OWNER, MANIFEST_REPO_OWNER,
MANIFEST_REPO_NAME, MANIFEST_REPO_NAME,
AUTH, AUTH,
MANIFEST_REPO_BRANCH MANIFEST_REPO_BRANCH
); );
return await tc.findFromManifest(
semanticVersionSpec,
false,
manifest,
architecture
);
} }
async function installPython(workingDirectory: string) { async function installPython(workingDirectory: string) {
@ -72,33 +59,15 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
const downloadUrl = release.files[0].download_url; const downloadUrl = release.files[0].download_url;
core.info(`Download from "${downloadUrl}"`); core.info(`Download from "${downloadUrl}"`);
let pythonPath = ''; const pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
try { core.info('Extract downloaded archive');
pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH); let pythonExtractedFolder;
core.info('Extract downloaded archive'); if (IS_WINDOWS) {
let pythonExtractedFolder; pythonExtractedFolder = await tc.extractZip(pythonPath);
if (IS_WINDOWS) { } else {
pythonExtractedFolder = await tc.extractZip(pythonPath); pythonExtractedFolder = await tc.extractTar(pythonPath);
} else {
pythonExtractedFolder = await tc.extractTar(pythonPath);
}
core.info('Execute installation script');
await installPython(pythonExtractedFolder);
} catch (err) {
if (err instanceof tc.HTTPError) {
// Rate limit?
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
core.info(
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
);
} else {
core.info(err.message);
}
if (err.stack) {
core.debug(err.stack);
}
}
throw err;
} }
core.info('Execute installation script');
await installPython(pythonExtractedFolder);
} }

View file

@ -1,25 +1,13 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as finder from './find-python'; import * as finder from './find-python';
import * as finderPyPy from './find-pypy'; import * as finderPyPy from './find-pypy';
import * as finderGraalPy from './find-graalpy';
import * as path from 'path'; import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
import fs from 'fs';
import {getCacheDistributor} from './cache-distributions/cache-factory'; import {getCacheDistributor} from './cache-distributions/cache-factory';
import { import {isCacheFeatureAvailable} from './utils';
isCacheFeatureAvailable,
logWarning,
IS_MAC,
getVersionInputFromFile,
getVersionInputFromPlainFile
} from './utils';
function isPyPyVersion(versionSpec: string) { function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith('pypy'); return versionSpec.startsWith('pypy-');
}
function isGraalPyVersion(versionSpec: string) {
return versionSpec.startsWith('graalpy');
} }
async function cacheDependencies(cache: string, pythonVersion: string) { async function cacheDependencies(cache: string, pythonVersion: string) {
@ -33,120 +21,28 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
await cacheDistributor.restoreCache(); await cacheDistributor.restoreCache();
} }
function resolveVersionInputFromDefaultFile(): string[] {
const couples: [string, (versionFile: string) => string[]][] = [
['.python-version', getVersionInputFromPlainFile]
];
for (const [versionFile, _fn] of couples) {
logWarning(
`Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '${versionFile}' file.`
);
if (fs.existsSync(versionFile)) {
return _fn(versionFile);
} else {
logWarning(`${versionFile} doesn't exist.`);
}
}
return [];
}
function resolveVersionInput() {
let versions = core.getMultilineInput('python-version');
const versionFile = core.getInput('python-version-file');
if (versions.length) {
if (versionFile) {
core.warning(
'Both python-version and python-version-file inputs are specified, only python-version will be used.'
);
}
} else {
if (versionFile) {
if (!fs.existsSync(versionFile)) {
throw new Error(
`The specified python version file at: ${versionFile} doesn't exist.`
);
}
versions = getVersionInputFromFile(versionFile);
} else {
versions = resolveVersionInputFromDefaultFile();
}
}
return versions;
}
async function run() { async function run() {
if (IS_MAC) {
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
}
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
}
core.debug(
`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`
);
try { try {
const versions = resolveVersionInput(); const version = core.getInput('python-version');
const checkLatest = core.getBooleanInput('check-latest'); if (version) {
const allowPreReleases = core.getBooleanInput('allow-prereleases'); let pythonVersion: string;
if (versions.length) {
let pythonVersion = '';
const arch: string = core.getInput('architecture') || os.arch(); const arch: string = core.getInput('architecture') || os.arch();
const updateEnvironment = core.getBooleanInput('update-environment'); if (isPyPyVersion(version)) {
core.startGroup('Installed versions'); const installed = await finderPyPy.findPyPyVersion(version, arch);
for (const version of versions) { pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
if (isPyPyVersion(version)) { core.info(
const installed = await finderPyPy.findPyPyVersion( `Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
version, );
arch, } else {
updateEnvironment, const installed = await finder.useCpythonVersion(version, arch);
checkLatest, pythonVersion = installed.version;
allowPreReleases core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
);
} else if (isGraalPyVersion(version)) {
const installed = await finderGraalPy.findGraalPyVersion(
version,
arch,
updateEnvironment,
checkLatest,
allowPreReleases
);
pythonVersion = `${installed}`;
core.info(`Successfully set up GraalPy ${installed}`);
} else {
if (version.startsWith('2')) {
core.warning(
'The support for python 2.7 was removed on June 19, 2023. Related issue: https://github.com/actions/setup-python/issues/672'
);
}
const installed = await finder.useCpythonVersion(
version,
arch,
updateEnvironment,
checkLatest,
allowPreReleases
);
pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
}
} }
core.endGroup();
const cache = core.getInput('cache'); const cache = core.getInput('cache');
if (cache && isCacheFeatureAvailable()) { if (cache && isCacheFeatureAvailable()) {
await cacheDependencies(cache, pythonVersion); await cacheDependencies(cache, pythonVersion);
} }
} else {
core.warning(
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
);
} }
const matchersPath = path.join(__dirname, '../..', '.github'); const matchersPath = path.join(__dirname, '../..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);

View file

@ -1,18 +1,11 @@
/* eslint no-unsafe-finally: "off" */
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
import * as toml from '@iarna/toml';
import * as exec from '@actions/exec';
import * as ifm from '@actions/http-client/lib/interfaces';
import * as http from 'http';
export const IS_WINDOWS = process.platform === 'win32'; export const IS_WINDOWS = process.platform === 'win32';
export const IS_LINUX = process.platform === 'linux'; export const IS_LINUX = process.platform === 'linux';
export const IS_MAC = process.platform === 'darwin';
export const WINDOWS_ARCHS = ['x86', 'x64']; export const WINDOWS_ARCHS = ['x86', 'x64'];
export const WINDOWS_PLATFORMS = ['win32', 'win64']; export const WINDOWS_PLATFORMS = ['win32', 'win64'];
const PYPY_VERSION_FILE = 'PYPY_VERSION'; const PYPY_VERSION_FILE = 'PYPY_VERSION';
@ -32,16 +25,6 @@ export interface IPyPyManifestRelease {
files: IPyPyManifestAsset[]; files: IPyPyManifestAsset[];
} }
export interface IGraalPyManifestAsset {
name: string;
browser_download_url: string;
}
export interface IGraalPyManifestRelease {
tag_name: string;
assets: IGraalPyManifestAsset[];
}
/** create Symlinks for downloaded PyPy /** create Symlinks for downloaded PyPy
* It should be executed only for downloaded versions in runtime, because * It should be executed only for downloaded versions in runtime, because
* toolcache versions have this setup. * toolcache versions have this setup.
@ -86,9 +69,9 @@ export function getPyPyVersionFromPath(installDir: string) {
*/ */
export function readExactPyPyVersionFile(installDir: string) { export function readExactPyPyVersionFile(installDir: string) {
let pypyVersion = ''; let pypyVersion = '';
const fileVersion = path.join(installDir, PYPY_VERSION_FILE); let fileVersion = path.join(installDir, PYPY_VERSION_FILE);
if (fs.existsSync(fileVersion)) { if (fs.existsSync(fileVersion)) {
pypyVersion = fs.readFileSync(fileVersion).toString().trim(); pypyVersion = fs.readFileSync(fileVersion).toString();
} }
return pypyVersion; return pypyVersion;
@ -103,7 +86,7 @@ export function writeExactPyPyVersionFile(
} }
/** /**
* Python version should be specified explicitly like "x.y" (3.10, 3.11, etc) * Python version should be specified explicitly like "x.y" (2.7, 3.6, 3.7)
* "3.x" or "3" are not supported * "3.x" or "3" are not supported
* because it could cause ambiguity when both PyPy version and Python version are not precise * because it could cause ambiguity when both PyPy version and Python version are not precise
*/ */
@ -120,193 +103,19 @@ export function isGhes(): boolean {
} }
export function isCacheFeatureAvailable(): boolean { export function isCacheFeatureAvailable(): boolean {
if (cache.isFeatureAvailable()) { if (!cache.isFeatureAvailable()) {
return true; if (isGhes()) {
} throw new Error(
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
} else {
core.warning(
'The runner was not able to contact the cache service. Caching will be skipped'
);
}
if (isGhes()) {
core.warning(
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
return false; return false;
} }
core.warning( return true;
'The runner was not able to contact the cache service. Caching will be skipped'
);
return false;
}
export function logWarning(message: string): void {
const warningPrefix = '[warning]';
core.info(`${warningPrefix}${message}`);
}
async function getWindowsInfo() {
const {stdout} = await exec.getExecOutput(
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
undefined,
{
silent: true
}
);
const windowsVersion = stdout.trim().split(' ')[3];
return {osName: 'Windows', osVersion: windowsVersion};
}
async function getMacOSInfo() {
const {stdout} = await exec.getExecOutput('sw_vers', ['-productVersion'], {
silent: true
});
const macOSVersion = stdout.trim();
return {osName: 'macOS', osVersion: macOSVersion};
}
export async function getLinuxInfo() {
const {stdout} = await exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
silent: true
});
const [osName, osVersion] = stdout.trim().split('\n');
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
return {osName: osName, osVersion: osVersion};
}
export async function getOSInfo() {
let osInfo;
try {
if (IS_WINDOWS) {
osInfo = await getWindowsInfo();
} else if (IS_LINUX) {
osInfo = await getLinuxInfo();
} else if (IS_MAC) {
osInfo = await getMacOSInfo();
}
} catch (err) {
const error = err as Error;
core.debug(error.message);
} finally {
return osInfo;
}
}
/**
* Extract a value from an object by following the keys path provided.
* If the value is present, it is returned. Otherwise undefined is returned.
*/
function extractValue(obj: any, keys: string[]): string | undefined {
if (keys.length > 0) {
const value = obj[keys[0]];
if (keys.length > 1 && value !== undefined) {
return extractValue(value, keys.slice(1));
} else {
return value;
}
} else {
return;
}
}
/**
* Python version extracted from the TOML file.
* If the `project` key is present at the root level, the version is assumed to
* be specified according to PEP 621 in `project.requires-python`.
* Otherwise, if the `tool` key is present at the root level, the version is
* assumed to be specified using poetry under `tool.poetry.dependencies.python`.
* If none is present, returns an empty list.
*/
export function getVersionInputFromTomlFile(versionFile: string): string[] {
core.debug(`Trying to resolve version form ${versionFile}`);
const pyprojectFile = fs.readFileSync(versionFile, 'utf8');
const pyprojectConfig = toml.parse(pyprojectFile);
let keys = [];
if ('project' in pyprojectConfig) {
// standard project metadata (PEP 621)
keys = ['project', 'requires-python'];
} else {
// python poetry
keys = ['tool', 'poetry', 'dependencies', 'python'];
}
const versions = [];
const version = extractValue(pyprojectConfig, keys);
if (version !== undefined) {
versions.push(version);
}
core.info(`Extracted ${versions} from ${versionFile}`);
const rawVersions = Array.from(versions, version =>
version.split(',').join(' ')
);
const validatedVersions = rawVersions
.map(item => semver.validRange(item, true))
.filter((versionRange, index) => {
if (!versionRange) {
core.debug(
`The version ${rawVersions[index]} is not valid SemVer range`
);
}
return !!versionRange;
}) as string[];
return validatedVersions;
}
/**
* Python version extracted from a plain text file.
*/
export function getVersionInputFromPlainFile(versionFile: string): string[] {
core.debug(`Trying to resolve version form ${versionFile}`);
const version = fs.readFileSync(versionFile, 'utf8').trim();
core.info(`Resolved ${versionFile} as ${version}`);
return [version];
}
/**
* Python version extracted from a plain or TOML file.
*/
export function getVersionInputFromFile(versionFile: string): string[] {
if (versionFile.endsWith('.toml')) {
return getVersionInputFromTomlFile(versionFile);
} else {
return getVersionInputFromPlainFile(versionFile);
}
}
/**
* Get the directory containing interpreter binary from installation directory of PyPy or GraalPy
* - On Linux and macOS, the Python interpreter is in 'bin'.
* - On Windows, it is in the installation root.
*/
export function getBinaryDirectory(installDir: string) {
return IS_WINDOWS ? installDir : path.join(installDir, 'bin');
}
/**
* Extract next page URL from a HTTP response "link" header. Such headers are used in GitHub APIs.
*/
export function getNextPageUrl<T>(response: ifm.TypedResponse<T>) {
const responseHeaders = <http.OutgoingHttpHeaders>response.headers;
const linkHeader = responseHeaders.link;
if (typeof linkHeader === 'string') {
for (const link of linkHeader.split(/\s*,\s*/)) {
const match = link.match(/<([^>]+)>(.*)/);
if (match) {
const url = match[1];
for (const param of match[2].split(/\s*;\s*/)) {
if (param.match(/rel="?next"?/)) {
return url;
}
}
}
}
}
return null;
} }

Some files were not shown because too many files have changed in this diff Show more