Skip to content
Snippets Groups Projects
Commit c5b8d367 authored by Robert Rosca's avatar Robert Rosca
Browse files

Update CI to work with pre-commit

Check stage tries to find the commit hash being merged into

Uses that hash to get  a list of changed files

Passes this list of files to pre-commit so that checks only run on
modified files
parent 233b8f7e
No related branches found
No related tags found
2 merge requests!433Fix/pre commit whitespace,!417Feat/pre commit checks
isort:
stage: test
stages:
- check
- test
checks:
stage: check
only: [merge_requests]
script:
- python3 -m pip install --user isort==5.6.4
- isort --diff **/*.py && isort -c **/*.py
- export PATH=/home/gitlab-runner/.local/bin:$PATH
- export CI_MERGE_REQUEST_TARGET_BRANCH_SHA=$(git ls-remote origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | cut -d$'\t' -f1)
- export FILES=$(git diff $CI_COMMIT_SHA $CI_MERGE_REQUEST_TARGET_BRANCH_SHA --name-only | tr '\n' ' ')
- echo "Running pre-commit on diff from $CI_COMMIT_SHA to $CI_MERGE_REQUEST_TARGET_BRANCH_SHA ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME)"
- python3 -m pip install --user -r requirements.txt
- echo $FILES | xargs pre-commit run --color=always --files
pytest:
stage: test
only: [merge_requests]
script:
- python3 -m pip install --user -r requirements.txt
- python3 -m pip install --user pytest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment