Skip to content

Commit 3d523d0

Browse files
committed
.github: add CI files and issue templates
1 parent 9785585 commit 3d523d0

File tree

9 files changed

+324
-0
lines changed

9 files changed

+324
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: 'Bug: '
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Describe the bug
11+
12+
<!--
13+
14+
A clear and concise description of what the bug is.
15+
16+
(Before opening an issue, check StrictDoc's 'Troubleshooting' document,
17+
which contains solutions to the most common issues.)
18+
19+
-->
20+
21+
## To Reproduce
22+
23+
<!--
24+
25+
Steps to reproduce the behavior:
26+
27+
1. Go to '...'
28+
2. Click on '....'
29+
3. Scroll down to '....'
30+
4. See error
31+
32+
-->
33+
34+
## Expected behavior
35+
36+
<!-- A clear and concise description of what you expected to happen. -->
37+
38+
## Screenshots
39+
40+
<!-- If applicable, add screenshots to help explain your problem. -->
41+
42+
## Environment
43+
44+
<!--
45+
46+
- OS: (e.g. Ubuntu Linux 22.04, macOS 12.6.3 (21G419), Windows 11)
47+
- Browser: (e.g. Chrome, Safari)
48+
- Version: (e.g. 22)
49+
50+
-->
51+
52+
## Additional context
53+
54+
<!-- Add any other context about the problem here. -->
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Feature request
3+
about: Create a feature request
4+
title: 'Feature: '
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Feel free to complete only the relevant sections and skip the rest. -->
11+
12+
## Description
13+
14+
<!-- Provide a clear and concise description of the feature you want to request. -->
15+
16+
## Problem
17+
18+
<!-- Describe the problem or gap that this feature aims to address. Why is it needed? -->
19+
20+
## Solution
21+
22+
<!-- Suggest a possible solution or feature implementation. -->
23+
24+
## Additional Information
25+
26+
<!-- Add any other relevant details, such as dependencies, related issues, or references to similar features elsewhere. -->

.github/ISSUE_TEMPLATE/general.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: General issue
3+
about: Create a general issue
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "StrictDoc on Linux"
2+
3+
on:
4+
pull_request:
5+
branches: [ "**" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
python-version: [
14+
"3.9", "3.12"
15+
]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Upgrade pip
26+
run: |
27+
python -m pip install --upgrade pip
28+
29+
- name: Install Python packages
30+
run: |
31+
pip install -r requirements.development.txt
32+
33+
- name: Install HPDF dependencies.
34+
run: |
35+
python developer/pip_install_hpdf_deps.py
36+
37+
- name: Run Lint tasks
38+
run: |
39+
invoke lint
40+
41+
- name: Run tests
42+
run: |
43+
invoke test

.github/workflows/ci-mac.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "StrictDoc on macOS"
2+
3+
on:
4+
pull_request:
5+
branches: [ "**" ]
6+
7+
jobs:
8+
build:
9+
runs-on: macos-13
10+
11+
strategy:
12+
matrix:
13+
python-version: [
14+
"3.8", "3.12"
15+
]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Upgrade pip
26+
run: |
27+
python -m pip install --upgrade pip
28+
29+
- name: Install minimal Python packages
30+
run: |
31+
pip install -r requirements.development.txt
32+
33+
- name: Install HPDF dependencies.
34+
run: |
35+
python developer/pip_install_hpdf_deps.py
36+
37+
- name: Run Lint tasks
38+
run: |
39+
invoke lint
40+
41+
- name: Run tests
42+
run: |
43+
invoke test

.github/workflows/ci-windows.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "StrictDoc on Windows"
2+
3+
on:
4+
pull_request:
5+
branches: [ "**" ]
6+
7+
jobs:
8+
build:
9+
runs-on: windows-latest
10+
11+
strategy:
12+
matrix:
13+
python-version: ["3.12"]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Upgrade pip
24+
run: |
25+
python -m pip install --upgrade pip
26+
27+
- name: Install minimal Python packages
28+
run: |
29+
pip install -r requirements.development.txt
30+
31+
- name: Install HPDF dependencies.
32+
run: |
33+
python developer/pip_install_hpdf_deps.py
34+
35+
- name: Run Lint tasks
36+
run: |
37+
invoke lint
38+
39+
- name: Run tests (Bash)
40+
run: |
41+
invoke test
42+
shell: bash

developer/pip_install_hpdf_deps.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import importlib.metadata as importlib_metadata
2+
import os
3+
import subprocess
4+
import sys
5+
import tempfile
6+
7+
import toml
8+
from packaging.requirements import Requirement
9+
10+
11+
class PackageNotFound(Exception):
12+
pass
13+
14+
15+
class PackageVersionConflict(Exception):
16+
pass
17+
18+
19+
# A simplified version inspired by:
20+
# https://github.com/HansBug/hbutils/blob/37879186c489bced2791309c43d131f1703b7bd4/hbutils/system/python/package.py#L171
21+
def check_if_package_installed(package_name: str):
22+
requirement: Requirement = Requirement(package_name)
23+
try:
24+
version = importlib_metadata.distribution(requirement.name).version
25+
except importlib_metadata.PackageNotFoundError:
26+
raise PackageNotFound(requirement) from None
27+
if not requirement.specifier.contains(version):
28+
raise PackageVersionConflict(version)
29+
30+
31+
print( # noqa: T201
32+
"pip_install_hpdf_deps.py: "
33+
"checking if the current Python environment has all packages installed"
34+
".",
35+
flush=True,
36+
)
37+
38+
pyproject_content = toml.load("pyproject.toml")
39+
40+
41+
# The development dependencies are ignored, because they are managed in tox.ini.
42+
dependencies = pyproject_content["project"]["dependencies"]
43+
44+
needs_installation = False
45+
46+
for dependency in dependencies:
47+
try:
48+
check_if_package_installed(dependency)
49+
except PackageNotFound:
50+
print( # noqa: T201
51+
f"pip_install_hpdf_deps.py: "
52+
f"Package is not installed: '{dependency}'.",
53+
flush=True,
54+
)
55+
needs_installation = True
56+
break
57+
except PackageVersionConflict as exception_:
58+
print( # noqa: T201
59+
(
60+
f"pip_install_hpdf_deps.py: version conflict between "
61+
f"hpdf's requirement '{dependency}' "
62+
f"and the already installed package: "
63+
f"{exception_.args[0]}."
64+
),
65+
flush=True,
66+
)
67+
needs_installation = True
68+
break
69+
70+
if not needs_installation:
71+
print( # noqa: T201
72+
"pip_install_hpdf_deps.py: all packages seem to be installed.",
73+
flush=True,
74+
)
75+
sys.exit(0)
76+
77+
print( # noqa: T201
78+
"pip_install_hpdf_deps.py: will install packages.", flush=True
79+
)
80+
81+
all_packages = "\n".join(dependencies) + "\n"
82+
83+
with tempfile.TemporaryDirectory() as tmp_dir:
84+
with open(
85+
os.path.join(tmp_dir, "requirements.txt"), "w", encoding="utf8"
86+
) as tmp_requirements_txt_file:
87+
tmp_requirements_txt_file.write(all_packages)
88+
89+
command = [
90+
sys.executable,
91+
"-m",
92+
"pip",
93+
"install",
94+
"-r",
95+
tmp_requirements_txt_file.name,
96+
]
97+
98+
result = subprocess.run(command, check=True, encoding="utf8")
99+
print( # noqa: T201
100+
f"'pip install' command exited with: {result.returncode}", flush=True
101+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
invoke
2+
toml
23

34
#
45
# Integration tests

tasks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ def format_readme(context):
7171
""")
7272

7373

74+
@task
75+
def lint(context):
76+
pass
77+
78+
7479
@task
7580
def test_integration(
7681
context,

0 commit comments

Comments
 (0)