Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: initial python project structure #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# [Pull request title here]

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:

- Firmware version:
- Hardware:
- Toolchain:
- SDK:

## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: CI

on:
push:
pull_request:
branches: main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
megalinter:
name: Run linters
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: MegaLinter
id: ml
uses: oxsecurity/megalinter@v7
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

project_checks:
name: Run project checks
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Run checks
run: make lint

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false
steps:
- name: Check out
uses: actions/checkout@v3

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

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Run tests
run: make test
29 changes: 0 additions & 29 deletions .github/workflows/linters.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
*reports/

# Translations
*.mo
Expand Down Expand Up @@ -157,4 +158,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
8 changes: 8 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

ENABLE_LINTERS:
- REPOSITORY_GITLEAKS
- REPOSITORY_KICS
- BASH_SHELLCHECK
- ACTION_ACTIONLINT
- MARKDOWN_MARKDOWNLINT
- MAKEFILE_CHECKMAKE
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PYMODULE := trestlebot
TESTS := tests

all: develop lint test
.PHONY: all

develop:
@poetry install
@poetry shell
.PHONY: develop

lint:
@poetry lock --check
@poetry run isort --profile=black --lines-after-imports=2 \
--check-only $(TESTS) $(PYMODULE)
@poetry run black --check $(TESTS) $(PYMODULE) --diff
@poetry run mypy $(PYMODULE) $(TESTS)
@poetry run flake8
.PHONY: lint

test:
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml
.PHONY: test

build: clean-build
@poetry build
.PHONY: build

clean-build:
@rm -rf dist
.PHONY: clean-build

clean:
@git clean -Xdf
.PHONY: clean

publish:
@poetry config pypi-token.pypi $(PYPI_TOKEN)
@poetry publish --dry-run
@poetry publish
.PHONY: publish

build-and-publish: build publish
.PHONY: build-and-publish
Loading