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

Improve template documentation

parent b4305f1b
No related branches found
No related tags found
1 merge request!35Improve template documentation
Pipeline #116006 passed
Pipeline: Python Package

#116010

    Pipeline: Python Package

    #116007

      FROM python:3.12
      # 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
      RUN python -m pip install --upgrade pip
      RUN python -m pip install --upgrade cookiecutter tox twine
      ......@@ -2,8 +2,6 @@ default:
      image:
      name: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG
      pull_policy: always
      before_script:
      - python --version # For debugging
      cache:
      paths:
      - .cache/pip
      ......@@ -24,12 +22,13 @@ stages:
      variables:
      PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
      # Job templates from Gitlab that scan for security issues or leaked secrets
      include:
      - template: Security/SAST.gitlab-ci.yml
      - template: Security/Dependency-Scanning.gitlab-ci.yml
      - template: Security/Secret-Detection.gitlab-ci.yml
      # Prepare image to run ci on
      # Prepare image to run ci on, image will be used in most jobs
      trigger_prepare:
      stage: prepare
      trigger:
      ......@@ -53,16 +52,6 @@ sast:
      pmd-apex, security-code-scan, sobelow, spotbugs
      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
      .run_unit_test_version_base:
      before_script:
      ......@@ -71,6 +60,7 @@ secret_detection:
      - python -m pip install --upgrade tox twine
      # Run all unit tests for Python versions except the base image
      # The base image is used for the highest Python version
      run_unit_tests:
      extends: .run_unit_test_version_base
      stage: test
      ......@@ -95,6 +85,7 @@ run_unit_tests_coverage:
      paths:
      - htmlcov/*
      # Build and packge the project
      package_files:
      stage: package
      artifacts:
      ......@@ -104,6 +95,7 @@ package_files:
      script:
      - tox -e build
      # Build the sphinx documentation
      package_docs:
      stage: package
      artifacts:
      ......@@ -113,6 +105,7 @@ package_docs:
      script:
      - tox -e docs
      # Build a tiny docker image that contains the minimal dependencies to run this project
      docker_build:
      stage: images
      image: docker:latest
      ......@@ -203,6 +196,7 @@ publish_to_readthedocs:
      - echo "scp docs/* ???"
      - exit 1
      # automatically create a release on Gitlab for every tagged commit
      release_job:
      stage: publish
      image: registry.gitlab.com/gitlab-org/release-cli:latest
      ......
      # 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_language_version:
      python: python3
      ......
      ......@@ -57,5 +57,7 @@ To automatically apply most suggested linting changes execute:
      ```tox -e format```
      The configuration for linting and tox can be found in `pyproject.toml`
      ## License
      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
      # This dockerfile is used throughout steps of the CI/CD pipeline
      # It contains dependencies to run tests
      FROM python:3.13
      RUN python -m pip install --upgrade pip
      ......
      # 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
      # Build without copying from host inside docker
      FROM python:3.13 AS build_no_copy
      ADD ../../requirements.txt .
      COPY ../.. /work
      RUN rm -r /work/dist | true
      RUN rm -rf /work/dist
      RUN python -m pip install --user tox
      WORKDIR /work
      RUN python -m tox -e build
      # Copy build package from host `dist` directory
      FROM python:3.13 AS build_copy
      COPY dist /work/dist
      # Dynamically set `build` from `build_no_copy` or `build_copy` depending on
      # `BUILD_ENV` argument
      FROM build_${BUILD_ENV} AS build
      # Copy build stage files into final python slim image and install
      FROM python:3.13-slim
      COPY --from=build /work/dist /dist
      RUN python -m pip install /dist/*.whl
      ......@@ -3,6 +3,16 @@
      # Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
      # SPDX-License-Identifier: Apache-2.0
      """
      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
      file_dir = os.path.dirname(os.path.realpath(__file__))
      ......
      ......@@ -4,8 +4,10 @@
      # SPDX-License-Identifier: Apache-2.0
      #
      # This file's directory is used to determine the station control directory
      # location.
      # Substitute BASH_SOURCE if unset this is required for simple shells
      # such as the one found in docker or alpine docker images.
      # `#! /usr/bin/env bash` does not actually ensure the sourcing is executed
      # using BASH
      if [ -z ${BASH_SOURCE} ]; then
      BASH_SOURCE=${(%):-%x}
      fi
      ......@@ -24,7 +26,7 @@ source "$VENV_DIR/bin/activate"
      python -m pip install pre-commit
      python -m pip install "tox>=4.21.0"
      # Install git pre-commit pre-push hook
      if [ ! -f "${ABSOLUTE_PATH}/.git/hooks/pre-push.legacy" ]; then
      source "${ABSOLUTE_PATH}/bin/install-hooks/pre-commit.sh"
      # Install git pre-commit pre-push hook if not already installed
      if [ ! -f "${ABSOLUTE_PATH}/.git/hooks/pre-push" ]; then
      pre-commit install --hook-type pre-push
      fi
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment