|
1 | | -# GitHub Repo Template |
| 1 | +# `ni/python-actions` |
2 | 2 |
|
3 | | -GitHub Repo Template is a template for creation of open source projects made |
4 | | -available on GitHub. It includes a permissive open source license, a developer |
5 | | -certificate of origin, and a pull request template. This provides everything |
6 | | -necessary to have a properly licensed open source project. |
| 3 | +`ni/python-actions` is a Git repository containing reusable GitHub Actions for NI Python projects. |
7 | 4 |
|
8 | | -## Using GitHub Repo Template |
| 5 | +## `ni/python-actions/setup-python` |
9 | 6 |
|
10 | | -1. Clone or download this repository. |
11 | | -2. Copy its contents into your project (including the hidden .github directory). |
12 | | -3. Customize each file to suit your project's needs (including the README). Look through the files for "TODO" and \<reponame\>, and replace with content appropriate to your project. |
13 | | -4. (Optional) Check out [GitHub Template Guidelines](https://github.com/cezaraugusto/github-template-guidelines) for ideas about how to customize your project. |
| 7 | +The `setup-python` action installs Python and adds it to the PATH. |
14 | 8 |
|
15 | | -TODO: describe a project in detail, what it does, how to use it, etc. |
| 9 | +It is a thin wrapper for https://github.com/actions/setup-python which is intended to |
| 10 | +single-source the default Python version for multiple NI Python projects. |
| 11 | + |
| 12 | +By default, this action installs Python 3.11.9. |
| 13 | + |
| 14 | +### Usage |
| 15 | + |
| 16 | +```yaml |
| 17 | +steps: |
| 18 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 19 | +``` |
| 20 | +
|
| 21 | +### Inputs |
| 22 | +
|
| 23 | +#### `python-version` |
| 24 | + |
| 25 | +You can specify the `python-version` input for testing with multiple versions of Python: |
| 26 | +```yaml |
| 27 | +strategy: |
| 28 | + matrix: |
| 29 | + python-version: [3.9, '3.10', 3.11, 3.12, 3.13] |
| 30 | +steps: |
| 31 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | +``` |
| 35 | + |
| 36 | +### Outputs |
| 37 | + |
| 38 | +#### `python-version` |
| 39 | + |
| 40 | +You can use the `python-version` output to get the actual version of Python, which is useful for caching: |
| 41 | +```yaml |
| 42 | +steps: |
| 43 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 44 | + id: setup-python |
| 45 | +- uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: .venv |
| 48 | + key: venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} |
| 49 | +``` |
| 50 | + |
| 51 | +#### `python-path` |
| 52 | + |
| 53 | +`actions/setup-python` sets the `pythonLocation` environment variable to the **directory** |
| 54 | +containing the Python installation. |
| 55 | + |
| 56 | +You can also use the `python-path` output to get the path to the Python interpreter: |
| 57 | +```yaml |
| 58 | +steps: |
| 59 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 60 | + id: setup-python |
| 61 | +- run: pipx install <package> --python ${{ steps.setup-python.outputs.python-version }} |
| 62 | +``` |
| 63 | + |
| 64 | +## `ni/python-actions/setup-poetry` |
| 65 | + |
| 66 | +The `setup-poetry` action installs Poetry, adds it to the PATH, and caches it to speed up |
| 67 | +workflows. |
| 68 | + |
| 69 | +This action installs Poetry using the Python version that was selected by the `setup-python` |
| 70 | +action, so you must call `setup-python` first. |
| 71 | + |
| 72 | +By default, this action installs Poetry 1.8.2. |
| 73 | + |
| 74 | +### Usage |
| 75 | + |
| 76 | +```yaml |
| 77 | +steps: |
| 78 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 79 | +- uses: ni/python-actions/setup-poetry@v0.1.0 |
| 80 | +- run: poetry install -v |
| 81 | +``` |
| 82 | + |
| 83 | +### Inputs |
| 84 | + |
| 85 | +#### `poetry-version` |
| 86 | + |
| 87 | +```yaml |
| 88 | +steps: |
| 89 | +- uses: ni/python-actions/setup-python@v0.1.0 |
| 90 | +- uses: ni/python-actions/setup-poetry@v0.1.0 |
| 91 | + with: |
| 92 | + poetry-version: 2.1.3 |
| 93 | +- run: poetry install -v |
| 94 | +``` |
0 commit comments