diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 687b779fc369965d8789ef9f3ebc1c56222cd1d0..e25f8e359cb5b95967aa9b55406320fcbc62690f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,21 @@ -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