Skip to content

Commit

Permalink
Add CI and pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidg committed Nov 18, 2023
1 parent 9c30446 commit e3f3cdb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: tests

on:
push:
branches: [ main ]
paths:
- '**.py'
- '.github/workflows/tests.yml'
pull_request:
branches: [ main ]
paths:
- '**.py'
- '.github/workflows/tests.yml'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python3 -m pip install '.[test]'
- name: Lint with ruff
run: |
python -m pip install ruff
python -m ruff check .
- name: Test with unittest
run: |
python -m unittest
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formruatter.
- id: ruff-format
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ readme = "README.md"
classifiers = ["License :: OSI Approved :: MIT License"]

[project.optional-dependencies]
test = ["fastjsonschema==2.19.0"]
test = ["fastjsonschema==2.19.0", "coverage[toml]"]

[project.urls]
Home = "https://github.com/abhidg/infer-schema"

[project.scripts]
infer-schema = "infer_schema:main"

[tool.coverage.run]
omit = ["tests/*", "test_*"]
2 changes: 1 addition & 1 deletion test_infer_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def validate_csv(file: str, jsonschema_file: str, explicit_nulls: bool = False)
for row in reader:
try:
validate(
crow := casted_row(
casted_row(
row,
integer_columns,
numeric_columns,
Expand Down

0 comments on commit e3f3cdb

Please sign in to comment.