Commit c213bdb3 authored by Gadhave's avatar Gadhave
Browse files

Optimize .gitlab-ci.yml file test

parent def9d6fa
Pipeline #12120 passed with stage
in 9 seconds
......@@ -30,6 +30,10 @@ lint:
stage: lint
image: python:3.10
extends: .build_template
cache:
key: "pip-cache"
paths:
- .cache/pip
before_script :
- pip install flake8
script:
......@@ -37,62 +41,6 @@ lint:
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- echo "Done running the Python Lint stage"
test:
stage: test
image: python:3.10
extends: .build_template
before_script:
- pip install pytest
- echo "Running Tests"
- echo "PYTHONPATH:" ${PYTHONPATH}
- echo "PWD=$(pwd)"
script:
- echo "Running PyTests"
after_script:
- echo "Tests completed succesfully"
diag:
stage: diag
image: docker:24.0.9
tags: ["windows","docker","ws12"]
script:
- echo "Check socket:"
- ls -l /var/run || true
- stat /var/run/docker.sock || true
- echo "Docker info:"
- docker version || true
- docker info || true
build:
stage: build
image: docker:24.0.9
extends: .build_template
before_script:
- echo "Building Docker image for commit:" ${CI_COMMIT_SHORT_SHA}
- echo "Logging in to Docker registry..."
- echo "Docker Registry :" ${DOCKER_REGISTRY}
- echo "Docker Username :" ${DOCKER_USERNAME}
- echo "Docker Passowrd :" ${DOCKER_PASSWORD}
script:
- echo "Building image..."
- cd Desktop/Telegram_Bot
- docker build -t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
after_script:
- echo "Docker image pushed successfully!"
deploy:
stage: deploy
image: docker:24.0.9
tags: ["windows","docker","ws12"]
script:
- echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "Logged into dockerhub succesfully!!"
- docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
- echo "Pushed the docker image to dockerhub succesfully!"
- 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
\ No newline at end of file
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH
\ No newline at end of file
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