Skip to content

Commit 0a4cf51

Browse files
authored
Merge pull request #1 from sarnold/workflow-bits
workflow cleanup
2 parents ce523c7 + 8546682 commit 0a4cf51

File tree

12 files changed

+148
-39
lines changed

12 files changed

+148
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
pull_request:
66
push:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010
matrix_build:

.github/workflows/containers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
push:
77
branches:
8-
- master
8+
- main
99

1010
jobs:
1111
get_version:

.github/workflows/coverage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
pull_request:
1515
push:
1616
branches:
17-
- master
17+
- main
1818

1919
jobs:
2020
pre_ci:
@@ -300,12 +300,12 @@ jobs:
300300
# Only generate and publish if these conditions are met:
301301
# - The test step ended successfully
302302
# - One of these is met:
303-
# - This is a push event and the push event is on branch 'master' or 'develop'
303+
# - This is a push event and the push event is on branch 'main' or 'develop'
304304
# Note: if this repo is personal (ie, not an org repo) then you can
305305
# use the following to change the scope of the next 2 jobs
306306
# instead of running on branch push as shown below:
307307
# - This is a pull request event and the pull actor is the same as the repo owner
308-
# if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/master' }}
308+
# if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/main' }}
309309
name: Generate badge image with test coverage value
310310
runs-on: ubuntu-24.04
311311
permissions:

.github/workflows/packaging.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
push:
77
branches:
88
- main
9-
- develop
109

1110
jobs:
1211
package_checks:

.github/workflows/pylint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
pull_request:
66
push:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010
pylint:

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
push:
77
branches:
8-
- master
8+
- main
99

1010
jobs:
1111
build:

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_call:
66
pull_request:
77
push:
8-
branches: [ master ]
8+
branches: [ main ]
99

1010
jobs:
1111
python_wheels:

README.rst

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,81 @@
1-
Python Project Template
2-
=======================
1+
Simple Python Project
2+
=====================
3+
4+
Python project using simple setuptools project config; note package
5+
data, scripts, entry points, etc, **all still work** using pyproject.toml
6+
per `setuptools documentation`_.
7+
8+
|ci| |wheels| |bandit| |release|
9+
10+
|pre| |cov| |pylint|
11+
12+
|tag| |license| |reuse| |python|
13+
14+
To use this template, replace the example project name with your own:
15+
16+
* change the project name at the top of ``pyproject.toml``
17+
* change the package directory name under the ``src`` folder
18+
* change the github URL paths in ``pyproject.toml``
19+
* change the project name in ``docs/source/conf.py``
20+
21+
22+
.. _setuptools documentation: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html
23+
24+
Github workflows and setuptools_scm
25+
-----------------------------------
26+
27+
This project uses setuptools_scm_ for dynamic versioning, therefor some
28+
of the (github) workflows will look for a git tag to set the version in
29+
CI. If there are no tags, this will result in some failed workflow runs.
30+
There are several options to make them succeed:
31+
32+
* create a base tag, eg ``git tag -a 0.0.0``
33+
* set SETUPTOOLS_SCM_PRETEND_VERSION to the above value in the workflow env
34+
* disable failing workflows in the Github Actions tab
35+
* delete any workflows you don't need
36+
37+
38+
Github workflows and repo settings
39+
----------------------------------
40+
41+
Some of the automation workflows may also fail without some non-default
42+
repository settings; the following changes are required to allow these
43+
workflows to run.
44+
45+
Go to the repository Settings tab and scroll to the bottom of the General
46+
settings and enable these checkboxes under Pull Requests:
47+
48+
* Always suggest updating pull request branches (optional)
49+
* Allow auto-merge (required)
50+
* Automatically delete head branches (optional)
51+
52+
Next, in the left-hand menu under the Settings tab, click Actions, then General,
53+
then scroll to Workflow permissions:
54+
55+
* make sure *Read repository contents and packages permissions* is selected
56+
* enable the *Allow GitHub Actions to create and approve pull requests* checkbox,
57+
then click Save
58+
59+
In addition, the provided dependabot config expects some issue labels, so open the
60+
project URL below (using your new project name) and add the following new labels:
361

62+
**https://github.com/<your_name>/<project_name>/issues/labels**
63+
64+
* actions
65+
* dependencies
66+
* packaging
67+
68+
69+
Github best practices
70+
---------------------
71+
72+
Finally, best practices for public repositories includes following extra
73+
features:
74+
75+
* under Advanced Security enable Code Scanning, Dependabot, Private
76+
Vulnerability Reporting, and (default) Codeql config
77+
* under Rules => Rulesets add some branch protection rules with required
78+
status checks
479

580

681
Make a ``badges`` branch
@@ -16,7 +91,6 @@ checkout, run the following commands::
1691
$ git checkout main
1792

1893

19-
2094
Dev tools
2195
=========
2296

@@ -142,3 +216,53 @@ specifications.
142216
.. _sbom4python: https://github.com/anthonyharrison/sbom4python
143217
.. _gitchangelog: https://github.com/sarnold/gitchangelog
144218
.. _pre-commit: http://pre-commit.com/
219+
.. _setuptools_scm: https://setuptools-scm.readthedocs.io/en/stable/
220+
221+
222+
.. |ci| image:: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/ci.yml/badge.svg
223+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/ci.yml
224+
:alt: CI Status
225+
226+
.. |wheels| image:: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/wheels.yml/badge.svg
227+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/wheels.yml
228+
:alt: Wheel Status
229+
230+
.. |badge| image:: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/pylint.yml/badge.svg
231+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/pylint.yml
232+
:alt: Pylint Status
233+
234+
.. |release| image:: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/release.yml/badge.svg
235+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/release.yml
236+
:alt: Release Status
237+
238+
.. |bandit| image:: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/bandit.yml/badge.svg
239+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/bandit.yml
240+
:alt: Security check - Bandit
241+
242+
.. |cov| image:: https://raw.githubusercontent.com/sarnold/doorstop-to-mermaid/badges/main/test-coverage.svg
243+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/coverage.yml
244+
:alt: Test coverage
245+
246+
.. |pylint| image:: https://raw.githubusercontent.com/sarnold/doorstop-to-mermaid/badges/main/pylint-score.svg
247+
:target: https://github.com/sarnold/doorstop-to-mermaid/actions/workflows/pylint.yml
248+
:alt: Pylint Score
249+
250+
.. |license| image:: https://img.shields.io/badge/license-MIT-blue
251+
:target: https://github.com/sarnold/doorstop-to-mermaid/blob/main/LICENSE
252+
:alt: License
253+
254+
.. |tag| image:: https://img.shields.io/github/v/tag/sarnold/doorstop-to-mermaid?color=green&include_prereleases&label=latest%20release
255+
:target: https://github.com/sarnold/doorstop-to-mermaid/releases
256+
:alt: GitHub tag
257+
258+
.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg
259+
:target: https://www.python.org/downloads/
260+
:alt: Python
261+
262+
.. |reuse| image:: https://api.reuse.software/badge/git.fsfe.org/reuse/api
263+
:target: https://api.reuse.software/info/git.fsfe.org/reuse/api
264+
:alt: REUSE status
265+
266+
.. |pre| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
267+
:target: https://github.com/pre-commit/pre-commit
268+
:alt: pre-commit

pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ Changelog = "https://github.com/sarnold/doorstop-to-mermaid/blob/main/CHANGELOG.
7272
[tool.setuptools]
7373
package-dir = {"" = "src"}
7474

75-
[tool.setuptools.package-data] # non-python package data if needed
76-
ds2mermaid = [
77-
"*.yaml",
78-
"*.txt",
79-
]
80-
8175
[tool.setuptools_scm]
8276

8377
[tool.pytest.ini_options]
@@ -90,7 +84,7 @@ markers = "subscript"
9084

9185
[tool.coverage.run]
9286
branch = true
93-
source_pkgs = ["src/ds2mermaid"]
87+
source_pkgs = ["src"]
9488
omit = [
9589
"setup.py",
9690
"scripts",
@@ -99,7 +93,7 @@ omit = [
9993
]
10094

10195
[tool.coverage.paths]
102-
source = ["src/ds2mermaid"]
96+
source = ["src"]
10397

10498
[tool.coverage.report]
10599
fail_under = 75

src/ds2mermaid/__init__.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@
22
Example just for package template. Replace with your own code.
33
"""
44

5-
import sys
6-
from pathlib import Path
7-
from typing import Tuple
8-
9-
import numpy as np
10-
from munch import Munch
11-
from scapy.all import conf
12-
13-
if sys.version_info < (3, 8):
14-
from importlib_metadata import version
15-
else:
16-
from importlib.metadata import version
17-
18-
if sys.version_info < (3, 10):
19-
import importlib_resources as ilr # type: ignore[import-not-found]
20-
else:
21-
import importlib.resources as ilr
5+
from importlib.metadata import version
226

237
__version__ = version('ds2mermaid')
248

9+
__all__ = [
10+
"__version__",
11+
]

0 commit comments

Comments
 (0)