diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cc0161c0..9546f901 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -3,9 +3,18 @@ name: Python package on: push: branches: [master, main] + paths: + - 'nisystemlink_examples/**' + - 'tests/**' + - 'pyproject.toml' + - '.github/workflows/python-package.yml' pull_request: branches: [master, main] - workflow_dispatch: + paths: + - 'nisystemlink_examples/**' + - 'tests/**' + - 'pyproject.toml' + - '.github/workflows/python-package.yml' jobs: build-lint-unit-test: @@ -25,4 +34,38 @@ jobs: - run: poetry run poe test - run: poetry run poe check - run: poetry run poe lint - - run: poetry run poe types \ No newline at end of file + - run: poetry run poe types + release: + runs-on: ubuntu-latest + needs: [build-lint-unit-test] + if: github.event_name == github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') + environment: + name: pypi + url: https://pypi.org/p/nisystemlink-examples + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_REPO_TOKEN }} + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: "poetry" + - run: poetry install + - name: Semantic release + run: | + pip install python-semantic-release==7.34.6 + git config --global user.name "github-actions" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + semantic-release version + env: + GH_TOKEN: ${{secrets.GH_REPO_TOKEN}} + - name: Build package + run: poetry build + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d969f962 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.testing.pytestArgs": ["tests"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56502d2b..286a51f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,6 +80,100 @@ You can also run all checks at once: poetry run poe format && poetry run poe lint && poetry run poe types && poetry run poe test ``` +## Commit Message Convention + +This project uses [Conventional Commits](https://www.conventionalcommits.org/) +for automated versioning and changelog generation of the `nisystemlink_examples` +Python package. + +**When conventional commits matter:** + +- Commits to the `nisystemlink_examples/` package code +- Changes to `tests/`, `pyproject.toml`, or the CI workflow +- When merged to the `main` branch + +For other contributions (examples, documentation, etc.), conventional commit +format is optional but still encouraged for consistency. + +### Commit Message Format + +```md +[optional scope]: + +[optional body] + +[optional footer(s)] +``` + +### Common Types and Version Bumps + +- **`fix:`** - A bug fix (triggers a **PATCH** version bump: 0.1.0 → 0.1.1) + + ```md + fix: correct calculation error in test result processing fix(simulator): + handle empty response from API endpoint + ``` + +- **`feat:`** - A new feature (triggers a **MINOR** version bump: 0.1.0 → 0.2.0) + + ```md + feat: add support for querying test results by date range feat(testdata): add + batch delete functionality for test results + ``` + +- **`feat!:`** or **`BREAKING CHANGE:`** - A breaking change (triggers a + **MAJOR** version bump: 0.1.0 → 1.0.0) + + ```md + feat!: remove deprecated create_result method + ``` + + Or with a footer: + + ```md + feat: redesign simulator API + + BREAKING CHANGE: The create_result method has been removed. Use + create_results_and_steps instead. + ``` + +### Other Common Types (no version bump) + +- **`docs:`** - Documentation changes only +- **`style:`** - Code style changes (formatting, whitespace, etc.) +- **`refactor:`** - Code refactoring without changing functionality +- **`test:`** - Adding or updating tests +- **`chore:`** - Maintenance tasks, dependency updates, etc. +- **`ci:`** - CI/CD configuration changes + +### Examples + +```bash +# Patch release (0.1.0 → 0.1.1) +git commit -m "fix: handle empty response from API endpoint" + +# Minor release (0.1.0 → 0.2.0) +git commit -m "feat: add batch delete functionality for test results" + +# Major release (1.0.0 → 2.0.0) - use commit editor for multi-line +git commit +# Then in the editor: +# feat!: redesign simulator API with new parameter structure +# +# BREAKING CHANGE: Removed create_result(), use create_results_and_steps() +``` + +**What triggers an automated release:** + +When commits following the conventional format are merged to `main` and affect: + +- `nisystemlink_examples/**` (package source code) +- `tests/**` (test files) +- `pyproject.toml` (package configuration) +- `.github/workflows/python-package.yml` (CI/CD workflow) + +The package will be automatically versioned, tagged, and published to PyPI. + ## Security scanning with Snyk This repository uses [Snyk](https://snyk.io/) for security scanning to identify diff --git a/nisystemlink_demo/__init__.py b/nisystemlink_examples/__init__.py similarity index 100% rename from nisystemlink_demo/__init__.py rename to nisystemlink_examples/__init__.py diff --git a/nisystemlink_demo/testdata/__init__.py b/nisystemlink_examples/testdata/__init__.py similarity index 100% rename from nisystemlink_demo/testdata/__init__.py rename to nisystemlink_examples/testdata/__init__.py diff --git a/nisystemlink_demo/testdata/simulator.py b/nisystemlink_examples/testdata/simulator.py similarity index 100% rename from nisystemlink_demo/testdata/simulator.py rename to nisystemlink_examples/testdata/simulator.py diff --git a/pyproject.toml b/pyproject.toml index d0c59eb0..ad567686 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "nisystemlink-demo" +name = "nisystemlink-examples" version = "0.0.0" description = "NI SystemLink examples and demo utilities" authors = ["National Instruments"] @@ -11,7 +11,7 @@ readme = "README.md" keywords = ["nisystemlink", "systemlink"] license = "MIT" packages = [ - {include = "nisystemlink_demo"} + {include = "nisystemlink_examples"} ] [tool.poetry.dependencies] @@ -45,7 +45,7 @@ match = "(main|master)" [tool.poe.tasks] test = "pytest tests" -lint = "flake8 nisystemlink_demo tests" -check = "black --check nisystemlink_demo tests" -format = "black nisystemlink_demo tests" -types = "mypy nisystemlink_demo tests" \ No newline at end of file +lint = "flake8 nisystemlink_examples tests" +check = "black --check nisystemlink_examples tests" +format = "black nisystemlink_examples tests" +types = "mypy nisystemlink_examples tests" \ No newline at end of file diff --git a/tests/testdata/test_simulator.py b/tests/testdata/test_simulator.py index 78447fa4..59ce88d6 100644 --- a/tests/testdata/test_simulator.py +++ b/tests/testdata/test_simulator.py @@ -1,6 +1,6 @@ """Unit tests for the Simulator class.""" -from nisystemlink_demo.testdata.simulator import Simulator +from nisystemlink_examples.testdata.simulator import Simulator class TestSimulator: