Skip to content

Commit f4976b6

Browse files
committed
feat: add github actions for formatting, linting and testing
I removed one configuration from isort because it creates difference between isort and ruff check.
1 parent dbc3d98 commit f4976b6

File tree

4 files changed

+213
-1
lines changed

4 files changed

+213
-1
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Workflow template from https://github.com/tox-dev/tox-gh
2+
name: Formatting, Linting and Testing
3+
on:
4+
push:
5+
branches: main
6+
pull_request:
7+
branches: main
8+
9+
concurrency:
10+
group: check-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: test with ${{ matrix.py }} on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
py:
21+
- "3.12"
22+
- "3.11"
23+
- "3.10"
24+
- "3.9"
25+
- "3.8"
26+
os:
27+
- ubuntu-latest
28+
- macos-latest
29+
- windows-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup python for test ${{ matrix.py }}
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: ${{ matrix.py }}
39+
40+
- name: Install tox
41+
run: python -m pip install tox-gh>=1.2
42+
43+
- name: Setup test suite
44+
run: tox --notest
45+
46+
- name: Run test suite
47+
env:
48+
TOKEN: ${{ secrets.TOKEN }}
49+
run: tox --skip-pkg-install

CONTRIBUTING.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Contributing
2+
3+
All contributions are welcome and appreciated! Credits will be given in the changelog file.
4+
5+
## Types of Contributions
6+
7+
### Report Bugs
8+
9+
Bugs can come from Oceans 3.0 API (backend) or the onc library. When reporting an issue, please include some descriptions (code snippet, expected behavior, actual behavior, etc.) to help us reproduce the bug.
10+
11+
Bugs from the backend can also be reported at [Oceans 3.0 Data Portal](https://data.oceannetworks.ca/DataPreview) from the request support form located in the top-right corner.
12+
13+
### Fix Bugs / Implement Features
14+
15+
These are issues labeled with "bug" / "enhancement". Any issue that has no assignee is open to whoever wants to implement it.
16+
17+
### Write Documentation
18+
19+
Documentations are important for users to understand the library. You are welcome to raise an issue if you find something that is outdated or can be improved.
20+
21+
For docstring, [numpy style](https://numpydoc.readthedocs.io/en/latest/format.html) is used.
22+
23+
### Commit
24+
25+
We use [conventional commits](https://www.conventionalcommits.org/) for commit messages. Most of the time it is as simple as adding a type before the message.
26+
27+
The general format is as follows:
28+
29+
```text
30+
<type>[optional scope]: short description
31+
32+
[optional body: long description]
33+
34+
[optional footer]
35+
```
36+
37+
Types can be _fix, feat (short for feature), refactor, style, docs, test, etc_. Some examples are:
38+
39+
```text
40+
feat: allow users to cancel a running data product
41+
42+
test: add tests for cancelling a running data product
43+
44+
docs: add docstrings for discovery methods
45+
```
46+
47+
Check [py-pkgs open source book](https://py-pkgs.org/07-releasing-versioning#automatic-version-bumping) for an introduction.
48+
49+
---
50+
51+
## Set up a development environment
52+
53+
Here is a setup for the local development.
54+
55+
### Creating a virtual environment
56+
57+
Make sure the python version meets the minimum version requirement defined in pyproject.toml. This step can be simplified if you are using [VS Code](https://code.visualstudio.com/docs/python/environments) or [PyCharm](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html#python_create_virtual_env).
58+
59+
```shell
60+
# Create a virtual environment
61+
$ python -m venv .venv
62+
63+
# Activate the venv
64+
$ source .venv/bin/activate
65+
# For Windows, use .venv\Scripts\activate.ps1 for powershell or .venv\Scripts\activate.bat for cmd.exe
66+
67+
# Install onc library in editable mode
68+
$ pip install -e .
69+
70+
# Install dependencies (TODO: Change it to use pyproject optional dependencies)
71+
$ pip install -r requirements-dev.txt
72+
```
73+
74+
### Running the test
75+
76+
See README.md in the tests folder.
77+
78+
Or use tox
79+
80+
```shell
81+
$ tox -e py310 # py38, py39, py311, py312. Make sure the specified python version is installed.
82+
```
83+
84+
### Formatter
85+
86+
Code is formatted using [black](https://black.readthedocs.io/en/stable/) and [isort](https://pycqa.github.io/isort/).
87+
88+
```shell
89+
$ black onc tests
90+
$ isort onc tests
91+
```
92+
93+
Or use tox
94+
95+
```shell
96+
$ tox -e format
97+
```
98+
99+
### Linter
100+
101+
[Ruff](https://docs.astral.sh/ruff/) is used for linting.
102+
103+
```shell
104+
$ ruff check onc
105+
```
106+
107+
Or use tox
108+
109+
```shell
110+
$ tox -e lint
111+
```
112+
113+
## Set up a development environment for documentation
114+
115+
WIP.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Source = "https://github.com/OceanNetworksCanada/api-python-client"
3333

3434
[tool.isort]
3535
profile = "black"
36-
src_paths = ["onc", "tests"]
3736

3837
[tool.ruff]
3938
# Reference for the rules https://docs.astral.sh/ruff/rules/

tox.ini

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[tox]
2+
min_version = 4.0
3+
env_list =
4+
py{38,39,310,311,312}
5+
format-check
6+
lint
7+
isolated_build = True
8+
9+
[testenv]
10+
description = run unit tests
11+
deps =
12+
robotframework
13+
python-dotenv
14+
passenv = TOKEN
15+
commands =
16+
robot tests/suites
17+
18+
[testenv:format]
19+
description = run black and isort
20+
skip_install = true
21+
deps =
22+
black
23+
isort
24+
commands = black src tests
25+
isort src tests
26+
27+
[testenv:format-check]
28+
description = run black and isort check
29+
skip_install = true
30+
deps =
31+
black
32+
isort
33+
commands = black --check --diff src tests
34+
isort --check --diff src tests
35+
36+
[testenv:lint]
37+
description = run ruff
38+
skip_install = true
39+
deps =
40+
ruff
41+
commands = ruff check {posargs:src}
42+
43+
[gh]
44+
python =
45+
3.8 = py38
46+
3.9 = py39
47+
3.10 = py310, format-check, lint
48+
3.11 = py311
49+
3.12 = py312

0 commit comments

Comments
 (0)