Skip to content
Snippets Groups Projects
Commit a3565db3 authored by Corné Lukken's avatar Corné Lukken
Browse files

Document

parent 9af9706c
No related branches found
No related tags found
1 merge request!10Add pre commit improve tox setup
Pipeline #116047 failed
Pipeline: Python Binary Wheel Package

#116049

    Pipeline: Python Binary Wheel Package

    #116048

      # This dockerfile is used throughout steps of the CI/CD pipeline
      # It contains dependencies to execute the template and run tests
      FROM python:3.13 FROM python:3.13
      RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade pip
      RUN python -m pip install --upgrade cibuildwheel==2.23.0 cookiecutter tox twine RUN python -m pip install --upgrade cibuildwheel>=2.23.0 cookiecutter tox twine
      RUN curl -sSL https://get.docker.com/ | sh RUN curl -sSL https://get.docker.com/ | sh
      ...@@ -78,13 +78,13 @@ package_docs: ...@@ -78,13 +78,13 @@ package_docs:
      paths: paths:
      - my_awesome_app/docs/build/* - my_awesome_app/docs/build/*
      #docker_build: docker_build:
      # needs: needs:
      # - pipeline: $PARENT_PIPELINE_ID - pipeline: $PARENT_PIPELINE_ID
      # job: build-template job: build-template
      # - package_files - package_files
      # before_script: before_script:
      # - cd my_awesome_app - cd my_awesome_app
      run_integration_tests: run_integration_tests:
      needs: needs:
      ......
      ...@@ -2,8 +2,6 @@ default: ...@@ -2,8 +2,6 @@ default:
      image: image:
      name: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG name: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG
      pull_policy: always pull_policy: always
      before_script:
      - python --version # For debugging
      cache: cache:
      paths: paths:
      - .cache/pip - .cache/pip
      ...@@ -22,14 +20,13 @@ stages: ...@@ -22,14 +20,13 @@ stages:
      variables: variables:
      PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
      # Job templates from Gitlab that scan for security issues or leaked secrets
      include: include:
      - template: Security/SAST.gitlab-ci.yml - template: Security/SAST.gitlab-ci.yml
      - template: Security/Dependency-Scanning.gitlab-ci.yml - template: Security/Dependency-Scanning.gitlab-ci.yml
      - template: Security/Secret-Detection.gitlab-ci.yml - template: Security/Secret-Detection.gitlab-ci.yml
      # Prepare image to run ci on, image will be used in most jobs
      # Prepare image to run ci on
      trigger_prepare: trigger_prepare:
      stage: prepare stage: prepare
      trigger: trigger:
      ...@@ -48,16 +45,6 @@ sast: ...@@ -48,16 +45,6 @@ sast:
      pmd-apex, sobelow, spotbugs pmd-apex, sobelow, spotbugs
      stage: test stage: test
      dependency_scanning:
      # override default before_script, job won't have Python available
      before_script:
      - uname
      secret_detection:
      # override default before_script, job won't have Python available
      before_script:
      - uname
      # Basic setup for all Python versions for which we don't have a base image # Basic setup for all Python versions for which we don't have a base image
      .run_unit_test_version_base: .run_unit_test_version_base:
      before_script: before_script:
      ...@@ -66,6 +53,7 @@ secret_detection: ...@@ -66,6 +53,7 @@ secret_detection:
      - python -m pip install --upgrade tox twine - python -m pip install --upgrade tox twine
      # Run all unit tests for Python versions except the base image # Run all unit tests for Python versions except the base image
      # The base image is used for the highest Python version
      run_unit_tests: run_unit_tests:
      extends: .run_unit_test_version_base extends: .run_unit_test_version_base
      stage: test stage: test
      ...@@ -90,6 +78,8 @@ run_unit_tests_coverage: ...@@ -90,6 +78,8 @@ run_unit_tests_coverage:
      paths: paths:
      - htmlcov/* - htmlcov/*
      # Binary packages will be build for many architectures
      # using scikitbuild-core and cibuildwheel
      package_files: package_files:
      stage: package stage: package
      tags: tags:
      ...@@ -102,6 +92,7 @@ package_files: ...@@ -102,6 +92,7 @@ package_files:
      - source scripts/setup-docker-host.sh - source scripts/setup-docker-host.sh
      - tox -e build-ci-linux - tox -e build-ci-linux
      # Build the sphinx documentation
      package_docs: package_docs:
      stage: package stage: package
      artifacts: artifacts:
      ...@@ -111,6 +102,22 @@ package_docs: ...@@ -111,6 +102,22 @@ package_docs:
      script: script:
      - tox -e docs - tox -e docs
      # Build a tiny docker image that contains the minimal dependencies to run this project
      docker_build:
      stage: images
      image: docker:latest
      needs:
      - package_files
      tags:
      - dind
      before_script: []
      script:
      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
      - docker build -f docker/{{cookiecutter.project_slug}}/Dockerfile . --build-arg BUILD_ENV=copy --tag $CI_REGISTRY_IMAGE/{{cookiecutter.project_slug}}:$CI_COMMIT_REF_SLUG
      # enable this push line once you have configured docker registry cleanup policy
      # - docker push $CI_REGISTRY_IMAGE/{{cookiecutter.project_slug}}:$CI_COMMIT_REF_SLUG
      run_integration_tests: run_integration_tests:
      stage: integration stage: integration
      allow_failure: true allow_failure: true
      ...@@ -187,6 +194,7 @@ publish_to_readthedocs: ...@@ -187,6 +194,7 @@ publish_to_readthedocs:
      - echo "scp docs/* ???" - echo "scp docs/* ???"
      - exit 1 - exit 1
      # automatically create a release on Gitlab for every tagged commit
      release_job: release_job:
      stage: publish stage: publish
      image: registry.gitlab.com/gitlab-org/release-cli:latest image: registry.gitlab.com/gitlab-org/release-cli:latest
      ......
      # https://pre-commit.com/ # run several checks prior to creating a commit or pushing to a remote
      # These can be skipped (but you shouldn't generally as the pipeline will fail)
      # using `git push / commit --no-check`
      # for more information see: https://pre-commit.com/
      default_stages: [ pre-commit, pre-push ] default_stages: [ pre-commit, pre-push ]
      default_language_version: default_language_version:
      python: python3 python: python3
      ......
      ...@@ -38,5 +38,7 @@ To automatically apply most suggested linting changes execute: ...@@ -38,5 +38,7 @@ To automatically apply most suggested linting changes execute:
      ```tox -e format``` ```tox -e format```
      The configuration for linting and tox can be found in `pyproject.toml`
      ## License ## License
      This project is licensed under the Apache License Version 2.0 This project is licensed under the Apache License Version 2.0
      #!/bin/bash
      if [ ! -f "setup.sh" ]; then
      echo "pre-commit.sh must be executed with repository root as working directory!"
      exit 1
      fi
      pre-commit install --hook-type pre-push
      cibuildwheel==2.23.0 # BSD cibuildwheel>=2.23.0 # BSD
      tox >= 4.0 # ? tox >= 4.0 # ?
      build >= 0.8.0 # MIT build >= 0.8.0 # MIT
      # This dockerfile is used throughout steps of the CI/CD pipeline
      # It contains dependencies to run tests
      FROM python:3.13 FROM python:3.13
      RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade pip
      RUN python -m pip install --upgrade cibuildwheel==2.23.0 tox twine RUN python -m pip install --upgrade cibuildwheel>=2.23.0 tox twine
      RUN curl -sSL https://get.docker.com/ | sh RUN curl -sSL https://get.docker.com/ | sh
      # This dockerfile creates a minimal docker image that can run the project.
      # It can copy the result of `tox -e build` from the host to the container
      # or build from source inside the container.
      # Set `docker build --build-arg BUILD_ENV=copy` to copy from the host, rebuild otherwise
      # contrarily, to the ci image it does not contain any dependencies used for testing.
      ARG BUILD_ENV=no_copy ARG BUILD_ENV=no_copy
      # Build without copying from host inside docker # Build without copying from host inside docker
      FROM python:3.13 AS build_no_copy FROM python:3.13 AS build_no_copy
      ADD ../../requirements.txt . ADD ../../requirements.txt .
      COPY ../.. /work COPY ../.. /work
      RUN rm -r /work/dist | true RUN rm -rf /work/dist
      RUN python -m pip install --user tox RUN python -m pip install --user tox
      WORKDIR /work WORKDIR /work
      RUN python -m tox -e build RUN python -m tox -e build-local
      # Copy build package from host `dist` directory # Copy build package from host `dist` directory
      FROM python:3.13 AS build_copy FROM python:3.13 AS build_copy
      ......
      ...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
      """ """
      Remove generated source documentation files except for index.rst Remove generated source documentation files except for index.rst
      If a source file is created, documentation is generated and the source file is later
      removed. The documentation for this source file will persists.
      This file ensures generated source documentation files, which are automatically
      generated from source, are removed between every build.
      """ """
      import os import os
      ......
      ...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
      # SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
      # #
      # This file's directory is used to determine the station control directory # Substitute BASH_SOURCE if unset this is required for simple shells
      # location. We substitute BASH_SOURCE if it doesn't get set, this particularly # such as the one found in docker or alpine docker images.
      # happens when sourcing using the `docker` docker image due to its primitive # `#! /usr/bin/env bash` does not actually ensure the sourcing is executed
      # shell. # using BASH
      if [ -z ${BASH_SOURCE} ]; then if [ -z ${BASH_SOURCE} ]; then
      BASH_SOURCE=${(%):-%x} BASH_SOURCE=${(%):-%x}
      fi fi
      # From BASH_SOURCE determine the absolute path, this is needed because $0 is
      # unset when sourcing in some shells.
      ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE}))
      # Create a virtual environment directory if it doesn't exist # Create a virtual environment directory if it doesn't exist
      ...@@ -26,7 +28,7 @@ source "$VENV_DIR/bin/activate" ...@@ -26,7 +28,7 @@ source "$VENV_DIR/bin/activate"
      python -m pip install pre-commit python -m pip install pre-commit
      python -m pip install "tox>=4.21.0" python -m pip install "tox>=4.21.0"
      # Install git pre-commit pre-push hook # Install git pre-commit pre-push hook if not already installed
      if [ ! -f "${ABSOLUTE_PATH}/.git/hooks/pre-push.legacy" ]; then if [ ! -f "${ABSOLUTE_PATH}/.git/hooks/pre-push" ]; then
      source "${ABSOLUTE_PATH}/bin/install-hooks/pre-commit.sh" pre-commit install --hook-type pre-push
      fi fi
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment