From 0963ec88df2cfdcfbb78bc1839e0d3060ba27b4d Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 17:07:22 -0400 Subject: [PATCH 01/11] commit initial workflows --- .github/actions/build-and-test/action.yaml | 19 +++++++++++++++++ .github/actions/setup-python/action.yaml | 10 +++++++++ .github/workflows/merge.yaml | 14 +++++++++++++ .github/workflows/pr.yaml | 13 ++---------- .github/workflows/release.yaml | 24 ++++++++++++++++++++++ 5 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 .github/actions/build-and-test/action.yaml create mode 100644 .github/actions/setup-python/action.yaml create mode 100644 .github/workflows/merge.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/actions/build-and-test/action.yaml b/.github/actions/build-and-test/action.yaml new file mode 100644 index 0000000..491a73f --- /dev/null +++ b/.github/actions/build-and-test/action.yaml @@ -0,0 +1,19 @@ +name: build-and-test + +runs: + using: composite + steps: + - name: Set up Python + uses: ./github/actions/setup-python + - name: Run build + shell: bash + run: python -m build + # TODO: move test dependencies to a separate file + - name: Install dependencies + shell: bash + run: | + python -m pip install -e . + python -m pip install pytest mock + - name: Run pytest + shell: bash + run: pytest diff --git a/.github/actions/setup-python/action.yaml b/.github/actions/setup-python/action.yaml new file mode 100644 index 0000000..6fcc071 --- /dev/null +++ b/.github/actions/setup-python/action.yaml @@ -0,0 +1,10 @@ +name: build-and-test + +runs: + using: composite + steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: pip diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml new file mode 100644 index 0000000..dcb94fc --- /dev/null +++ b/.github/workflows/merge.yaml @@ -0,0 +1,14 @@ +name: merge + +on: + push: + branches: + - master + +jobs: + merge: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - uses: ./.github/actions/build-and-test diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 7e83bc8..4950f50 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -3,18 +3,9 @@ name: pr on: pull_request jobs: - pytest: + pr: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Install dependencies - # TODO: move test dependencies to a separate file - run: | - python -m pip install -e . - python -m pip install pytest mock - - name: Run pytest - run: pytest + - uses: ./.github/actions/build-and-test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0630454 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,24 @@ +name: release + +# on: release + +# Temporarily test this workflow in a pull request +on: pull_request + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Python + uses: ./github/actions/setup-python + - name: Run build + run: python -m build + # - name: Publish package distributions to PyPI + # # TODO: setup attestations and trusted publishing. + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # # attestations requires trusted publishing which isn't setup yet + # attestations: false + # password: ${{ secrets.PYPI_TOKEN }} From 1359549068cf187e185a1e589783b6cbf9fc66c3 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 17:07:52 -0400 Subject: [PATCH 02/11] get `setup.py` version from `git` --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2ce5995..20f058c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,10 @@ def readme(): extra_requirements.append('future>=0.14.3') setup(name='alarmdecoder', - version='1.13.12', + setuptools_git_versioning={ + "enabled": True, + }, + setup_requires=["setuptools-git-versioning>=2.0,<3"], description='Python interface for the AlarmDecoder (AD2) family ' 'of alarm devices which includes the AD2USB, AD2SERIAL and AD2PI.', long_description=readme(), From 78235c121962f5355ccc9a1721e3cbf6e97e3b39 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 17:09:28 -0400 Subject: [PATCH 03/11] fix shared action extensions --- .github/actions/build-and-test/{action.yaml => action.yml} | 0 .github/actions/setup-python/{action.yaml => action.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/actions/build-and-test/{action.yaml => action.yml} (100%) rename .github/actions/setup-python/{action.yaml => action.yml} (100%) diff --git a/.github/actions/build-and-test/action.yaml b/.github/actions/build-and-test/action.yml similarity index 100% rename from .github/actions/build-and-test/action.yaml rename to .github/actions/build-and-test/action.yml diff --git a/.github/actions/setup-python/action.yaml b/.github/actions/setup-python/action.yml similarity index 100% rename from .github/actions/setup-python/action.yaml rename to .github/actions/setup-python/action.yml From 2de723f8a3479a77e7cb0b163260076e026154f4 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 17:16:50 -0400 Subject: [PATCH 04/11] fix action paths/names --- .github/actions/build-and-test/action.yml | 2 +- .github/workflows/merge.yaml | 3 ++- .github/workflows/pr.yaml | 3 ++- .github/workflows/release.yaml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yml index 491a73f..b8278bd 100644 --- a/.github/actions/build-and-test/action.yml +++ b/.github/actions/build-and-test/action.yml @@ -4,7 +4,7 @@ runs: using: composite steps: - name: Set up Python - uses: ./github/actions/setup-python + uses: ./.github/actions/setup-python - name: Run build shell: bash run: python -m build diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index dcb94fc..b47a6b9 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -11,4 +11,5 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 - - uses: ./.github/actions/build-and-test + - name: Build and test + uses: ./.github/actions/build-and-test diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4950f50..0c98b03 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,4 +8,5 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 - - uses: ./.github/actions/build-and-test + - name: Build and test + uses: ./.github/actions/build-and-test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0630454..57a14cb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,7 +12,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Set up Python - uses: ./github/actions/setup-python + uses: ./.github/actions/setup-python - name: Run build run: python -m build # - name: Publish package distributions to PyPI From e41b6dd081e9e6cf975be01a908b3947e7c6988f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:09:39 -0400 Subject: [PATCH 05/11] run build/test action before release --- .github/actions/build-and-test/action.yml | 18 ++++++++---- .github/actions/setup-python/action.yml | 2 ++ .github/workflows/release.yaml | 35 +++++++++++++++++++---- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yml index b8278bd..0dc4597 100644 --- a/.github/actions/build-and-test/action.yml +++ b/.github/actions/build-and-test/action.yml @@ -1,19 +1,27 @@ name: build-and-test +description: | + Set up Python and run build and test steps. runs: using: composite steps: - name: Set up Python uses: ./.github/actions/setup-python + # TODO: move dependencies to a separate file (e.g. a requirements.txt file) + - name: Install dependencies + shell: bash + run: | + python -m pip install pytest mock build - name: Run build shell: bash run: python -m build - # TODO: move test dependencies to a separate file - - name: Install dependencies + - name: Show dist files shell: bash run: | - python -m pip install -e . - python -m pip install pytest mock + echo "Dist files:" + ls -lh dist/ - name: Run pytest shell: bash - run: pytest + run: | + python -m pip install -e . + pytest diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 6fcc071..db5d6b8 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -1,4 +1,6 @@ name: build-and-test +description: | + This action lets the Python version for CI be specified in a single place. runs: using: composite diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 57a14cb..599153b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,20 +1,45 @@ name: release -# on: release +# on: +# workflow_dispatch: +# inputs: +# version: +# description: Release version (e.g. `1.13.12`) +# type: string +# required: true # Temporarily test this workflow in a pull request on: pull_request jobs: release: + # permissions: + # contents: write runs-on: ubuntu-latest + env: + # RELEASE_VERSION: ${{ inputs.version }} + RELEASE_VERSION: "1.13.13" steps: - name: Checkout repo uses: actions/checkout@v4 - - name: Set up Python - uses: ./.github/actions/setup-python - - name: Run build - run: python -m build + - name: Create local lightweight tag + run: git tag "${RELEASE_VERSION}" + - name: Build and test + uses: ./.github/actions/build-and-test + # - name: Push tag + # run: git push origin "${RELEASE_VERSION}" + # - name: Create release from tag + # env: + # GH_TOKEN: ${{ github.token }} + # run: | + # gh api \ + # --method POST \ + # "/repos/${GITHUB_REPOSITORY}/releases" \ + # -f "tag_name=${RELEASE_VERSION}" \ + # -f "name=${RELEASE_VERSION}" \ + # -F "draft=false" \ + # -F "prerelease=false" \ + # -F "generate_release_notes=true" # - name: Publish package distributions to PyPI # # TODO: setup attestations and trusted publishing. # uses: pypa/gh-action-pypi-publish@release/v1 From 0f4aec29bd1b37adaab518fb34477d62d36457a7 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:11:35 -0400 Subject: [PATCH 06/11] set `fetch_tags: true` on `actions/checkout` --- .github/workflows/merge.yaml | 2 ++ .github/workflows/pr.yaml | 2 ++ .github/workflows/release.yaml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index b47a6b9..ae2aa38 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -11,5 +11,7 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + with: + fetch-tags: true - name: Build and test uses: ./.github/actions/build-and-test diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0c98b03..2c08786 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,5 +8,7 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + with: + fetch-tags: true - name: Build and test uses: ./.github/actions/build-and-test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 599153b..f8af103 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v4 + with: + fetch-tags: true - name: Create local lightweight tag run: git tag "${RELEASE_VERSION}" - name: Build and test From 2cdd2111610a3cc24d3bad1325f7c5bcfb4952e2 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:15:07 -0400 Subject: [PATCH 07/11] set `fetch_depth: 0` to get all tag history --- .github/workflows/merge.yaml | 1 + .github/workflows/pr.yaml | 1 + .github/workflows/release.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index ae2aa38..eebb3cd 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -13,5 +13,6 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true + fetch-depth: 0 - name: Build and test uses: ./.github/actions/build-and-test diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2c08786..37d994f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -10,5 +10,6 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true + fetch-depth: 0 - name: Build and test uses: ./.github/actions/build-and-test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f8af103..3920ac5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,6 +24,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true + fetch-depth: 0 - name: Create local lightweight tag run: git tag "${RELEASE_VERSION}" - name: Build and test From 646668d98ccffa7346ff05cceff33193190eece5 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:21:56 -0400 Subject: [PATCH 08/11] revert testing changes for `release.yaml` --- .github/workflows/release.yaml | 67 ++++++++++++++++------------------ 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3920ac5..ae2720f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,24 +1,21 @@ name: release -# on: -# workflow_dispatch: -# inputs: -# version: -# description: Release version (e.g. `1.13.12`) -# type: string -# required: true - -# Temporarily test this workflow in a pull request -on: pull_request +on: + workflow_dispatch: + inputs: + version: + description: Release version (e.g. `1.13.12`) + type: string + required: true jobs: release: - # permissions: - # contents: write + permissions: + # `contents: write` is required to create tags and create releases + contents: write runs-on: ubuntu-latest env: - # RELEASE_VERSION: ${{ inputs.version }} - RELEASE_VERSION: "1.13.13" + RELEASE_VERSION: ${{ inputs.version }} steps: - name: Checkout repo uses: actions/checkout@v4 @@ -29,24 +26,24 @@ jobs: run: git tag "${RELEASE_VERSION}" - name: Build and test uses: ./.github/actions/build-and-test - # - name: Push tag - # run: git push origin "${RELEASE_VERSION}" - # - name: Create release from tag - # env: - # GH_TOKEN: ${{ github.token }} - # run: | - # gh api \ - # --method POST \ - # "/repos/${GITHUB_REPOSITORY}/releases" \ - # -f "tag_name=${RELEASE_VERSION}" \ - # -f "name=${RELEASE_VERSION}" \ - # -F "draft=false" \ - # -F "prerelease=false" \ - # -F "generate_release_notes=true" - # - name: Publish package distributions to PyPI - # # TODO: setup attestations and trusted publishing. - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # # attestations requires trusted publishing which isn't setup yet - # attestations: false - # password: ${{ secrets.PYPI_TOKEN }} + - name: Push tag + run: git push origin "${RELEASE_VERSION}" + - name: Create release from tag + env: + GH_TOKEN: ${{ github.token }} + run: | + gh api \ + --method POST \ + "/repos/${GITHUB_REPOSITORY}/releases" \ + -f "tag_name=${RELEASE_VERSION}" \ + -f "name=${RELEASE_VERSION}" \ + -F "draft=false" \ + -F "prerelease=false" \ + -F "generate_release_notes=true" + - name: Publish package distributions to PyPI + # TODO: setup attestations and trusted publishing. + uses: pypa/gh-action-pypi-publish@release/v1 + with: + # attestations require trusted publishing which isn't setup yet + attestations: false + password: ${{ secrets.PYPI_TOKEN }} From dbb48b9f18fcc64579e6fc1934a4c158e86c9cf3 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:22:26 -0400 Subject: [PATCH 09/11] Revert "fix shared action extensions" This reverts commit 78235c121962f5355ccc9a1721e3cbf6e97e3b39. --- .github/actions/build-and-test/{action.yml => action.yaml} | 0 .github/actions/setup-python/{action.yml => action.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/actions/build-and-test/{action.yml => action.yaml} (100%) rename .github/actions/setup-python/{action.yml => action.yaml} (100%) diff --git a/.github/actions/build-and-test/action.yml b/.github/actions/build-and-test/action.yaml similarity index 100% rename from .github/actions/build-and-test/action.yml rename to .github/actions/build-and-test/action.yaml diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yaml similarity index 100% rename from .github/actions/setup-python/action.yml rename to .github/actions/setup-python/action.yaml From a42d68497107e0fabdb4e4e4227571bd527fd059 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 18:56:45 -0400 Subject: [PATCH 10/11] add docs --- .github/actions/build-and-test/action.yaml | 2 +- .github/workflows/merge.yaml | 2 ++ .github/workflows/pr.yaml | 2 ++ .github/workflows/release.yaml | 2 ++ MAINTAINERS.md | 36 ++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 MAINTAINERS.md diff --git a/.github/actions/build-and-test/action.yaml b/.github/actions/build-and-test/action.yaml index 0dc4597..592ce10 100644 --- a/.github/actions/build-and-test/action.yaml +++ b/.github/actions/build-and-test/action.yaml @@ -1,6 +1,6 @@ name: build-and-test description: | - Set up Python and run build and test steps. + Set up Python and run the build and test steps. runs: using: composite diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index eebb3cd..26eecdf 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -1,3 +1,5 @@ +# This workflow builds and tests code that is pushed to the `master` branch. + name: merge on: diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 37d994f..cba9306 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,3 +1,5 @@ +# This workflow builds and tests code in pull requests. + name: pr on: pull_request diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ae2720f..2d49f05 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,3 +1,5 @@ +# This workflow initiates a release of the project. + name: release on: diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..623a32d --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,36 @@ +# Maintainers + +This document is intended for maintainers of the `nutechsoftware/alarmdecoder` repository. + +It summarizes information about the automated processes involved with the repository. + +## GitHub Actions Automation + +This section describes how GitHub Actions is used to automate test and release processes for the `nutechsoftware/alarmdecoder` repository. + +### Reusable Actions + +The GitHub Actions workflows described below make use of [composite actions](https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action) to help consolidate common workflow steps. + +These actions are found in the [.github/actions](./.github/actions) directory. Each action has a `description` field at the top of the file that describes its purpose. + +### Workflows + +The GitHub Actions workflows can be found in the [./.github/workflows](./.github/workflows) directory. Each workflow has a comment at the top of the file that describes its purpose. + +The sections below further delineate between automated and manual workflows that are in use. More information on triggering workflows (both automatically and manually) can be found here: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow. + +#### Automated Workflows + +Some workflows are configured to run automatically based on certain GitHub events. Examples of these workflows are listed below: + +- `pr.yaml` - runs in response to pull requests being opened +- `merge.yaml` - runs anytime a change is pushed to the `master` branch (i.e. when a PR is merged) + +#### Manual Workflows + +Some workflows are configured to run based on a manual invocation from a maintainer. Examples of these workflows are listed below: + +- `release.yaml` - runs a workflow to build, test, and release the `alarmdecoder` Python packages to PyPI + +More information on manually triggering GitHub Actions workflows can be found here: https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow. From 7a9b6ce7c35774556fd952a948dd13a1a1228259 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Sun, 9 Mar 2025 19:03:42 -0400 Subject: [PATCH 11/11] minor doc updates --- MAINTAINERS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 623a32d..1fe1afc 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -6,7 +6,7 @@ It summarizes information about the automated processes involved with the reposi ## GitHub Actions Automation -This section describes how GitHub Actions is used to automate test and release processes for the `nutechsoftware/alarmdecoder` repository. +This section describes how GitHub Actions is used to automate test and release processes for the `nutechsoftware/alarmdecoder` repository. GitHub Actions is free for public repositories. More information about GitHub Actions can be found on their official documentation site here: https://docs.github.com/en/actions. ### Reusable Actions @@ -16,7 +16,7 @@ These actions are found in the [.github/actions](./.github/actions) directory. E ### Workflows -The GitHub Actions workflows can be found in the [./.github/workflows](./.github/workflows) directory. Each workflow has a comment at the top of the file that describes its purpose. +The GitHub Actions workflows can be found in the [.github/workflows](./.github/workflows) directory. Each workflow has a comment at the top of the file that describes its purpose. The sections below further delineate between automated and manual workflows that are in use. More information on triggering workflows (both automatically and manually) can be found here: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow.