Skip to content

Commit f72ab87

Browse files
committed
Initialize everything
0 parents  commit f72ab87

23 files changed

+2278
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
groups:
8+
actions-minor:
9+
update-types:
10+
- minor
11+
- patch

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Linting
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
linter:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- uses: pre-commit/action@v3.0.1

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Tansu Python
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
publish:
15+
name: Publish Python distribution to PyPI
16+
runs-on: ubuntu-latest
17+
permissions:
18+
id-token: write
19+
attestations: write
20+
environment:
21+
name: publish-python
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v3
28+
with:
29+
enable-cache: true
30+
31+
- name: Set up Python
32+
run: uv python install 3.12
33+
34+
- name: Install the project
35+
run: uv sync --all-extras --dev
36+
37+
- name: Build
38+
run: uv build
39+
40+
- name: Test import
41+
run: uv run --with scikit-statistics --no-project -- python -c "import skstats"
42+
43+
- name: Generate artifact attestation for sdist and wheels
44+
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c
45+
with:
46+
subject-path: "dist/scikit*"
47+
48+
- name: Verify artifact attestation
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
shell: bash
52+
run: |
53+
for artifact in dist/*; do
54+
echo "# ${artifact}"
55+
gh attestation verify "${artifact}" --repo ${{ github.repository }}
56+
done
57+
58+
- name: Publish distribution to PyPI
59+
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597
60+
with:
61+
print-hash: true

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
pytest:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ['3.11', '3.13']
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v3
24+
with:
25+
enable-cache: true
26+
27+
- name: Set up Python ${{ matrix.python-version }}
28+
run: uv python install ${{ matrix.python-version }}
29+
30+
- name: Install the project
31+
run: uv sync --all-extras --dev
32+
33+
- name: Tests
34+
if: matrix.python-version != '3.11'
35+
run: |
36+
uv run pytest
37+
38+
- name: Tests with coverage
39+
if: matrix.python-version == '3.13'
40+
run: |
41+
uv run pytest --cov skstats --cov-report term-missing

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Temporary and binary files
2+
*~
3+
*.py[cod]
4+
*.so
5+
__pycache__/*
6+
__pycache__
7+
.cache/*
8+
**/.ipynb_checkpoints
9+
10+
# Env variables with direnv
11+
.envrc
12+
13+
# OS generated files
14+
.DS_Store*
15+
16+
# Project files
17+
.project
18+
.pydevproject
19+
.settings
20+
.idea
21+
.vscode
22+
.spyproject
23+
24+
# Test, linter, coverage
25+
htmlcov/*
26+
.coverage
27+
.mypy_cache
28+
.ruff_cache
29+
.pytest_cache
30+
31+
# Build and docs folder/files
32+
build/*
33+
dist/*
34+
sdist/*
35+
docs/html
36+
docs/jupyter_execute

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.6.9
4+
hooks:
5+
# Run the linter.
6+
- id: ruff
7+
args: [ --fix ]
8+
# Run the formatter.
9+
- id: ruff-format

CODE_OF_CONDUCT.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Code of Conduct
2+
3+
Until we have our own code of conduct, we are following NumFOCUS' Code of
4+
Conduct:
5+
6+
https://numfocus.org/code-of-conduct

CONTRIBUTING.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Contributing
2+
3+
Welcome to our community! Thank you for taking the time to read the following.
4+
5+
## TL;DR
6+
7+
* Be cool! For real, toxic people will be banned without warning.
8+
* All code should have tests.
9+
* All code should be documented.
10+
* No changes are ever committed without review and approval.
11+
12+
## Project management
13+
14+
* GitHub is used for the code base.
15+
* For a PR to be integrated, it must be approved at least by one core team member.
16+
* Development discussions happen on Discord but any request **must** be formalized in GitHub. This ensures a common history.
17+
* Continuous Integration is provided by *Github actions* and configuration is located at ``.github/workflows``.
18+
19+
## Code
20+
21+
### Local development
22+
23+
After cloning the repository, use the Makefile!
24+
25+
```bash
26+
$ make
27+
$ make prepare
28+
```
29+
30+
### Testing
31+
32+
Testing your code is paramount. Without continuous integration, we **cannot**
33+
guaranty the quality of the code. Some minor modification on a function can
34+
have unexpected implications. With a single commit, everything can go south!
35+
The ``main`` branch is always on a passing state: CI is green, working code,
36+
and an installable Python package.
37+
38+
The library [pytest](https://docs.pytest.org/en/latest/) is used with
39+
[coverage](https://coverage.readthedocs.io/) to ensure the added
40+
functionalities are covered by tests.
41+
42+
All tests can be launched using:
43+
44+
```bash
45+
uv run pytest --cov skstats --cov-report term-missing
46+
```
47+
48+
The output consists in tests results and coverage report.
49+
50+
> Tests will be automatically launched when you will push your branch to
51+
> GitHub. Be mindful of this resource!
52+
53+
### Style
54+
55+
For all python code, developers **must** follow guidelines from the Python Software Foundation. As a quick reference:
56+
57+
* For code: [PEP 8](https://www.python.org/dev/peps/pep-0008/)
58+
* For documentation: [PEP 257](https://www.python.org/dev/peps/pep-0257/)
59+
* Use NumPyDoc formatting: [Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
60+
61+
And for a more Pythonic code: [PEP 20](https://www.python.org/dev/peps/pep-0020/)
62+
Last but not least, avoid common pitfalls: [Anti-patterns](https://docs.quantifiedcode.com/python-anti-patterns/)
63+
64+
### Linter
65+
66+
Apart from normal unit and integration tests, you can perform a static
67+
analysis of the code using [ruff](https://github.com/astral-sh/ruff). This allows to spot naming errors for
68+
example as well as other style errors.
69+
70+
Just use the pre-commit hooks to make your life easier.
71+
72+
```bash
73+
pre-commit install
74+
```
75+
76+
Manually:
77+
```bash
78+
ruff check --fix
79+
```
80+
81+
## GIT
82+
83+
### Workflow
84+
85+
The development model is based on the Cactus Model also called
86+
[Trunk Based Development](https://trunkbaseddevelopment.com) model.
87+
More specifically, we use the Scaled Trunk-Based Development model.
88+
89+
> Some additional ressources:
90+
> [gitflow](https://nvie.com/posts/a-successful-git-branching-model/),
91+
> [gitflow critique](https://barro.github.io/2016/02/a-succesful-git-branching-model-considered-harmful/),
92+
> [github PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges).
93+
94+
It means that **each** new feature has to go through a new branch. Why?
95+
For peer review. Pushing directly on the develop without review should be
96+
exceptional (hotfix)!
97+
98+
When you try to commit your changes, it will launch the pre-commit hooks
99+
(``.pre-commit-config.yaml``)
100+
and modify the files if there are any changes to be made for the commit to be
101+
accepted. If you don't use this feature and your changes are not compliant
102+
(linter), CI will fail.
103+
104+
### Recipe for new feature
105+
106+
If you want to add a modification, create a new branch branching off ``main``.
107+
Then you can create a pull request on GitHub. From here, the fun begins.
108+
109+
> For every commit you push, the linter and tests are launched.
110+
111+
Your request will only be considered for integration if in a **finished** state:
112+
113+
0. Be nice, subject to own judgment :)
114+
1. Respect python coding rules,
115+
2. Have tests regarding the changes,
116+
3. The branch passes all tests (current and new ones),
117+
4. Maintain test coverage,
118+
5. Have the respective documentation.
119+
120+
#### Writing the commit message
121+
122+
Commit messages should be clear and follow a few basic rules. Example:
123+
124+
```bash
125+
Add functionality X.
126+
127+
Lines shouldn't be longer than 72
128+
characters. If the commit is related to a ticket, you can indicate that
129+
with "See #3456", "See ticket 3456", "Closes #3456", or similar.
130+
```
131+
132+
Describing the motivation for a change, the nature of a bug for bug fixes or
133+
some details on what an enhancement does are also good to include in a commit
134+
message. Messages should be understandable without looking at the code
135+
changes. A commit message like ``fixed another one`` is an example of
136+
what not to do; the reader has to go look for context elsewhere.
137+
138+
### Squash, rebase and merge
139+
140+
Squash-merge is systematically used to maintain a linear history. It's
141+
important to check the message on the squash commit to keep things tidy.
142+
143+
## Making a release
144+
145+
Following is the process that the development team follows in order to make
146+
a release:
147+
148+
1. Update the version in the main `pyproject.toml`
149+
2. Build locally using `uv build`, and verify the content of the artifacts
150+
3. Submit PR, wait for tests to pass, and merge release into `main`
151+
4. On GitHub manually trigger the release workflow
152+
5. Check that a release has been deployed to PyPI and GitHub
153+
6. Check the documentation is built and deployed
154+
7. Check that auto-generated PR is auto-merged on the conda-forge feedstock repo

LICENSE.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2024, Scikit-Stats Python library
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
3. Neither the name of the copyright holder nor the names of its
14+
contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)