Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CICD Example
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RC Data Science
community-containers
CICD Example
Commits
ea736249
Commit
ea736249
authored
6 months ago
by
Matthew K Defenderfer
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+28
-30
28 additions, 30 deletions
.gitlab-ci.yml
with
28 additions
and
30 deletions
.gitlab-ci.yml
+
28
−
30
View file @
ea736249
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment