Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Default code owner for \<reponame\>
benmont #replace for \<reponame\>
# Default code owners for ni/python-actions
* @mshafer-NI @bkeryan
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug,triage'
---

<!---
Thanks for filing an issue! Before you submit, please read the following:

Search open/closed issues before submitting. Someone may have reported the same issue before.
-->

# Bug Report

<!--- Provide a general summary of the issue here -->

## Repro or Code Sample

<!-- Please provide steps to reproduce the issue and/or a code repository, gist, code snippet or sample files -->

## Expected Behavior

<!--- Tell us what should happen -->

## Current Behavior

<!--- Tell us what happens instead of the expected behavior -->
<!--- If you are seeing an error, please include the full error message and stack trace -->
<!--- If applicable, provide screenshots -->

## Possible Solution

<!--- Not obligatory, but suggest a fix/reason for the bug -->
<!--- Please let us know if you'd be willing to contribute the fix; we'd be happy to work with you -->

## Context

<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment

<!--- Include as many relevant details as possible about the environment you experienced the bug in -->

* `ni/python-actions` version
* Python version
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'enhancement,triage'
---

<!---
Thanks for filing an issue! Before you submit, please read the following:

Search open/closed issues before submitting. Someone may have requested the same feature before.
-->

## Problem to Solve

<!--- Provide a clear and concise description of why this feature is wanted or what problem it solves. -->

## Proposed Solution

<!--- Provide a clear and concise description of the feature you're proposing. -->

<!--- The implementing team may build a list of tasks/sub-issues here:
## Tasks
- [ ] This is a subtask of the feature. (It can be converted to an issue.)
-->
38 changes: 38 additions & 0 deletions .github/workflows/sync_github_issues_to_azdo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Sync issue to Azure DevOps work item

on:
issues:
# Omit "labeled" and "unlabeled" to work around https://github.com/danhellem/github-actions-issue-to-work-item/issues/70
types:
[opened, edited, deleted, closed, reopened, assigned]
issue_comment:
types: [created, edited, deleted]

jobs:
alert:
if: ${{ !github.event.issue.pull_request && github.event.issue.title != 'Dependency Dashboard' }}
runs-on: ubuntu-latest
steps:
- name: Choose work item type
id: choose_work_item_type
run: |
if [ "${{ contains(github.event.issue.labels.*.name, 'enhancement') || contains(github.event.issue.labels.*.name, 'user story') }}" == "true" ]; then
echo "work_item_type=User Story" >> $GITHUB_OUTPUT
elif [ "${{ contains(github.event.issue.labels.*.name, 'tech debt') }}" == "true" ]; then
echo "work_item_type=Technical Debt" >> $GITHUB_OUTPUT
else
echo "work_item_type=Bug" >> $GITHUB_OUTPUT
fi
- uses: danhellem/[email protected]
env:
ado_token: "${{ secrets.AZDO_WORK_ITEM_TOKEN }}"
github_token: "${{ secrets.GH_REPO_TOKEN }}"
ado_organization: "ni"
ado_project: "DevCentral"
ado_area_path: "DevCentral\\Product RnD\\Platform HW and SW\\SW New Invest and Tech\\ETW\\Python CodeGen"
ado_wit: "${{ steps.choose_work_item_type.outputs.work_item_type }}"
ado_new_state: "New"
ado_active_state: "Active"
ado_close_state: "Closed"
ado_bypassrules: true
log_level: 100
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Contributing to \<reponame\>
# Contributing to `ni/python-actions`

Contributions to \<reponame\> are welcome from all!
Contributions to `ni/python-actions` are welcome from all!

\<reponame\> is managed via [git](https://git-scm.com), with the canonical upstream
`ni/python-actions` is managed via [git](https://git-scm.com), with the canonical upstream
repository hosted on [GitHub](https://github.com/ni/<reponame>/).

\<reponame\> follows a pull-request model for development. If you wish to
`ni/python-actions` follows a pull-request model for development. If you wish to
contribute, you will need to create a GitHub account, fork this project, push a
branch with your changes to your project, and then submit a pull request.

Expand Down Expand Up @@ -58,4 +58,4 @@ See [GitHub's official documentation](https://help.github.com/articles/using-pul
(taken from [developercertificate.org](https://developercertificate.org/))

See [LICENSE](https://github.com/ni/<reponame>/blob/main/LICENSE)
for details about how \<reponame\> is licensed.
for details about how `ni/python-actions` is licensed.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2022, National Instruments Corp.
Copyright (c) 2025, National Instruments Corp.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
101 changes: 90 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,94 @@
# GitHub Repo Template
# `ni/python-actions`

GitHub Repo Template is a template for creation of open source projects made
available on GitHub. It includes a permissive open source license, a developer
certificate of origin, and a pull request template. This provides everything
necessary to have a properly licensed open source project.
`ni/python-actions` is a Git repository containing reusable GitHub Actions for NI Python projects.

## Using GitHub Repo Template
## `ni/python-actions/setup-python`

1. Clone or download this repository.
2. Copy its contents into your project (including the hidden .github directory).
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.
4. (Optional) Check out [GitHub Template Guidelines](https://github.com/cezaraugusto/github-template-guidelines) for ideas about how to customize your project.
The `setup-python` action installs Python and adds it to the PATH.

TODO: describe a project in detail, what it does, how to use it, etc.
It is a thin wrapper for https://github.com/actions/setup-python which is intended to
single-source the default Python version for multiple NI Python projects.

By default, this action installs Python 3.11.9.

### Usage

```yaml
steps:
- uses: ni/python-actions/[email protected]
```

### Inputs

#### `python-version`

You can specify the `python-version` input for testing with multiple versions of Python:
```yaml
strategy:
matrix:
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
steps:
- uses: ni/python-actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
```

### Outputs

#### `python-version`

You can use the `python-version` output to get the actual version of Python, which is useful for caching:
```yaml
steps:
- uses: ni/python-actions/[email protected]
id: setup-python
- uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
```

#### `python-path`

`actions/setup-python` sets the `pythonLocation` environment variable to the **directory**
containing the Python installation.

You can also use the `python-path` output to get the path to the Python interpreter:
```yaml
steps:
- uses: ni/python-actions/[email protected]
id: setup-python
- run: pipx install <package> --python ${{ steps.setup-python.outputs.python-version }}
```

## `ni/python-actions/setup-poetry`

The `setup-poetry` action installs Poetry, adds it to the PATH, and caches it to speed up
workflows.

This action installs Poetry using the Python version that was selected by the `setup-python`
action, so you must call `setup-python` first.

By default, this action installs Poetry 1.8.2.

### Usage

```yaml
steps:
- uses: ni/python-actions/[email protected]
- uses: ni/python-actions/[email protected]
- run: poetry install -v
```

### Inputs

#### `poetry-version`

```yaml
steps:
- uses: ni/python-actions/[email protected]
- uses: ni/python-actions/[email protected]
with:
poetry-version: 2.1.3
- run: poetry install -v
```
59 changes: 59 additions & 0 deletions setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Set up Poetry
description: Install Poetry, add it to the PATH, and cache it to speed up workflows.
inputs:
poetry-version:
default: 1.8.2
runs:
using: composite
steps:
- name: Get Python version
id: get-python-version
run: |
if [ ! -d "$pythonLocation" ]; then
echo "You must use the setup-python action before using this action."
exit 1
fi
"$pythonLocation/python" -c "import platform; print(f'python-version={platform.python_version()}')" >> "$GITHUB_OUTPUT"
shell: bash
- name: Set paths (Linux/Mac)
if: runner.os != 'Windows'
run: |
echo "POETRY_BIN_DIR=$HOME/.local/poetry/bin" >> "$GITHUB_ENV"
echo "POETRY_HOME=$HOME/.local/poetry/home" >> "$GITHUB_ENV"
echo "POETRY_HOME_BIN=$HOME/.local/poetry/home/bin" >> "$GITHUB_ENV"
echo "$HOME/.local/poetry/bin" >> "$GITHUB_PATH"
shell: bash
- name: Set paths (Windows)
if: runner.os == 'Windows'
run: |
Add-Content $env:GITHUB_ENV "POETRY_BIN_DIR=$HOME\.local\poetry\bin"
Add-Content $env:GITHUB_ENV "POETRY_HOME=$HOME\.local\poetry\home"
Add-Content $env:GITHUB_ENV "POETRY_HOME_BIN=$HOME\.local\poetry\home\Scripts"
Add-Content $env:GITHUB_PATH "$HOME\.local\poetry\bin"
shell: pwsh
- name: Copy paths from $GITHUB_ENV to $GITHUB_OUTPUT
id: copy-paths
run: |
echo "poetry-bin-dir=$POETRY_BIN_DIR" >> "$GITHUB_OUTPUT"
echo "poetry-home=$POETRY_HOME" >> "$GITHUB_OUTPUT"
shell: bash
- name: Cache poetry
id: cache-poetry
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
# Using ${{ env.POETRY_HOME }} here does not work because it is evaluated before the "set paths" step runs.
path: |
${{ steps.copy-paths.outputs.poetry-bin-dir }}/poetry*
${{ steps.copy-paths.outputs.poetry-home }}
key: poetry${{ inputs.poetry-version }}-${{ runner.os }}-py${{ steps.get-python-version.outputs.python-version }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
"$pythonLocation/python" -m venv "$POETRY_HOME"
"$POETRY_HOME_BIN/python" -m pip install poetry==${{ inputs.poetry-version }}
mkdir -p "$POETRY_BIN_DIR"
ln -s "$POETRY_HOME_BIN/poetry"* "$POETRY_BIN_DIR/"
shell: bash
- name: Print Poetry version
run: poetry --version
shell: bash
18 changes: 18 additions & 0 deletions setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Set up Python
description: Install Python with appropriate defaults for NI Python projects.
inputs:
python-version:
default: 3.11.9
outputs:
python-path:
value: ${{ steps.setup-python.outputs.python-path }}
python-version:
value: ${{ steps.setup-python.outputs.python-version }}
runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
id: setup-python
with:
python-version: ${{ inputs.python-version }}