Skip to content

Commit

Permalink
refactor: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
daxartio committed Mar 27, 2024
1 parent 0b60d96 commit 102bdc5
Show file tree
Hide file tree
Showing 17 changed files with 1,515 additions and 1,531 deletions.
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Please explain the changes you made -->

<!--
Please, make sure:
- you have read the contributing guidelines:
https://github.com/sportorg/sportident/blob/master/CONTRIBUTING.md
-->
21 changes: 21 additions & 0 deletions .github/workflows/bumpversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Bump version

on:
# push:
# branches: [ master ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
push: true
github_token: ${{ secrets.GITHUB_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install python dependencies
run: make install-poetry install

- name: Run linters
run: make lint

test:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4

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

- name: Install python dependencies
run: make install-poetry install

- name: Run test
run: make test
17 changes: 17 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish to PYPI

on:
push:
tags:
- '*'
release:
types:
- created
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install poetry
run: make install-poetry

- name: Publish package to pypi
run: make publish
env:
pypi_username: ${{ secrets.PYPI_USERNAME }}
pypi_password: ${{ secrets.PYPI_PASSWORD }}
17 changes: 2 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -73,7 +72,6 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -84,9 +82,7 @@ profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down Expand Up @@ -132,14 +128,5 @@ dmypy.json
# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# static files generated from Django application using `collectstatic`
media
static

.vscode
.idea
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

This project adheres to the Python Code of Conduct, which can be found [here](https://www.python.org/psf/conduct/).
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Welcome! Happy to see you willing to make the project better.

## Getting started

### Install

**Activate virtual environment**

```
python -m venv .venv
```

**Install poetry**

```
make install-poetry
# pip install poetry
```

Don't forget to use last version of poetry!

**Install dependencies**

```
make install
```

### Run tests

```
make test
```

### Formatting

```
make format
```

### Lint

```
make lint
```

## Release

Automatically after merging with the master

1. `make bump`
2. `git push` and `git push --tags`

## Commit Message Format

This project adheres to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
A specification for adding human and machine readable meaning to commit messages.

### Commit Message Header

```
<type>(<scope>): <short summary>
│ │ │
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│ │
│ └─⫸ Commit Scope
└─⫸ Commit Type: feat|fix|build|ci|docs|perf|refactor|test|chore
```

#### Type

| type | name | description |
|----------|--------------------------|--------------------------------------------------------------------------------------------------------|
| feat | Features | A new feature |
| fix | Bug Fixes | A bug fix |
| docs | Documentation | Documentation only changes |
| style | Styles | Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
| refactor | Code Refactoring | A code change that neither fixes a bug nor adds a feature |
| perf | Performance Improvements | A code change that improves performance |
| test | Tests | Adding missing tests or correcting existing tests |
| build | Builds | Changes that affect the build system or external dependencies (example scopes: mypy, pip, pytest) |
| ci | Continuous Integrations | Changes to our CI configuration files and scripts (example scopes: Github Actions) |
| chore | Chores | Other changes that don't modify src or test files |
| revert | Reverts | Reverts a previous commit |
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

76 changes: 52 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
PYTHONPATH = PYTHONPATH=./
TEST = $(PYTHONPATH) pytest --verbosity=2 --showlocals --log-level=DEBUG --strict $(arg) -k "$(k)"
PYLINT_CODE = sportident.py test_sportident.py
CODE = $(PYLINT_CODE)
.DEFAULT_GOAL := help
CODE = sportident.py test_sportident.py
POETRY_RUN = poetry run
TEST = $(POETRY_RUN) pytest $(args)

.PHONY: test test-fast test-failed test-cov teamcity lint format check
.PHONY: help
help: ## Show help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

test:
$(TEST) --cov
.PHONY: all
all: format lint test ## Run formakt lint test

test-fast:
.PHONY: install-poetry
install-poetry: ## Install poetry
pip install poetry

.PHONY: install
install: ## Install dependencies
poetry install

.PHONY: install-docs
install-docs: ## Install docs dependencies
poetry install --only docs

.PHONY: publish
publish: ## Publish package
@poetry publish --build --no-interaction --username=$(pypi_username) --password=$(pypi_password)

.PHONY: test
test: ## Test with coverage
$(TEST) --cov=./

.PHONY: test-fast
test-fast: ## Test until error
$(TEST) --exitfirst

test-failed:
.PHONY: test-failed
test-failed: ## Test failed
$(TEST) --last-failed

test-cov:
.PHONY: test-report
test-report: ## Report testing
$(TEST) --cov --cov-report html
$(POETRY_RUN) python -m webbrowser 'htmlcov/index.html'

teamcity: export TEAMCITY_VERSION=1
teamcity: lint test
.PHONY: lint
lint: ## Check code
$(POETRY_RUN) black --check $(CODE)
$(POETRY_RUN) pytest --dead-fixtures --dup-fixtures
# $(POETRY_RUN) mypy $(CODE)

lint:
flake8 --jobs 4 --statistics --show-source $(CODE)
#pylint --jobs 4 --rcfile=setup.cfg $(PYLINT_CODE)
black --target-version py37 --skip-string-normalization --check $(CODE)
pytest --dead-fixtures --dup-fixtures
safety check --bare --full-report
.PHONY: format
format: ## Formatting code
$(POETRY_RUN) black $(CODE)

format:
autoflake --recursive --in-place --remove-all-unused-imports $(CODE)
isort --apply --recursive $(CODE)
black --target-version py37 --skip-string-normalization $(CODE)
unify --in-place --recursive $(CODE)
.PHONY: bump
bump: ## Bump version (commit and tag)
$(POETRY_RUN) cz bump

check: format lint test
.PHONY: clean
clean: ## Clean
rm -rf site || true
rm -rf dist || true
rm -rf htmlcov || true
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# SportIdent Reader

[![Build Status](https://api.travis-ci.org/sportorg/sireader.svg)](https://travis-ci.org/sportorg/sireader)
[![PyPI](https://img.shields.io/pypi/v/sportident)](https://pypi.org/project/sportident/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sportident)](https://www.python.org/downloads/)
[![GitHub last commit](https://img.shields.io/github/last-commit/sportorg/sportident)](https://github.com/sportorg/sireader)
[![GitHub stars](https://img.shields.io/github/stars/sportorg/sportident?style=social)](https://github.com/sportorg/sireader)

sportIdent.py is a python module to communicate with a SportIdent main station to read out SportIdent cards.
sportIdent.py is a python module to communicate with a SportIdent main station to read out SportIdent cards.
SportIdent is an electronic punching system mainly used for orienteering events.

## Installation

```
pip install sportident
```

## Usage

```python
from time import sleep
from sportident import SIReaderReadout
Expand All @@ -27,4 +38,12 @@ card_data = si.read_sicard()

# beep
si.ack_sicard()
```
```

## License

* [GNU LICENSE](LICENSE)

## Contribution

[Contribution guidelines for this project](CONTRIBUTING.md)
Loading

0 comments on commit 102bdc5

Please sign in to comment.