Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67fd444281 | ||
|
|
5ccb29d877 | ||
|
|
c3e033939c | ||
|
|
206e984b94 | ||
|
|
2c3dd9e7e2 | ||
|
|
76bbdfadd7 | ||
|
|
1aafadcfb9 | ||
|
|
b80efd6bc5 | ||
|
|
5cddb27885 | ||
|
|
47c4a7af1d | ||
|
|
af57b64994 | ||
|
|
4818a5a153 | ||
|
|
8bcd2560e2 | ||
|
|
13ae5bb136 | ||
|
|
0c4d7b878c | ||
|
|
13a464fa11 | ||
|
|
b4fe97ecda | ||
|
|
434aeabbb4 | ||
|
|
98c991d13f | ||
|
|
397a35f988 | ||
|
|
48a0f006ff | ||
|
|
978fd06d1f | ||
|
|
050e616f66 | ||
|
|
f6795b163d | ||
|
|
2e6ca74422 | ||
|
|
aa5ddbf8fe | ||
|
|
c0abeaa470 | ||
|
|
197204a31c | ||
|
|
c96b4b55f3 | ||
|
|
9aa1c6cb27 |
@@ -1 +1,2 @@
|
|||||||
* @actions/actions-service
|
* @actions/actions-service
|
||||||
|
* @actions/runner-images-team
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
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
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
# `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:
|
||||||
@@ -17,36 +12,6 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-dist:
|
call-check-dist:
|
||||||
runs-on: ubuntu-latest
|
name: Check dist/
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- 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@v3
|
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: dist/
|
|
||||||
@@ -1,47 +1,13 @@
|
|||||||
name: "Code scanning - action"
|
name: CodeQL analysis
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ 'main' ]
|
branches: [ 'main' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '25 3 * * 5'
|
- cron: '0 3 * * 0'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL-Build:
|
call-codeQL-analysis:
|
||||||
|
name: CodeQL analysis
|
||||||
strategy:
|
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
|
||||||
fail-fast: false
|
|
||||||
|
|
||||||
# CodeQL runs on ubuntu-latest and windows-latest
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v2
|
|
||||||
# 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@v2
|
|
||||||
|
|
||||||
# ℹ️ 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@v2
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Main workflow
|
name: e2e tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -8,32 +9,18 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
test-setup-python:
|
||||||
name: Run
|
name: Test setup-python
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
operating-system: [ubuntu-20.04, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- 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
|
- name: Run with setup-python 2.7
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -9,21 +9,6 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
call-licensed:
|
||||||
runs-on: ubuntu-latest
|
name: Licensed
|
||||||
name: Check licenses
|
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- 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
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Release new action version
|
name: Release new action version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [released]
|
||||||
@@ -21,7 +22,7 @@ jobs:
|
|||||||
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/[email protected].0
|
uses: actions/[email protected].1
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Validate PyPy e2e
|
name: Validate PyPy e2e
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -124,3 +125,45 @@ jobs:
|
|||||||
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
|
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
|
||||||
${EXECUTABLE} --version
|
${EXECUTABLE} --version
|
||||||
shell: bash
|
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@v3
|
||||||
|
- 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
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Validate Python e2e
|
name: Validate Python e2e
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -190,8 +191,35 @@ jobs:
|
|||||||
- name: Validate version
|
- name: Validate version
|
||||||
run: |
|
run: |
|
||||||
$pythonVersion = (python --version)
|
$pythonVersion = (python --version)
|
||||||
if ("$pythonVersion" -NotMatch "${{ matrix.python }}"){
|
if ("$pythonVersion" -NotMatch "${{ matrix.python-version }}"){
|
||||||
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
|
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@v3
|
||||||
|
- 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
|
exit 1
|
||||||
}
|
}
|
||||||
$pythonVersion
|
$pythonVersion
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 3.0.0
|
version: 3.0.4
|
||||||
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
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.7.0
|
version: 1.10.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
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: minimatch
|
name: minimatch
|
||||||
version: 3.0.4
|
version: 3.1.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: a glob matcher in javascript
|
summary: a glob matcher in javascript
|
||||||
homepage: https://github.com/isaacs/minimatch#readme
|
homepage: https://github.com/isaacs/minimatch#readme
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ steps:
|
|||||||
python-version: 'pypy3.9'
|
python-version: 'pypy3.9'
|
||||||
- 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 using `setup-python`.
|
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.
|
||||||
|
|
||||||
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/).
|
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/).
|
||||||
|
|
||||||
For information regarding locally cached versions of Python or PyPy on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).
|
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).
|
||||||
|
|
||||||
## Supported version syntax
|
## Supported version syntax
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
let saveSatetSpy: jest.SpyInstance;
|
let saveSatetSpy: jest.SpyInstance;
|
||||||
let getStateSpy: jest.SpyInstance;
|
let getStateSpy: jest.SpyInstance;
|
||||||
let setOutputSpy: jest.SpyInstance;
|
let setOutputSpy: jest.SpyInstance;
|
||||||
let getLinuxOSReleaseInfoSpy: jest.SpyInstance;
|
|
||||||
|
|
||||||
// cache spy
|
// cache spy
|
||||||
let restoreCacheSpy: jest.SpyInstance;
|
let restoreCacheSpy: jest.SpyInstance;
|
||||||
@@ -67,6 +66,9 @@ 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,7 +85,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
|
|
||||||
whichSpy = jest.spyOn(io, 'which');
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
whichSpy.mockImplementation(() => '/path/to/python');
|
whichSpy.mockImplementation(() => '/path/to/python');
|
||||||
getLinuxOSReleaseInfoSpy = jest.spyOn(utils, 'getLinuxOSReleaseInfo');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Validate provided package manager', () => {
|
describe('Validate provided package manager', () => {
|
||||||
@@ -120,17 +121,11 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
dependencyFile
|
dependencyFile
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
|
||||||
getLinuxOSReleaseInfoSpy.mockImplementation(() =>
|
|
||||||
Promise.resolve('Ubuntu-20.4')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await cacheDistributor.restoreCache();
|
await cacheDistributor.restoreCache();
|
||||||
|
|
||||||
if (process.platform === 'linux' && packageManager === 'pip') {
|
if (process.platform === 'linux' && packageManager === 'pip') {
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-Ubuntu-20.4-python-${pythonVersion}-${packageManager}-${fileHash}`
|
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -42,14 +42,13 @@ 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';
|
||||||
isCacheFeatureAvailable();
|
expect(isCacheFeatureAvailable()).toBeFalsy();
|
||||||
} catch (error) {
|
expect(infoMock).toHaveBeenCalledWith(message);
|
||||||
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'];
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@ inputs:
|
|||||||
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
|
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
|
||||||
default: false
|
default: false
|
||||||
token:
|
token:
|
||||||
description: "Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user."
|
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."
|
||||||
default: ${{ github.token }}
|
default: ${{ github.server_url == 'https://github.com' && 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:
|
update-environment:
|
||||||
|
|||||||
Vendored
+1994
-1094
File diff suppressed because it is too large
Load Diff
Vendored
+2172
-571
File diff suppressed because it is too large
Load Diff
+102
-8
File diff suppressed because one or more lines are too long
+97
-21
File diff suppressed because one or more lines are too long
Generated
+55
-22
@@ -9,8 +9,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.4",
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
@@ -31,9 +31,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
||||||
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
@@ -72,11 +72,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.7.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/exec": {
|
"node_modules/@actions/exec": {
|
||||||
@@ -10160,9 +10177,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
},
|
},
|
||||||
@@ -11340,9 +11357,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
||||||
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
@@ -11380,11 +11397,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.7.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"requires": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/exec": {
|
"@actions/exec": {
|
||||||
@@ -19457,9 +19490,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -8,6 +8,7 @@
|
|||||||
"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 --write \"{,!(node_modules)/**/}*.ts\"",
|
"format": "prettier --write \"{,!(node_modules)/**/}*.ts\"",
|
||||||
"format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
|
"format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
|
||||||
|
"lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"",
|
||||||
"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 --coverage"
|
"test": "jest --coverage"
|
||||||
},
|
},
|
||||||
@@ -23,8 +24,8 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.4",
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
import {getLinuxOSReleaseInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
import {getLinuxInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
||||||
|
|
||||||
class PipCache extends CacheDistributor {
|
class PipCache extends CacheDistributor {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -61,9 +61,9 @@ class PipCache extends CacheDistributor {
|
|||||||
let restoreKey = '';
|
let restoreKey = '';
|
||||||
|
|
||||||
if (IS_LINUX) {
|
if (IS_LINUX) {
|
||||||
const osRelease = await getLinuxOSReleaseInfo();
|
const osInfo = await getLinuxInfo();
|
||||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
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']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`;
|
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||||
} else {
|
} else {
|
||||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
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}`;
|
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||||
|
|||||||
+7
-2
@@ -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} from './utils';
|
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils';
|
||||||
|
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
@@ -85,9 +85,14 @@ export async function useCpythonVersion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
|
const osInfo = await getOSInfo();
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Version ${version} with arch ${architecture} not found`,
|
`The version '${version}' with architecture '${architecture}' was not found for ${
|
||||||
|
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)
|
||||||
);
|
);
|
||||||
|
|||||||
+66
-38
@@ -8,7 +8,6 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
IS_WINDOWS,
|
IS_WINDOWS,
|
||||||
WINDOWS_ARCHS,
|
|
||||||
WINDOWS_PLATFORMS,
|
WINDOWS_PLATFORMS,
|
||||||
IPyPyManifestRelease,
|
IPyPyManifestRelease,
|
||||||
createSymlinkInFolder,
|
createSymlinkInFolder,
|
||||||
@@ -47,37 +46,58 @@ export async function installPyPy(
|
|||||||
let 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);
|
|
||||||
|
|
||||||
core.info('Extracting downloaded archive...');
|
try {
|
||||||
if (IS_WINDOWS) {
|
const pypyPath = await tc.downloadTool(downloadUrl);
|
||||||
downloadDir = await tc.extractZip(pypyPath);
|
|
||||||
} else {
|
core.info('Extracting downloaded archive...');
|
||||||
downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
|
if (IS_WINDOWS) {
|
||||||
|
downloadDir = await tc.extractZip(pypyPath);
|
||||||
|
} else {
|
||||||
|
downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
|
||||||
|
}
|
||||||
|
|
||||||
|
// root folder in archive can have unpredictable name so just take the first folder
|
||||||
|
// downloadDir is unique folder under TEMP and can't contain any other folders
|
||||||
|
const archiveName = fs.readdirSync(downloadDir)[0];
|
||||||
|
|
||||||
|
const toolDir = path.join(downloadDir, archiveName);
|
||||||
|
let installDir = toolDir;
|
||||||
|
if (!isNightlyKeyword(resolvedPyPyVersion)) {
|
||||||
|
installDir = await tc.cacheDir(
|
||||||
|
toolDir,
|
||||||
|
'PyPy',
|
||||||
|
resolvedPythonVersion,
|
||||||
|
architecture
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
||||||
|
|
||||||
|
const binaryPath = getPyPyBinaryPath(installDir);
|
||||||
|
await createPyPySymlink(binaryPath, resolvedPythonVersion);
|
||||||
|
await installPip(binaryPath);
|
||||||
|
|
||||||
|
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
|
||||||
|
} 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() {
|
export async function getAvailablePyPyVersions() {
|
||||||
@@ -157,7 +177,7 @@ export function findRelease(
|
|||||||
const isArchPresent =
|
const isArchPresent =
|
||||||
item.files &&
|
item.files &&
|
||||||
(IS_WINDOWS
|
(IS_WINDOWS
|
||||||
? isArchPresentForWindows(item)
|
? isArchPresentForWindows(item, architecture)
|
||||||
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
||||||
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
||||||
});
|
});
|
||||||
@@ -181,7 +201,7 @@ export function findRelease(
|
|||||||
|
|
||||||
const foundRelease = sortedReleases[0];
|
const foundRelease = sortedReleases[0];
|
||||||
const foundAsset = IS_WINDOWS
|
const foundAsset = IS_WINDOWS
|
||||||
? findAssetForWindows(foundRelease)
|
? findAssetForWindows(foundRelease, architecture)
|
||||||
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -205,11 +225,11 @@ export function pypyVersionToSemantic(versionSpec: string) {
|
|||||||
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArchPresentForWindows(item: any) {
|
export function isArchPresentForWindows(item: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return item.files.some(
|
return item.files.some(
|
||||||
(file: any) =>
|
(file: any) =>
|
||||||
WINDOWS_ARCHS.includes(file.arch) &&
|
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(file.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,11 +243,11 @@ export function isArchPresentForMacOrLinux(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findAssetForWindows(releases: any) {
|
export function findAssetForWindows(releases: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return releases.files.find(
|
return releases.files.find(
|
||||||
(item: any) =>
|
(item: any) =>
|
||||||
WINDOWS_ARCHS.includes(item.arch) &&
|
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(item.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,3 +260,11 @@ 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;
|
||||||
|
}
|
||||||
|
|||||||
+30
-12
@@ -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, isGhes} from './utils';
|
import {IS_WINDOWS, IS_LINUX} from './utils';
|
||||||
|
|
||||||
const TOKEN = core.getInput('token');
|
const TOKEN = core.getInput('token');
|
||||||
const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`;
|
const AUTH = !TOKEN ? 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';
|
||||||
@@ -72,15 +72,33 @@ 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}"`);
|
||||||
const pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
let pythonPath = '';
|
||||||
core.info('Extract downloaded archive');
|
try {
|
||||||
let pythonExtractedFolder;
|
pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||||
if (IS_WINDOWS) {
|
core.info('Extract downloaded archive');
|
||||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
let pythonExtractedFolder;
|
||||||
} else {
|
if (IS_WINDOWS) {
|
||||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
||||||
}
|
} else {
|
||||||
|
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
||||||
|
}
|
||||||
|
|
||||||
core.info('Execute installation script');
|
core.info('Execute installation script');
|
||||||
await installPython(pythonExtractedFolder);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-34
@@ -22,18 +22,18 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
|
|||||||
await cacheDistributor.restoreCache();
|
await cacheDistributor.restoreCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveVersionInput(): string {
|
function resolveVersionInput() {
|
||||||
let version = core.getInput('python-version');
|
let versions = core.getMultilineInput('python-version');
|
||||||
let versionFile = core.getInput('python-version-file');
|
let versionFile = core.getInput('python-version-file');
|
||||||
|
|
||||||
if (version && versionFile) {
|
if (versions.length && versionFile) {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Both python-version and python-version-file inputs are specified, only python-version will be used.'
|
'Both python-version and python-version-file inputs are specified, only python-version will be used.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
if (versions.length) {
|
||||||
return version;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
@@ -42,9 +42,9 @@ function resolveVersionInput(): string {
|
|||||||
`The specified python version file at: ${versionFile} doesn't exist.`
|
`The specified python version file at: ${versionFile} doesn't exist.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
const version = fs.readFileSync(versionFile, 'utf8');
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
return version;
|
return [version];
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarning(
|
logWarning(
|
||||||
@@ -52,14 +52,14 @@ function resolveVersionInput(): string {
|
|||||||
);
|
);
|
||||||
versionFile = '.python-version';
|
versionFile = '.python-version';
|
||||||
if (fs.existsSync(versionFile)) {
|
if (fs.existsSync(versionFile)) {
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
const version = fs.readFileSync(versionFile, 'utf8');
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
return version;
|
return [version];
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarning(`${versionFile} doesn't exist.`);
|
logWarning(`${versionFile} doesn't exist.`);
|
||||||
|
|
||||||
return version;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
@@ -75,35 +75,38 @@ async function run() {
|
|||||||
`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`
|
`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const version = resolveVersionInput();
|
const versions = resolveVersionInput();
|
||||||
const checkLatest = core.getBooleanInput('check-latest');
|
const checkLatest = core.getBooleanInput('check-latest');
|
||||||
|
|
||||||
if (version) {
|
if (versions.length) {
|
||||||
let pythonVersion: string;
|
let pythonVersion = '';
|
||||||
const arch: string = core.getInput('architecture') || os.arch();
|
const arch: string = core.getInput('architecture') || os.arch();
|
||||||
const updateEnvironment = core.getBooleanInput('update-environment');
|
const updateEnvironment = core.getBooleanInput('update-environment');
|
||||||
if (isPyPyVersion(version)) {
|
core.startGroup('Installed versions');
|
||||||
const installed = await finderPyPy.findPyPyVersion(
|
for (const version of versions) {
|
||||||
version,
|
if (isPyPyVersion(version)) {
|
||||||
arch,
|
const installed = await finderPyPy.findPyPyVersion(
|
||||||
updateEnvironment,
|
version,
|
||||||
checkLatest
|
arch,
|
||||||
);
|
updateEnvironment,
|
||||||
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
checkLatest
|
||||||
core.info(
|
);
|
||||||
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
||||||
);
|
core.info(
|
||||||
} else {
|
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
||||||
const installed = await finder.useCpythonVersion(
|
);
|
||||||
version,
|
} else {
|
||||||
arch,
|
const installed = await finder.useCpythonVersion(
|
||||||
updateEnvironment,
|
version,
|
||||||
checkLatest
|
arch,
|
||||||
);
|
updateEnvironment,
|
||||||
pythonVersion = installed.version;
|
checkLatest
|
||||||
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
|
);
|
||||||
|
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);
|
||||||
|
|||||||
+64
-26
@@ -105,40 +105,78 @@ export function isGhes(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
if (isGhes()) {
|
return true;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
core.warning(
|
||||||
}
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
|
||||||
export async function getLinuxOSReleaseInfo() {
|
|
||||||
const {stdout, stderr, exitCode} = await exec.getExecOutput(
|
|
||||||
'lsb_release',
|
|
||||||
['-i', '-r', '-s'],
|
|
||||||
{
|
|
||||||
silent: true
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
return false;
|
||||||
const [osRelease, osVersion] = stdout.trim().split('\n');
|
|
||||||
|
|
||||||
core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`);
|
|
||||||
|
|
||||||
return `${osVersion}-${osRelease}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logWarning(message: string): void {
|
export function logWarning(message: string): void {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${message}`);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user