Commit 1bb2611c authored by Bhavani's avatar Bhavani
Browse files

cicd testing

parent 8fe9f434
Pipeline #12139 canceled with stages
stages:
- lint
- test
- build
- deploy
variables:
PYTHONPATH: "${CI_PROJECT_DIR}"
DOCKERHUB_REPO: "uttamsb007/discord-bot"
###########################
# 1. LINT STAGE
###########################
lint:
stage: lint
image: python:3.10
script:
- pip install flake8
- echo "Running linting..."
- flake8 .
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
###########################
# 2. TEST STAGE
###########################
test:
stage: test
image: python:3.10
script:
- pip install pytest
- pytest || echo "No tests found, skipping."
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
###########################
# 3. BUILD DOCKER IMAGE
###########################
build:
stage: build
image: docker:24.0.9
tags: ["ubuntu", "vm"]
script:
- echo "Building Docker image..."
- docker build -t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
###########################
# 4. DEPLOY (PUSH TO DOCKERHUB)
###########################
deploy:
stage: deploy
image: docker:24.0.9
tags: ["ubuntu", "vm"]
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "Pushing to DockerHub..."
- docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
# If main branch, also push "latest"
- if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest;
docker push $DOCKERHUB_REPO:latest;
fi
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment