forked from actions/setup-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consume toolkit from npmjs (actions#12)
- Loading branch information
Danny McCormick
authored
Aug 20, 2019
1 parent
ae4917d
commit 24b4fa7
Showing
56 changed files
with
8,593 additions
and
8,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
!node_modules/ | ||
__tests__/runner/* | ||
!node_modules/ | ||
__tests__/runner/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": false, | ||
"arrowParens": "avoid", | ||
"parser": "typescript" | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": false, | ||
"arrowParens": "avoid", | ||
"parser": "typescript" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2018 GitHub, Inc. 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 MIT License (MIT) | ||
|
||
Copyright (c) 2018 GitHub, Inc. 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
# setup-python | ||
|
||
<p align="left"> | ||
<a href="https://github.com/actions/setup-python"><img alt="GitHub Actions status" src="https://github.com/actions/setup-python/workflows/Main%20workflow/badge.svg"></a> | ||
</p> | ||
|
||
This action sets up a python environment for use in actions by: | ||
|
||
- optionally installing a version of python and adding to PATH. Note that this action only uses versions of Python already installed in the cache. The action will fail if no matching versions are found. | ||
- registering problem matchers for error output | ||
|
||
# Usage | ||
|
||
See [action.yml](action.yml) | ||
|
||
Basic: | ||
```yaml | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' # Version range or exact version of a Python version to use, using semvers version range syntax. | ||
architecture: 'x64' # (x64 or x86) | ||
- run: python my_script.py | ||
``` | ||
Matrix Testing: | ||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-16.04 | ||
strategy: | ||
matrix: | ||
python: [ '2.x', '3.x', 'pypy3' ] | ||
name: Python ${{ matrix.python }} sample | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
architecture: x64 | ||
- run: python my_script.py | ||
``` | ||
# License | ||
The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||
# Contributions | ||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md) | ||
# setup-python | ||
|
||
<p align="left"> | ||
<a href="https://github.com/actions/setup-python"><img alt="GitHub Actions status" src="https://github.com/actions/setup-python/workflows/Main%20workflow/badge.svg"></a> | ||
</p> | ||
|
||
This action sets up a python environment for use in actions by: | ||
|
||
- optionally installing a version of python and adding to PATH. Note that this action only uses versions of Python already installed in the cache. The action will fail if no matching versions are found. | ||
- registering problem matchers for error output | ||
|
||
# Usage | ||
|
||
See [action.yml](action.yml) | ||
|
||
Basic: | ||
```yaml | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' # Version range or exact version of a Python version to use, using semvers version range syntax. | ||
architecture: 'x64' # (x64 or x86) | ||
- run: python my_script.py | ||
``` | ||
Matrix Testing: | ||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-16.04 | ||
strategy: | ||
matrix: | ||
python: [ '2.x', '3.x', 'pypy3' ] | ||
name: Python ${{ matrix.python }} sample | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Setup python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
architecture: x64 | ||
- run: python my_script.py | ||
``` | ||
# License | ||
The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||
# Contributions | ||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
import io = require('@actions/io'); | ||
import fs = require('fs'); | ||
import path = require('path'); | ||
|
||
const toolDir = path.join( | ||
__dirname, | ||
'runner', | ||
path.join( | ||
Math.random() | ||
.toString(36) | ||
.substring(7) | ||
), | ||
'tools' | ||
); | ||
const tempDir = path.join( | ||
__dirname, | ||
'runner', | ||
path.join( | ||
Math.random() | ||
.toString(36) | ||
.substring(7) | ||
), | ||
'temp' | ||
); | ||
|
||
process.env['RUNNER_TOOL_CACHE'] = toolDir; | ||
process.env['RUNNER_TEMP'] = tempDir; | ||
|
||
import * as finder from '../src/find-python'; | ||
|
||
describe('Finder tests', () => { | ||
it('Finds Python if it is installed', async () => { | ||
const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); | ||
await io.mkdirP(pythonDir); | ||
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await finder.findPythonVersion('3.x', 'x64'); | ||
}); | ||
|
||
it('Errors if Python is not installed', async () => { | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
let thrown = false; | ||
try { | ||
await finder.findPythonVersion('3.300000', 'x64'); | ||
} catch { | ||
thrown = true; | ||
} | ||
expect(thrown).toBeTruthy(); | ||
}); | ||
|
||
it('Finds PyPy if it is installed', async () => { | ||
const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); | ||
await io.mkdirP(pythonDir); | ||
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await finder.findPythonVersion('pypy2', 'x64'); | ||
}); | ||
}); | ||
import io = require('@actions/io'); | ||
import fs = require('fs'); | ||
import path = require('path'); | ||
|
||
const toolDir = path.join( | ||
__dirname, | ||
'runner', | ||
path.join( | ||
Math.random() | ||
.toString(36) | ||
.substring(7) | ||
), | ||
'tools' | ||
); | ||
const tempDir = path.join( | ||
__dirname, | ||
'runner', | ||
path.join( | ||
Math.random() | ||
.toString(36) | ||
.substring(7) | ||
), | ||
'temp' | ||
); | ||
|
||
process.env['RUNNER_TOOL_CACHE'] = toolDir; | ||
process.env['RUNNER_TEMP'] = tempDir; | ||
|
||
import * as finder from '../src/find-python'; | ||
|
||
describe('Finder tests', () => { | ||
it('Finds Python if it is installed', async () => { | ||
const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); | ||
await io.mkdirP(pythonDir); | ||
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await finder.findPythonVersion('3.x', 'x64'); | ||
}); | ||
|
||
it('Errors if Python is not installed', async () => { | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
let thrown = false; | ||
try { | ||
await finder.findPythonVersion('3.300000', 'x64'); | ||
} catch { | ||
thrown = true; | ||
} | ||
expect(thrown).toBeTruthy(); | ||
}); | ||
|
||
it('Finds PyPy if it is installed', async () => { | ||
const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); | ||
await io.mkdirP(pythonDir); | ||
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); | ||
// This will throw if it doesn't find it in the cache (because no such version exists) | ||
await finder.findPythonVersion('pypy2', 'x64'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
name: 'Setup Python environment' | ||
description: 'Setup a Python environment and add it to the PATH, additionally providing proxy support' | ||
author: 'GitHub' | ||
inputs: | ||
python-version: | ||
description: 'Version range or exact version of a Python version to use, using semvers version range syntax.' | ||
default: '3.x' | ||
architecture: | ||
description: 'The target architecture (x86, x64) of the Python interpreter.' | ||
default: 'x64' | ||
# Deprecated option, do not use. Will not be supported after October 1, 2019 | ||
version: | ||
description: 'Deprecated. Use python-version instead. Will not be supported after October 1, 2019' | ||
runs: | ||
using: 'node12' | ||
main: 'lib/setup-python.js' | ||
name: 'Setup Python environment' | ||
description: 'Setup a Python environment and add it to the PATH, additionally providing proxy support' | ||
author: 'GitHub' | ||
inputs: | ||
python-version: | ||
description: 'Version range or exact version of a Python version to use, using semvers version range syntax.' | ||
default: '3.x' | ||
architecture: | ||
description: 'The target architecture (x86, x64) of the Python interpreter.' | ||
default: 'x64' | ||
# Deprecated option, do not use. Will not be supported after October 1, 2019 | ||
version: | ||
description: 'Deprecated. Use python-version instead. Will not be supported after October 1, 2019' | ||
runs: | ||
using: 'node12' | ||
main: 'lib/setup-python.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
# Contributors | ||
|
||
### Checkin | ||
|
||
- Do checkin source (src) | ||
- Do checkin build output (lib) | ||
- Do checkin runtime node_modules | ||
- Do not checkin devDependency node_modules (husky can help see below) | ||
|
||
### devDependencies | ||
|
||
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. | ||
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: | ||
|
||
``` | ||
npm install # installs all devDependencies including Husky | ||
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) | ||
git commit -m "Informative commit message" # Commit. This will run Husky | ||
``` | ||
|
||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. | ||
# Contributors | ||
|
||
### Checkin | ||
|
||
- Do checkin source (src) | ||
- Do checkin build output (lib) | ||
- Do checkin runtime node_modules | ||
- Do not checkin devDependency node_modules (husky can help see below) | ||
|
||
### devDependencies | ||
|
||
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. | ||
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: | ||
|
||
``` | ||
npm install # installs all devDependencies including Husky | ||
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) | ||
git commit -m "Informative commit message" # Commit. This will run Husky | ||
``` | ||
|
||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. | ||
It will also make sure these changes are appropriately included in your commit (no further work is needed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
testRunner: 'jest-circus/runner', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
verbose: true | ||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
testRunner: 'jest-circus/runner', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
verbose: true | ||
} |
Oops, something went wrong.