Skip to content

Commit f099c01

Browse files
committed
Basic structure
0 parents  commit f099c01

13 files changed

Lines changed: 442 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Linting
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
linter:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
- uses: pre-commit/action@v3.0.1

.github/workflows/release.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
environment: Soroban
12+
permissions:
13+
# IMPORTANT: this permission is mandatory for trusted publishing
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Python 3.11
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.11'
22+
architecture: 'x64'
23+
24+
- name: Install hatch
25+
run: pip install hatch
26+
27+
- name: Build
28+
run: hatch build
29+
30+
- name: Publish to PyPI
31+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test
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.12']
19+
defaults:
20+
run:
21+
shell: bash -l {0}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: matrix.python-version
27+
cache: 'pip'
28+
cache-dependency-path: |
29+
**/pyproject.toml
30+
31+
- name: Install package
32+
run: |
33+
pip install .[test]
34+
35+
- name: Test
36+
if: matrix.python-version != '3.12'
37+
run: |
38+
pytest
39+
40+
- name: Test with coverage
41+
if: matrix.python-version == '3.12'
42+
run: |
43+
pytest --cov simdec --cov-report term-missing

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/_build

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-added-large-files
7+
- id: check-ast
8+
- id: fix-byte-order-marker
9+
- id: check-case-conflict
10+
- id: check-docstring-first
11+
- id: check-merge-conflict
12+
- id: detect-private-key
13+
- id: end-of-file-fixer
14+
15+
- repo: https://github.com/psf/black
16+
rev: 24.2.0
17+
hooks:
18+
- id: black
19+
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
# Ruff version.
22+
rev: 'v0.2.2'
23+
hooks:
24+
- id: ruff

CONTRIBUTING.md

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Soroban CLI

0 commit comments

Comments
 (0)