From 8b7f78e5b8ba4580ff3de68bd266d58a11153da6 Mon Sep 17 00:00:00 2001
From: diehlbw <36572844+diehlbw@users.noreply.github.com>
Date: Thu, 23 May 2024 15:55:37 -0500
Subject: [PATCH] Add github actions for testing MRs (#5)
Create workflows for linting, pytest, and changelogs
---
.devcontainer/.bashrc | 2 +
.github/CODEOWNERS | 1 +
.github/workflows/changelog.yml | 33 +++++++++++++
.github/workflows/ci.yml | 52 +++++++++++++++++++++
.github/workflows/{static.yml => pages.yml} | 0
changelog/README.rst | 21 +++++++++
docs/release_notes/index.rst | 4 +-
pyproject.toml | 9 ++++
setup.cfg | 2 +-
9 files changed, 122 insertions(+), 2 deletions(-)
create mode 100644 .github/workflows/changelog.yml
create mode 100644 .github/workflows/ci.yml
rename .github/workflows/{static.yml => pages.yml} (100%)
create mode 100644 changelog/README.rst
diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc
index 742d253..4d486f0 100644
--- a/.devcontainer/.bashrc
+++ b/.devcontainer/.bashrc
@@ -5,5 +5,7 @@ export PATH=$PATH:$HOME/.local/bin
#check if package is already installed before installing it
if ! python -c "import seismometer" 2> /dev/null; then
+ pip install pre-commit
pip install -r /home/seismo/workspace/requirements.txt
+ pre-commit install
fi
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index f2e164a..b5c654a 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,6 +1,7 @@
# Restrict all files related to deploying to require maintainer approval.
.github/workflows/ @epic-open-source/ai-trust-and-assurance-core
+.github/CODEOWNERS @epic-open-source/ai-trust-and-assurance-core
src/seisomemeter/_version.py @epic-open-source/ai-trust-and-assurance-core
pyproject.toml @epic-open-source/ai-trust-and-assurance-core
setup.cfg @epic-open-source/ai-trust-and-assurance-core
diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml
new file mode 100644
index 0000000..305261f
--- /dev/null
+++ b/.github/workflows/changelog.yml
@@ -0,0 +1,33 @@
+name: Enforce changelog fragment creation
+
+on:
+ pull_request: {}
+
+permissions: "read-all"
+
+jobs:
+ check-changelog-entry:
+ name: changelog entry
+ runs-on: ubuntu-latest
+ # skip job if label is present
+ if: "!contains(github.event.pull_request.labels.*.name, 'skip changelog')"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ # `towncrier check` needs full history to compare
+ fetch-depth: 0
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - name: Install towncrier
+ run: |
+ pip install --upgrade pip
+ pip install towncrier
+ - name: Validate changelog
+ run: |
+ if ! towncrier check --compare-with origin/${{ github.base_ref }}; then
+ echo "Please add a change fragment; see https://github.com/epic-open-source/seismometer/blob/main/changelog/README.rst for details."
+ false
+ fi
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..ef7f20b
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,52 @@
+name: CI
+
+on:
+ push: {}
+ pull_request: {}
+ workflow_dispatch: {}
+
+permissions: "read-all"
+
+jobs:
+ run-linting:
+ name: linting via pre-commit
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - name: Install pre-commit
+ run: |
+ pip install --upgrade pip
+ pip install pre-commit
+ - name: Run pre-commit steps
+ run: |
+ pre-commit run --all-files
+ run-tests:
+ name: tests via pytest
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - name: Install dependencies
+ run: |
+ pip install --upgrade pip
+ pip install -e .[dev,audit]
+ - name: Run tests
+ run: |
+ pytest .
+ - name: Upload coverage
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-data
+ path: coverage/coverage.xml
+ if-no-files-found: error
diff --git a/.github/workflows/static.yml b/.github/workflows/pages.yml
similarity index 100%
rename from .github/workflows/static.yml
rename to .github/workflows/pages.yml
diff --git a/changelog/README.rst b/changelog/README.rst
new file mode 100644
index 0000000..6e66a55
--- /dev/null
+++ b/changelog/README.rst
@@ -0,0 +1,21 @@
+This directory contains changelog `fragments`; small per-fix or per-PR files **ReST**-formatted text that will
+be added to ``CHANGES.rst`` by `towncrier `_.
+
+The result is a documentation page meant for **users**. With this focus in mind, describe the change in the user
+experience over the internal implementation detail.
+
+Use full sentences, in the past tense, with proper punctuation, examples::
+
+ Added support for displaying a fairness audit visualization.
+
+ Upgraded event merging to be compatible with pandas v2.
+
+Each file should be named ``..rst``, where ```` is an issue number, and ```` is one of
+the five towncrier types: feature, bugfix, doc, removal, or misc.
+
+Such as ``1234.bugfix.rst`` or ``2345.doc.rst``
+
+If a pull request fixes an issue, use that number in its file name. If there is no issue, then use the pull
+request instead.
+
+If your change does not deserve a changelog entry, apply the `skip changelog` GitHub label to your pull request.
diff --git a/docs/release_notes/index.rst b/docs/release_notes/index.rst
index d9e63c9..adea31a 100644
--- a/docs/release_notes/index.rst
+++ b/docs/release_notes/index.rst
@@ -7,7 +7,9 @@ This is a list of changes that have been made between releases of the ``seismome
Breaking changes may occur between minor versions prior to the v1 release; afterwhich API changes will be restricted to major version updates.
+.. towncrier release notes start
+
v0.1.0
------
-Initial release!
\ No newline at end of file
+Initial release!
diff --git a/pyproject.toml b/pyproject.toml
index 670c1d2..ebef71d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,12 @@
[build-system]
requires = ["setuptools >= 65.6.0", "wheel >= 0.36.0"]
build-backend = 'setuptools.build_meta'
+
+[tool.towncrier]
+package = "seismometer"
+package_dir = "src"
+filename = "docs/release_notes/index.rst"
+directory = "changelog"
+issue_format = "`#{issue} `__"
+title_format = "{version}"
+underlines = ["-","~"]
diff --git a/setup.cfg b/setup.cfg
index 52cc96e..135110e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -71,7 +71,7 @@ docs =
[tool:pytest]
-addopts = --cov-config=setup.cfg --cov-report=html --cov=seismometer
+addopts = --cov-config=setup.cfg --cov=seismometer --cov-report=term --cov-report=html --cov-report=xml:coverage/coverage.xml
testpaths = tests
json_report = coverage/test-report.json
jsonapi = True