Skip to content
Snippets Groups Projects

Draft: Add pre-commit hook and improve with better linting

Closed Hannes Feldt requested to merge add-pre-commit-improve-tox-setup into main
2 files
+ 159
49
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 37
49
include:
- local: "{{cookiecutter.project_slug}}/.gitlab-ci.yml"
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- prepare
- build
- test
trigger_prepare:
stage: prepare
@@ -10,53 +9,42 @@ trigger_prepare:
strategy: depend
include: "{{cookiecutter.project_slug}}/.prepare.gitlab-ci.yml"
default:
# Generate template instance in my_awesome_app directory
build-template:
stage: build
image: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG
# Bootstrap Cookiecutter template to test provided ci pipeline template
before_script:
script:
- python --version # For debugging
- git config --global user.name "unit test"
- git config --global user.email "info@astron.nl"
- cookiecutter --no-input --overwrite-if-exists --output-dir . .
- cd my_awesome_app
# Override semgrep-sast before script
sast:
before_script:
- python --version # For debugging
# Override unit test before script
.run_unit_test_version_base:
before_script:
- pip install cookiecutter
- !reference [default, before_script]
- python --version # For debugging
- python -m pip install --upgrade pip
- pip install --upgrade tox twine
# Override artifact directories
package_docs:
stage: package
artifacts:
expire_in: 1w
paths:
- my_awesome_app/docs/build/*
# override package files before script
package_files:
before_script:
- pip install cookiecutter
- !reference [default, before_script]
- git init
- git config user.email "ci-runner@example.com"
- git config user.name "CI Runner"
- source ./setup.sh
- ls -lah
- tox --version
- pip install --upgrade tox
- tox -e fix
- rm -r .venv
- rm -r .tox
# cannot use needs, for artifacts on child pipeline so must regenerate template!
artifacts:
expire_in: 1w
paths:
- my_awesome_app/dist/*
# Override artifact directories
run_unit_tests_coverage:
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: my_awesome_app/coverage.xml
paths:
- my_awesome_app/htmlcov/*
- my_awesome_app/*
- project.gitlab-ci.yml
# Spawn pipeline using the gitlab-ci.yml from generated template instance
# use project.gitlab.ci.yml for necessary job overrides from this template instance
# (due to changes in directories and paths etc)
project-pipeline:
stage: test
trigger:
strategy: depend
include:
- artifact: my_awesome_app/.gitlab-ci.yml
job: build-template
- artifact: project.gitlab-ci.yml
job: build-template
variables:
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
Loading