Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
software-project-WS25
Reddit Team
Commits
14ce85cd
Commit
14ce85cd
authored
Nov 28, 2025
by
Benavides Ontiveros
Browse files
test code run
parent
4e820290
Pipeline
#12187
failed with stages
in 21 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
14ce85cd
...
@@ -15,11 +15,11 @@ variables:
...
@@ -15,11 +15,11 @@ variables:
# BASE JOB TEMPLATE
# BASE JOB TEMPLATE
# =====================================================================
# =====================================================================
.build_template
:
.build_template
:
tags
:
[
"
ubuntu"
,
"
vm"
]
# Must match your runner tags
tags
:
[
"
ubuntu"
,
"
vm"
]
image
:
docker:24.0.9
# Docker CLI available
image
:
docker:24.0.9
before_script
:
before_script
:
-
echo "Using host Docker daemon"
-
echo "Using host Docker daemon"
-
docker info ||
true
# check Docker access
-
docker info ||
true
# =====================================================================
# =====================================================================
# LINT
# LINT
...
@@ -31,10 +31,8 @@ lint:
...
@@ -31,10 +31,8 @@ lint:
before_script
:
before_script
:
-
pip install flake8
-
pip install flake8
script
:
|
script
:
|
echo "Linting Python code..."
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
echo "Done running the Python Lint stage"
rules
:
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
if
:
'
$CI_COMMIT_BRANCH'
-
if
:
'
$CI_COMMIT_BRANCH'
...
@@ -50,11 +48,7 @@ test:
...
@@ -50,11 +48,7 @@ test:
tags
:
[
"
ubuntu"
,
"
vm"
]
tags
:
[
"
ubuntu"
,
"
vm"
]
before_script
:
before_script
:
-
pip install pytest
-
pip install pytest
-
echo "Running Tests"
script
:
pytest -q || echo "No tests found"
script
:
|
pytest -q || echo "No tests found"
after_script
:
-
echo "Tests completed successfully"
rules
:
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
if
:
'
$CI_COMMIT_BRANCH'
-
if
:
'
$CI_COMMIT_BRANCH'
...
@@ -68,7 +62,6 @@ diag:
...
@@ -68,7 +62,6 @@ diag:
stage
:
diag
stage
:
diag
extends
:
.build_template
extends
:
.build_template
script
:
|
script
:
|
echo "Check Docker access:"
ls -l /var/run
ls -l /var/run
stat /var/run/docker.sock || true
stat /var/run/docker.sock || true
docker version || true
docker version || true
...
@@ -86,15 +79,29 @@ generate:
...
@@ -86,15 +79,29 @@ generate:
stage
:
generate
stage
:
generate
image
:
python:3.10
image
:
python:3.10
tags
:
[
"
ubuntu"
,
"
vm"
]
tags
:
[
"
ubuntu"
,
"
vm"
]
# 👇 Provide the same important environment variables as the Docker build
variables
:
REDDIT_CLIENT_ID
:
"
$REDDIT_CLIENT_ID"
REDDIT_CLIENT_SECRET
:
"
$REDDIT_CLIENT_SECRET"
SOME_OTHER_VAR
:
"
$SOME_OTHER_VAR"
# Add if needed
before_script
:
before_script
:
-
pip install -r requirements.txt
# optional: install dependencies
-
pip install -r requirements.txt
# If you need dependencies
script
:
-
mkdir -p generated
-
echo "Running Python script to generate files..."
-
mkdir -p generated
# ensure folder exists
script
:
|
-
python app.py
# replace with your script
echo "Running file-generation script with environment variables..."
echo "REDDIT_CLIENT_ID is: $REDDIT_CLIENT_ID"
echo "REDDIT_CLIENT_SECRET is: ${REDDIT_CLIENT_SECRET:0:4}****"
# Run your actual Python file generator
python generate_files.py
artifacts
:
artifacts
:
paths
:
paths
:
-
generated/
# folder with generated files
-
generated/
rules
:
rules
:
-
if
:
'
$CI_COMMIT_BRANCH'
-
if
:
'
$CI_COMMIT_BRANCH'
...
@@ -104,8 +111,8 @@ generate:
...
@@ -104,8 +111,8 @@ generate:
build
:
build
:
stage
:
build
stage
:
build
extends
:
.build_template
extends
:
.build_template
script
:
|
script
:
|
echo "Logging in to Docker registry..."
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Building Docker image for commit: ${CI_COMMIT_SHORT_SHA}"
echo "Building Docker image for commit: ${CI_COMMIT_SHORT_SHA}"
...
@@ -113,8 +120,10 @@ build:
...
@@ -113,8 +120,10 @@ build:
--build-arg REDDIT_CLIENT_ID="$REDDIT_CLIENT_ID" \
--build-arg REDDIT_CLIENT_ID="$REDDIT_CLIENT_ID" \
--build-arg REDDIT_CLIENT_SECRET="$REDDIT_CLIENT_SECRET" \
--build-arg REDDIT_CLIENT_SECRET="$REDDIT_CLIENT_SECRET" \
-t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
-t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
after_script
:
after_script
:
-
echo "Docker image built successfully!"
-
echo "Docker image built successfully!"
rules
:
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
when
:
never
when
:
never
...
@@ -129,26 +138,16 @@ deploy:
...
@@ -129,26 +138,16 @@ deploy:
stage
:
deploy
stage
:
deploy
extends
:
.build_template
extends
:
.build_template
script
:
|
script
:
|
echo "Logging in to Docker registry..."
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Verify login
docker info | grep Username || (echo "Docker login failed!" && exit 1)
docker info | grep Username || (echo "Docker login failed!" && exit 1)
echo "Listing local Docker images before push..."
docker images
echo "Pushing Docker image: $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA"
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
echo "Tagging image as latest..."
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
echo "Pushing latest tag..."
docker push $DOCKERHUB_REPO:latest
docker push $DOCKERHUB_REPO:latest
fi
fi
echo "Listing local Docker images after push..."
docker images
rules
:
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment