Skip to content
Merged

Ruff #280

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
42 changes: 42 additions & 0 deletions .commitlintrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export default {
extends: [
'@commitlint/config-conventional'
],
ignores: [
(message) => message.includes('Signed-off-by: dependabot[bot]')
],
rules: {
'header-max-length': [
2,
'always',
72
],
'body-max-line-length': [
2,
'always',
72
],
'body-leading-blank': [
2,
'always'
],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'deps',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test'
]
]
}
};
84 changes: 14 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,20 @@
name: Continuous Integration
name: CI
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
python: [ "3.10" , "3.11" ]
env:
DATABASE_URL: postgis://postgres:postgres@localhost/smbackend
SECRET_KEY: test-secret
services:
postgres:
image: postgis/postgis:13-3.3
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip

- name: Install required Ubuntu packages
run: |
sudo apt-get update && sudo apt-get install gdal-bin voikko-fi libvoikko-dev

- name: Create needed postgis extensions
run: |
psql -h localhost -U postgres template1 -c 'create extension hstore;create extension pg_trgm;'

- name: Install PyPI dependencies
run: |
python -m pip install --upgrade pip
pip install codecov -r requirements.txt -r requirements-dev.txt
workflow_dispatch:

- name: Run Python side code neatness tests
run: |
flake8
black --check .
isort . -c

- name: Run pytest code functionality tests
run: |
pytest -ra -vvv --cov=.

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

# Without this workaround Sonar reports a warning about an incorrect source path
- name: Override coverage report source path for Sonar
if: github.event_name == 'push'
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml

- name: SonarCloud Scan
if: github.event_name == 'push'
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
jobs:
common:
uses: City-of-Helsinki/.github/.github/workflows/ci-django-api.yml@main
secrets: inherit
with:
python-version: "3.10"
postgres-major-version: 13
use-postgis: true
extra-commands: |
sudo apt-get install voikko-fi libvoikko-dev
psql postgresql://test_user:test_password@localhost/template1 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'
psql postgresql://test_user:test_password@localhost/template1 -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;'
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Keep tool versions in sync with the versions in requirements-dev.txt
minimum_pre_commit_version: 2.13.0
default_install_hook_types: [pre-commit, commit-msg]
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6 # Sync with requirements-dev.in
hooks:
- id: ruff
name: ruff lint
- id: ruff-format
name: ruff format
args: [ --check ]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.13.0
hooks:
- id: commitlint
stages: [commit-msg, manual]
additional_dependencies: ["@commitlint/config-conventional"]
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
Loading
Loading