Files
rss-proxy/.gitlab-ci.yml
2025-03-03 23:11:41 +03:00

68 lines
1.6 KiB
YAML
Executable File

stages:
- test
- build
- pre_push
- push
test:
stage: test
image: python:3.11-alpine
script:
- pip install -q -r requirements.txt
- python -m unittest discover tests
only:
changes:
- ^README.md
- ^CHANGELOG
- ^.gitattribute
- ^.gitignore
- ^.gitlab-ci.yml
- ^tests/
- proxy/**/*
- Dockerfile
- requirements.txt
build:
needs:
- test
stage: build
script:
- docker build -t $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_REF_SLUG .
- docker tag $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_REF_SLUG $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_SHORT_SHA
- docker tag $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_REF_SLUG $CI_REGISTRY/$CI_PROJECT_PATH:latest
pre_push:
needs:
- build
stage: pre_push
before_script:
- apk add --no-cache curl
script:
- echo "Running container to test image"
- docker run -d --rm --name test_container $CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_REF_SLUG
- CONTAINER_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' test_container)
- |
echo "Waiting for the application to start..."
sleep 10
if curl --fail http://$CONTAINER_IP:5050/health; then
echo "Healthcheck passed"
else
echo "Healthcheck failed, stopping push"
exit 1
fi
after_script:
- docker rm -f test_container
push:
needs:
- pre_push
stage: push
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
- docker push $CI_REGISTRY/$CI_PROJECT_PATH:latest