8000 Merge pull request #69 from actions/master · Ditto190/Github-setup-python@53d19fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 53d19fa

Browse files
authored
Merge pull request actions#69 from actions/master
Update releases/v1 with changes from master
2 parents 948e534 + 9ac7308 commit 53d19fa
  • typed-rest-client
  • underscore
  • uuid
  • src
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    187 files changed

    +6122
    -15035
    lines changed

    .github/workflows/lint-yaml.yml

    Lines changed: 12 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,12 @@
    1+
    name: Lint YAML
    2+
    on: [pull_request]
    3+
    jobs:
    4+
    lint:
    5+
    runs-on: ubuntu-latest
    6+
    steps:
    7+
    - uses: actions/checkout@master
    8+
    - name: Lint action.yml
    9+
    uses: ibiqlik/action-yamllint@master
    10+
    with:
    11+
    file_or_dir: action.yml
    12+
    config_file: yaml-lint-config.yml

    .github/workflows/workflow.yml

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,5 +1,5 @@
    11
    name: Main workflow
    2-
    on: [push]
    2+
    on: [push, pull_request]
    33
    jobs:
    44
    run:
    55
    name: Run
    @@ -14,7 +14,7 @@ jobs:
    1414
    - name: Set Node.js 10.x
    1515
    uses: actions/setup-node@master
    1616
    with:
    17-
    version: 10.x
    17+
    node-version: 10.x
    1818

    1919
    - name: npm install
    2020
    run: npm install

    .gitignore

    Lines changed: 5 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,7 +1,10 @@
    1-
    # Explicitly not ignoring node_modules so that they are included in package downloaded by runner
    2-
    !node_modules/
    1+
    # Ignore node_modules, ncc is used to compile nodejs modules into a single file in the releases branch
    2+
    node_modules/
    33
    __tests__/runner/*
    44

    5+
    # Ignore js files that are transpiled from ts files in src/
    6+
    lib/
    7+
    58
    # Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
    69
    # Logs
    710
    logs

    README.md

    Lines changed: 72 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -16,25 +16,25 @@ See [action.yml](action.yml)
    1616
    Basic:
    1717
    ```yaml
    1818
    steps:
    19-
    - uses: actions/checkout@master
    19+
    - uses: actions/checkout@v2
    2020
    - uses: actions/setup-python@v1
    2121
    with:
    22-
    python-version: '3.x' # Version range or exact version of a Python version to use, using semvers version range syntax.
    23-
    architecture: 'x64' # (x64 or x86)
    22+
    python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
    23+
    architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
    2424
    - run: python my_script.py
    2525
    ```
    2626
    2727
    Matrix Testing:
    2828
    ```yaml
    2929
    jobs:
    3030
    build:
    31-
    runs-on: ubuntu-16.04
    31+
    runs-on: ubuntu-latest
    3232
    strategy:
    3333
    matrix:
    3434
    python-version: [ '2.x', '3.x', 'pypy2', 'pypy3' ]
    3535
    name: Python ${{ matrix.python-version }} sample
    3636
    steps:
    37-
    - uses: actions/checkout@master
    37+
    - uses: actions/checkout@v2
    3838
    - name: Setup python
    3939
    uses: actions/setup-python@v1
    4040
    with:
    @@ -43,6 +43,73 @@ jobs:
    4343
    - run: python my_script.py
    4444
    ```
    4545
    46+
    Exclude a specific Python version:
    47+
    ```yaml
    48+
    jobs:
    49+
    build:
    50+
    runs-on: ${{ matrix.os }}
    51+
    strategy:
    52+
    matrix:
    53+
    os: [ubuntu-latest, macos-latest, windows-latest]
    54+
    python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3]
    55+
    exclude:
    56+
    - os: macos-latest
    57+
    python-version: 3.8
    58+
    - os: windows-latest
    59+
    python-version: 3.6
    60+
    steps:
    61+
    - uses: actions/checkout@v2
    62+
    - name: Set up Python
    63+
    uses: actions/setup-python@v1
    64+
    with:
    65+
    python-version: ${{ matrix.python-version }}
    66+
    - name: Display Python version
    67+
    run: python -c "import sys; print(sys.version)"
    68+
    ```
    69+
    70+
    # Getting started with Python + Actions
    71+
    72+
    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).
    73+
    74+
    # Hosted Tool Cache
    75+
    76+
    GitHub hosted runners have a tools cache that comes with Python + PyPy already installed. This tools cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and there is where you will find Python and PyPy installed. `setup-python` works by taking a specific version of Python or PyPy in this tools cache and adding it to PATH.
    77+
    78+
    || Location |
    79+
    |------|-------|
    80+
    |**Tool Cache Directory** |`RUNNER_TOOL_CACHE`|
    81+
    |**Python Tool Cache**|`RUNNER_TOOL_CACHE/Python/*`|
    82+
    |**PyPy Tool Cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
    83+
    84+
    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.
    85+
    - [Tools cache setup for Ubuntu](https://github.com/actions/virtual-environments/blob/master/images/linux/scripts/installers/hosted-tool-cache.sh)
    86+
    - [Tools cache setup for Windows](https://github.com/actions/virtual-environments/blob/master/images/win/scripts/Installers/Download-ToolCache.ps1)
    87+
    88+
    # Using `setup-python` with a self hosted runner
    89+
    90+
    If you would like to use `setup-python` on a self-hosted runner, you will need to download all versions of Python & PyPy that you would like and setup a similar tools cache locally for your runner.
    91+
    92+
    - Create an global environment variable called `AGENT_TOOLSDIRECTORY` that will point to the root directory of where you want the tools installed. The env variable is preferrably global as it must be set in the shell that will install the tools cache, along with the shell that the runner will be using.
    93+
    - This env variable is used internally by the runner to set the `RUNNER_TOOL_CACHE` env variable
    94+
    - Example for Administrator Powershell: `[System.Environment]::SetEnvironmentVariable("AGENT_TOOLSDIRECTORY", "C:\hostedtoolcache\windows", [System.EnvironmentVariableTarget]::Machine)` (restart the shell afterwards)
    95+
    - Download the appropriate NPM packages from the [GitHub Actions NPM registry](https://github.com/orgs/actions/packages)
    96+
    - Make sure to have `npm` installed, and then [configure npm for use with GitHub packages](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#authenticating-to-github-package-registry)
    97+
    - Create an empty npm project for easier installation (`npm init`) in the tools cache directory. You can delete `package.json`, `package.lock.json` and `node_modules` after all tools get installed
    98+
    - Before downloading a specific package, create an empty folder for the version of Python/PyPY that is being installed. If downloading Python 3.6.8 for example, create `C:\hostedtoolcache\windows\Python\3.6.8`
    99+
    - Once configured, download a specific package by calling `npm install`. Note (if downloading a PyPy package on Windows, you will need 7zip installed along with `7z.exe` added to your PATH)
    100+
    - Each NPM package has multiple versions that determine the version of Python or PyPy that should be installed.
    101+
    - `npm install @actions/toolcache-python-windows-x64@3.7.61579791175` for example installs Python 3.7.6 while `npm install @actions/toolcache-python-windows-x64@3.6.81579791177` installs Python 3.6.8
    102+
    - You can browse and find all available versions of a package by searching the GitHub Actions NPM registry
    103+
    ![image](https://user-images.githubusercontent.com/16109154/76194005-87aeb400-61e5-11ea-9b21-ef9111247f84.png)
    104+
    105+
    # Using Python without `setup-python`
    106+
    107+
    `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`.
    108+
    109+
    # Available versions of Python
    110+
    111+
    For detailed information regarding the available versions of Python that are installed see [Software installed on GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners)
    112+
    46113
    # License
    47114

    48115
    The scripts and documentation in this project are released under the [MIT License](LICENSE)

    action.yml

    Lines changed: 10 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,13 +1,20 @@
    1+
    ---
    12
    name: 'Setup Python'
    2-
    description: 'Set up a specific version of Python and add the command-line tools to the PATH'
    3+
    description: 'Set up a specific version of Python and add the command-line tools to the PATH.'
    34
    author: 'GitHub'
    45
    inputs:
    56
    python-version:
    6-
    description: 'Version range or exact version of a Python version to use, using semvers version range syntax.'
    7+
    description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
    78
    default: '3.x'
    89
    architecture:
    910
    description: 'The target architecture (x86, x64) of the Python interpreter.'
    1011
    default: 'x64'
    12+
    outputs:
    13+
    python-version:
    14+
    description: "The installed python version. Useful when given a version range as input."
    1115
    runs:
    1216
    using: 'node12'
    13-
    main: 'lib/setup-python.js'
    17+
    main: 'dist/index.js'
    18+
    branding:
    19+
    icon: 'code'
    20+
    color: 'yellow'

    0 commit comments

    Comments
     (0)
    0