diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 392335bd..3feb7fec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Pre-commit Checks + run: | + pip -q install pre-commit + pre-commit run --all-files - name: Start from clean state run: make clean - name: Run tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..339017a6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-json + - id: pretty-format-json + args: + - --autofix + - --indent=4 + - --no-ensure-ascii + - --no-sort-keys diff --git a/README.md b/README.md index bca30db0..28337eb2 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,17 @@ Mapping notes & respective JSON-LD output: - [Raw Data](examples/illustrations/raw_data/raw_data.json) - [Reconstructed File](examples/illustrations/reconstructed_file/reconstructed_file.json) (*[info](examples/illustrations/reconstructed_file/)*) - [SMS and Contacts](examples/illustrations/sms_and_contacts/sms_and_contacts.json) + + +This project uses [the `pre-commit` tool](https://pre-commit.com/) for linting the JSON files and ensuring consistent formatting. It can be installed with `pip`: +```bash +pip install pre-commit +pre-commit --version +``` + +The `pre-commit` tool hooks into Git's commit machinery to run a set of linters and static analyzers over each change. To install `pre-commit` into Git's hooks, run: +```bash +pre-commit install +``` + +To uninstall `pre-commit`, run either `pre-commit uninstall` or `rm .git/hooks/pre-commit`. \ No newline at end of file