Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
97339e2
Add formating and linting pre-commit hooks
JonathanPlasse Oct 26, 2022
0cddc4e
Add pyupgrade pre-commit hook
JonathanPlasse Oct 26, 2022
0134584
Add prettier and markdownlint pre-commit hook
JonathanPlasse Oct 26, 2022
e3e886a
Use stricter mypy configuration
JonathanPlasse Oct 27, 2022
86cc496
Use mypy strict mode
JonathanPlasse Oct 28, 2022
7649c3a
Fix failing tests without numpy
JonathanPlasse Oct 28, 2022
a991ec4
Make pymap3d PEP 561 compliant
JonathanPlasse Oct 29, 2022
1ca969b
Fix CI workflows for pull requests
JonathanPlasse Oct 29, 2022
f96676a
Improve coverage of timeconv
JonathanPlasse Oct 29, 2022
24dd16c
Add coverage to CI
JonathanPlasse Oct 29, 2022
1f4c108
Add coverage, mypy and black badges
JonathanPlasse Oct 29, 2022
a58baf7
Add CONTRIBUTING.md
JonathanPlasse Oct 29, 2022
735425e
Add name to codecov CI
JonathanPlasse Oct 30, 2022
25db2d6
Autoupdate pre-commit
JonathanPlasse Oct 30, 2022
fcee86d
Move .coveragerc into pyproject.toml
JonathanPlasse Nov 2, 2022
3be00ef
Remove CI types filter on pull requests
JonathanPlasse Nov 2, 2022
90c1371
Update .pre-commit-config.yaml
JonathanPlasse Nov 15, 2022
d0f668c
Fix mathfun.py mypy errors
JonathanPlasse Nov 15, 2022
82403c6
Fix pyproject.toml
JonathanPlasse Nov 15, 2022
6bf6d09
Apply pyupgrade
JonathanPlasse Nov 15, 2022
751be8b
Fix mypy errors
JonathanPlasse Nov 15, 2022
198d9d6
Fix pyproject.toml coverage configuration
JonathanPlasse Nov 15, 2022
7c5c4fc
Update .pre-commit-config.yaml
JonathanPlasse Nov 15, 2022
a180efb
Replace Flake8 by Ruff
JonathanPlasse Nov 16, 2022
6c33a23
Enable more linter in Ruff
JonathanPlasse Nov 16, 2022
aaee876
Make Ellipsoid class instead of dataclass
JonathanPlasse Nov 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# GitHub Actions CI workflows

Definitions for GitHub Actions (continuous integration) workflows

## Publishing

To publish a new version of the `pymap3d` package to PyPI, create and publish a
release in GitHub (preferrably from a Git tag) for the version; the workflow
will automatically build and publish an sdist and wheel from the tag.
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ name: ci
on:
push:
paths:
- "**.py"
- .github/workflows/ci.yml
- "!scripts/"
pull-request:
- "**.py"
- .github/workflows/ci.yml
- "**.py"
- .github/workflows/ci.yml
- "!scripts/"
pull_request:
paths:
- "**.py"
- .github/workflows/ci.yml

jobs:

full:
runs-on: ${{ matrix.os }}

name: ${{ matrix.os }} Python ${{ matrix.python-version }}
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]
include:
- os: macos-latest
python-version: '3.11'
- os: windows-latest
python-version: '3.11'
- os: macos-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.11"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3

- run: pip install .[full,tests,lint]
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- run: flake8
- run: mypy
- name: Install tests dependencies
run: pip install .[full,tests]

- run: pytest
- run: pytest

coverage:
runs-on: ubuntu-latest
Expand All @@ -55,7 +55,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install tests and lint dependencies
- name: Install tests and coverage dependencies
run: pip install -e .[tests,coverage]

- name: Collect coverage without NumPy
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/ci_stdlib_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ name: ci_stdlib_only
on:
push:
paths:
- "**.py"
- .github/workflows/ci_stdlib_only.yml
- "!scripts/"
pull-request:
- "**.py"
- .github/workflows/ci_stdlib_only.yml
- "**.py"
- .github/workflows/ci_stdlib_only.yml
- "!scripts/"
pull_request:
paths:
- "**.py"
- .github/workflows/ci_stdlib_only.yml

jobs:

stdlib_only:
runs-on: ${{ matrix.os }}

name: ${{ matrix.os }} Python ${{ matrix.python-version }}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11']
os: ['ubuntu-latest']
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest"]
include:
- os: macos-latest
python-version: '3.11'
- os: windows-latest
python-version: '3.11'
- os: macos-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.11"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- run: pip install .[tests]
- run: pip install .[tests]

- run: pytest
- run: pytest
32 changes: 14 additions & 18 deletions .github/workflows/publish-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install builder
run: pip install build

- name: Update pip
run: pip install -U pip
- name: Build package
run: pyproject-build --outdir dist/ .

- name: Install builder
run: pip install build

- name: Build package
run: pyproject-build --outdir dist/ .

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .lgtm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
path_classifiers:
test:
- exclude: scripts
- exclude: scripts

extraction:
python:
Expand Down
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.121
hooks:
- id: ruff
args:
- --fix

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
additional_dependencies:
- numpy
- pytest
- types-python-dateutil
- types-requests
- xarray

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier

- repo: https://github.com/markdownlint/markdownlint
rev: v0.12.0
hooks:
- id: markdownlint
args: ["--rules", "~MD013,~MD032"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-type-ignore
- id: python-no-eval
90 changes: 90 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Contributing

## Setting up an environment

Clone the `PyMap3D`.

Inside the repository, create a virtual environment.

```bash
python3 -m venv env
```

Activate the virtual environment.

```bash
source ./env/bin/activate
```

Upgrade `pip`.

```bash
pip install --upgrade pip
```

Install the development dependencies.

```bash
pip install -e .[full,tests,lint,format]
```

Install [pre-commit](https://pre-commit.com/) so that your code is formatted and checked when you are doing a commit.

```bash
pip install pre-commit
pre-commit install
```

### Visual Studio Code

If you are using VSCode, here are the settings to activate on save,

- `black` and `isort` to format.
- `mypy` to lint.
- Install [charliermarsh.ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension to lint (`ruff` is a fast equivalent to `flake8`)

```json
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.formatting.provider": "black",
"python.linting.mypyEnabled": true
}
```

## Testing

To test the code use [pytest](https://docs.pytest.org/en/7.1.x/).

```bash
pytest
```

To do the full coverage of `PyMap3d`, you must combine the coverage of the tests with,

- Vanilla Python
- NumPy installed
- Full dependencies installed

Here is how to do it with a newly created environment,

```bash
pip install -e .[tests]
pytest --cov=src --cov-report=html
pip install numpy
pytest --cov=src --cov-report=html --cov-append
pip install -e .[full]
pytest --cov=src --cov-report=html --cov-append
```

## Committing

After doing `git commit`, `pre-commit` will check the committed code.
The check can be passed, skipped or failed.
If the check failed, it is possible it auto-fixed the code, so you will only need to stage and commit again for it to pass.
If it did not auto-fixed the code, you will need to do it manually.
`pre-commit` will only check the code that is staged, the unstaged code will be stashed during the checks.
Loading