Skip to content

Commit c2a77d4

Browse files
authored
chore: update repo review handling (#167)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 06519fa commit c2a77d4

17 files changed

Lines changed: 196 additions & 69 deletions

File tree

.git_archival.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/cd.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v3
16-
17-
- uses: actions/setup-python@v4
1816
with:
19-
python-version: "3.x"
20-
21-
- name: Build sdist and wheel
22-
run: pipx run build
23-
24-
- uses: actions/upload-artifact@v3
25-
with:
26-
path: dist
17+
fetch-depth: 0
2718

28-
- name: Check products
29-
run: pipx run twine check dist/*
19+
- uses: hynek/build-and-inspect-python-package@v1
3020

3121
publish:
3222
name: Publish
@@ -41,7 +31,7 @@ jobs:
4131
steps:
4232
- uses: actions/download-artifact@v3
4333
with:
44-
name: artifact
34+
name: Packages
4535
path: dist
4636

4737
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/reusable-rr-tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
2123

2224
- uses: actions/setup-python@v4
2325
with:
@@ -30,3 +32,14 @@ jobs:
3032
run: python -m pytest -ra
3133
env:
3234
PYTHONUTF8: "1"
35+
36+
action:
37+
name: Action
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v3
41+
with:
42+
fetch-depth: 0
43+
44+
- name: Run sp-repo-review action
45+
uses: ./

.pre-commit-hooks.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
id: sp-repo-review
2+
name: sp-repo-review
3+
description: Check for configuration best practices
4+
entry: repo-review
5+
language: python
6+
types_or: [text]
7+
minimum_pre_commit_version: 2.9.0

README-rr.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# sp-repo-review
2+
3+
[![Actions Status][actions-badge]][actions-link]
4+
[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
5+
[![Live ReadTheDocs][rtd-badge]][rtd-link]
6+
7+
[![PyPI version][pypi-version]][pypi-link]
8+
[![PyPI platforms][pypi-platforms]][pypi-link]
9+
10+
`sp-repo-review` provides checks based on the [Scientific-Python Development
11+
Guide][] at [scientific-python/cookie][].
12+
13+
This tool can check the style of a repository. Use like this:
14+
15+
```bash
16+
pipx run 'sp-repo-review[cli]' <path to repository>
17+
```
18+
19+
This will produce a list of results - green checkmarks mean this rule is
20+
followed, red x’s mean the rule is not. A yellow warning sign means that the
21+
check was skipped because a previous required check failed. Some checks will
22+
fail, that’s okay - the goal is bring all possible issues to your attention, not
23+
to force compliance with arbitrary checks. Eventually there might be a way to
24+
mark checks as ignored.
25+
26+
For example, `GH101` expects all your action files to have a nice `name:` field.
27+
If you are happy with the file-based names you see in CI, you should feel free
28+
to simply ignore this check (just visually ignore it for the moment, a way to
29+
specify ignored checks will likely be added eventually).
30+
31+
All checks are mentioned at least in some way in the [Scientific-Python
32+
Development Guide][]. You should read that first - if you are not attempting to
33+
follow them, some of the checks might not work. For example, the guidelines
34+
specify pytest configuration be placed in `pyproject.toml`. If you place it
35+
somewhere else, then all the pytest checks will be skipped.
36+
37+
<!-- prettier-ignore-start -->
38+
39+
[actions-badge]: https://github.com/scientific-python/cookie/workflows/CI/badge.svg
40+
[actions-link]: https://github.com/scientific-python/cookie/actions
41+
[pypi-link]: https://pypi.org/project/sp-repo-review/
42+
[pypi-platforms]: https://img.shields.io/pypi/pyversions/sp-repo-review
43+
[pypi-version]: https://badge.fury.io/py/sp-repo-review.svg
44+
[docs-badge]: https://readthedocs.org/projects/scientific-python-cookie/badge/?version=latest
45+
[docs-link]: https://scientific-python-cookie.readthedocs.io/en/latest/?badge=latest
46+
[scientific-python development guide]: https://learn.scientific-python.org/development
47+
[scientific-python/cookie]: https://github.com/scientific-python/cookie
48+
[scikit-hep]: https://scikit-hep.org
49+
50+
<!-- prettier-ignore-end -->

README.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
55
[![Live ReadTheDocs][rtd-badge]][rtd-link]
66

7+
[![PyPI version][pypi-version]][pypi-link]
8+
[![PyPI platforms][pypi-platforms]][pypi-link]
9+
710
A cookiecutter template for new Python projects based on the Scientific Python
811
Developer Guide. What makes this different from other cookie cutter templates
912
for Python packages?
1013

11-
- Lives with the [Scientific Python Development Guide][]: Every decision is
14+
- Lives with the [Scientific-Python Development Guide][]: Every decision is
1215
clearly documented and every tool described.
1316
- Twelve different backends to choose from for building packages.
1417
- Template generation tested in GitHub Actions using nox.
1518
- Includes several compiled backends using pybind11, with wheels produced for
1619
all platforms using cibuildwheel.
1720
- Follows PyPA best practices and regularly updated.
18-
- Provides `sp-repo-review` to evaluate existing repos against the guidelines,
19-
with a WebAssembly version integrated with the guide. All checks cross-linked.
21+
- Provides [`sp-repo-review`][pypi-link] to evaluate existing repos against the
22+
guidelines, with a WebAssembly version integrated with the guide. All checks
23+
cross-linked.
2024

21-
Be sure you have read the [Scientific Python Development Guide][] first, and
25+
Be sure you have read the [Scientific-Python Development Guide][] first, and
2226
possibly used them on a project or two. This is _not_ a minimal example or
2327
tutorial. It is a collection of useful tooling for starting a new project using
2428
cookiecutter, or for copying in individual files for an existing project (by
@@ -156,26 +160,29 @@ NSLS-II guide during the 2023 Scientific-Python Developers Summit.
156160

157161
[actions-badge]: https://github.com/scikit-hep/cookie/workflows/CI/badge.svg
158162
[actions-link]: https://github.com/scikit-hep/cookie/actions
159-
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
160-
[github-discussions-link]: https://github.com/scikit-hep/cookie/discussions
161-
[rtd-badge]: https://readthedocs.org/projects/scientific-python-cookie/badge/?version=latest
162-
[rtd-link]: https://scientific-python-cookie.readthedocs.io/en/latest/?badge=latest
163-
[scientific-python development guide]: https://learn.scientific-python.org/development
164163
[cibuildwheel]: https://cibuildwheel.readthedocs.io/en/stable/
165-
[scikit-build]: https://scikit-build.readthedocs.io/en/latest/
166164
[flit]: https://flit.readthedocs.io/en/latest/
165+
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
166+
[github-discussions-link]: https://github.com/scikit-hep/cookie/discussions
167+
[hatch]: https://github.com/ofek/hatch
168+
[hypermodern]: https://github.com/cjolowicz/cookiecutter-hypermodern-python
169+
[maturin]: https://maturin.rs
170+
[meson-python]: https://meson-python.readthedocs.io
167171
[nox]: https://nox.thea.codes/en/stable/
168172
[pdm]: https://pdm.fming.dev
173+
[pep 621]: https://www.python.org/dev/peps/pep-0621
174+
[pipx]: https://pypa.github.io/pipx/
169175
[poetry]: https://python-poetry.org
170176
[pybind11]: https://pybind11.readthedocs.io/en/stable/
177+
[pypi-link]: https://pypi.org/project/sp-repo-review/
178+
[pypi-platforms]: https://img.shields.io/pypi/pyversions/sp-repo-review
179+
[pypi-version]: https://badge.fury.io/py/sp-repo-review.svg
180+
[rtd-badge]: https://readthedocs.org/projects/scientific-python-cookie/badge/?version=latest
181+
[rtd-link]: https://scientific-python-cookie.readthedocs.io/en/latest/?badge=latest
182+
[scientific-python development guide]: https://learn.scientific-python.org/development
183+
[scikit-build]: https://scikit-build.readthedocs.io/en/latest/
171184
[setuptools]: https://setuptools.readthedocs.io/en/latest/
172185
[trampolim]: https://trampolim.readthedocs.io/en/latest/
173-
[pipx]: https://pypa.github.io/pipx/
174186
[whey]: https://whey.readthedocs.io/en/latest/
175-
[maturin]: https://maturin.rs
176-
[hypermodern]: https://github.com/cjolowicz/cookiecutter-hypermodern-python
177-
[hatch]: https://github.com/ofek/hatch
178-
[meson-python]: https://meson-python.readthedocs.io
179-
[pep 621]: https://www.python.org/dev/peps/pep-0621
180187

181188
<!-- prettier-ignore-end -->

action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: sp-repo-review
2+
description: "Runs sp-repo-review"
3+
inputs:
4+
package-dir:
5+
description: "Path to Python package, if different from repo root"
6+
required: false
7+
default: ""
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- uses: actions/setup-python@v4
13+
id: python
14+
with:
15+
python-version: "3.11"
16+
update-environment: false
17+
18+
# prettier-ignore
19+
- name: Run repo-review
20+
shell: bash
21+
run: >
22+
pipx run
23+
--python '${{ steps.python.outputs.python-path }}'
24+
--spec '${{ github.action_path }}[cli]'
25+
repo-review .
26+
--stderr html
27+
--select "${{ inputs.select }}"
28+
--ignore "${{ inputs.ignore }}"
29+
--package-dir "${{ inputs.package-dir }}"
30+
>> $GITHUB_STEP_SUMMARY

docs/_includes/interactive_repo_review.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
const root = ReactDOM.createRoot(
1717
document.getElementById("interactive-repo-review-root")
1818
);
19-
root.render(<App header={false} />);
19+
root.render(
20+
<App
21+
header={false}
22+
deps={["sp_repo_review==2023.06.01", "repo-review==0.7.0b8"]}
23+
/>
24+
);
2025
</script>

docs/assets/js/webapp.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@ function Heading(props) {
1414
component="div"
1515
sx={{ flexGrow: 1 }}
1616
>
17-
SP-Repo-Review
17+
Repo-Review
1818
</MaterialUI.Typography>
19-
<MaterialUI.Button
20-
href="https://learn.scientific-python.org/development"
21-
color="inherit"
22-
>
23-
Developer Guidelines
24-
</MaterialUI.Button>
2519
<MaterialUI.Button
2620
href="https://github.com/scientific-python/repo-review"
2721
color="inherit"
@@ -152,19 +146,18 @@ function Results(props) {
152146
);
153147
}
154148

155-
async function prepare_pyodide() {
149+
async function prepare_pyodide(deps) {
150+
const deps_str = deps.map((i) => `"${i}"`).join(", ");
156151
const pyodide = await loadPyodide();
157152

158153
await pyodide.loadPackage("micropip");
159154
await pyodide.runPythonAsync(`
160155
import micropip
161-
await micropip.install(["sp_repo_review==2023.06.01", "repo-review==0.7.0b4"])
156+
await micropip.install([${deps_str}])
162157
`);
163158
return pyodide;
164159
}
165160

166-
const pyodide_promise = prepare_pyodide();
167-
168161
function MyThemeProvider(props) {
169162
const prefersDarkMode = MaterialUI.useMediaQuery(
170163
"(prefers-color-scheme: dark)"
@@ -190,15 +183,17 @@ function MyThemeProvider(props) {
190183
class App extends React.Component {
191184
constructor(props) {
192185
super(props);
186+
const deps_str = props.deps.map((i) => `"${i}"`).join(", ");
193187
this.state = {
194188
results: [],
195189
repo: urlParams.get("repo") || "",
196190
branch: urlParams.get("branch") || "",
197-
msg: DEFAULT_MSG,
191+
msg: `${DEFAULT_MSG} Packages: ${deps_str}`,
198192
progress: false,
199193
err_msg: "",
200194
url: "",
201195
};
196+
this.pyodide_promise = prepare_pyodide(props.deps);
202197
}
203198

204199
handleCompute() {
@@ -221,7 +216,7 @@ class App extends React.Component {
221216
progress: true,
222217
});
223218
const state = this.state;
224-
pyodide_promise.then((pyodide) => {
219+
this.pyodide_promise.then((pyodide) => {
225220
var families_checks;
226221
try {
227222
families_checks = pyodide.runPython(`

0 commit comments

Comments
 (0)