Skip to content
Snippets Groups Projects
Commit ea736249 authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

update the CI to hopefully improve readability for new users

parent d4d8d955
No related branches found
No related tags found
No related merge requests found
Pipeline #12067 failed with stages
in 3 minutes and 26 seconds
default: default:
image: python:3.12-slim image: python:3.12-slim
.install_dependencies: workflow:
before_script: rules:
- pip install --upgrade pip - if: '$CI_PIPELINE_SOURCE == "web"'
- pip install setuptools wheel build twine - if: '$CI_COMMIT_BRANCH == "main"'
variables:
PACKAGE_NAME: "pak"
REPO_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi"
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip"
PIP_INDEX_URL: "https://__token__:${CI_JOB_TOKEN}@gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi/simple"
PIP_EXTRA_INDEX_URL: "https://pypi.org/simple"
stages: stages:
- build - build
- test - test
- publish - publish
variables:
PACKAGE_NAME: "pak"
build_package: build_package:
stage: build stage: build
extends: .install_dependencies
script: script:
- pip install --upgrade pip
- pip install setuptools wheel build
- python -m build - python -m build
artifacts: artifacts:
paths: paths:
- dist/* - dist/*
cache:
paths:
- ${PIP_CACHE_DIR}
test_package: test_package:
stage: test stage: test
script: script:
- pip install . # Install the package - pip install .
- pip install pytest - pip install pytest
- pytest # Run tests - pytest
publish_pip: publish_pip:
stage: publish stage: publish
extends: .install_dependencies
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PIP_INDEX_URL: "https://__token__:${CI_JOB_TOKEN}@gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/pypi/simple"
PIP_EXTRA_INDEX_URL: "https://pypi.org/simple"
script: script:
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* - pip install twine
- twine upload -u gitlab-ci-token -p ${CI_JOB_TOKEN} --repository-url ${REPO_URL} dist/*
build_and_push_docker_image: build_and_push_docker_image:
stage: publish stage: publish
image: docker:26.0.1 image: docker:latest
services: services:
- docker:26.0.1-dind - docker:dind
variables: variables:
DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE/$PACKAGE_NAME:$CI_COMMIT_REF_SLUG DOCKER_IMAGE_NAME: ${CI_REGISTRY_IMAGE}/${PACKAGE_NAME}
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin ${CI_REGISTRY}
script: script:
- docker build --pull -t "$DOCKER_IMAGE_NAME" . - echo "Building docker image and tagging as latest"
- docker push "$DOCKER_IMAGE_NAME" - docker pull ${DOCKER_IMAGE_NAME}:latest || true
- | - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${DOCKER_IMAGE_NAME}:latest -t ${DOCKER_IMAGE_NAME}:latest .
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - docker push ${DOCKER_IMAGE_NAME}:latest
docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest"
docker push "$CI_REGISTRY_IMAGE:latest"
fi
only:
- main # Only run on the main branch
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