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
27 changes: 27 additions & 0 deletions .github/actions/build-and-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build-and-test
description: |
Set up Python and run the 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
- name: Show dist files
shell: bash
run: |
echo "Dist files:"
ls -lh dist/
- name: Run pytest
shell: bash
run: |
python -m pip install -e .
pytest
12 changes: 12 additions & 0 deletions .github/actions/setup-python/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: build-and-test
description: |
This action lets the Python version for CI be specified in a single place.

runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
20 changes: 20 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This workflow builds and tests code that is pushed to the `master` branch.

name: merge

on:
push:
branches:
- master

jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Build and test
uses: ./.github/actions/build-and-test
17 changes: 7 additions & 10 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# This workflow builds and tests code in pull requests.

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
fetch-tags: true
fetch-depth: 0
- name: Build and test
uses: ./.github/actions/build-and-test
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow initiates a release of the project.

name: release

on:
workflow_dispatch:
inputs:
version:
description: Release version (e.g. `1.13.12`)
type: string
required: true

jobs:
release:
permissions:
# `contents: write` is required to create tags and create releases
contents: write
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ inputs.version }}
steps:
- name: Checkout repo
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
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 require trusted publishing which isn't setup yet
attestations: false
password: ${{ secrets.PYPI_TOKEN }}
36 changes: 36 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -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. 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

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.
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down