Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
software-di-controllo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Davide Ricci
software-di-controllo
Commits
1a5b1094
Commit
1a5b1094
authored
2 months ago
by
Davide Ricci
Browse files
Options
Downloads
Patches
Plain Diff
Update .gitlab-ci.yml file
parent
fbd8a0ce
No related branches found
No related tags found
No related merge requests found
Pipeline
#29543
failed
2 months ago
Stage: validate
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+73
-130
73 additions, 130 deletions
.gitlab-ci.yml
with
73 additions
and
130 deletions
.gitlab-ci.yml
+
73
−
130
View file @
1a5b1094
...
@@ -5,175 +5,118 @@ image: python:3.12
...
@@ -5,175 +5,118 @@ image: python:3.12
variables
:
variables
:
PROJECT
:
"
noctua"
PROJECT
:
"
noctua"
PIP_CACHE_DIR
:
"
$CI_PROJECT_DIR/.cache/pip"
PIP_CACHE_DIR
:
"
$CI_PROJECT_DIR/.cache/pip"
FORMAT_TARGETS
:
"
${PROJECT}"
# For sed, autopep8, isort
FORMAT_TARGETS
:
"
${PROJECT}"
PYLINT_TARGETS
:
"
${PROJECT}"
# For pylint
PYLINT_TARGETS
:
"
${PROJECT}"
GIT_USER_EMAIL
:
"
davide.ricci@inaf.it"
GIT_USER_EMAIL
:
"
davide.ricci@inaf.it"
GIT_USER_NAME
:
"
Davide
GitLab
CI"
GIT_USER_NAME
:
"
Davide
GitLab
CI"
FORMATTED_BRANCH_NAME
:
"
validated"
FORMATTED_BRANCH_NAME
:
"
validated"
cache
:
cache
:
key
:
"
$CI_COMMIT_REF_SLUG"
# Cache pip downloads per branch
key
:
"
$CI_COMMIT_REF_SLUG"
paths
:
paths
:
-
.cache/pip
-
.cache/pip
# - venv/
stages
:
stages
:
-
setup_and_format
-
validate
# Combined setup, formatting, and linting
-
lint
# Does not modify code
-
deploy
-
deploy_docs
-
auto_commit
-
auto_commit
# Job 1: Install ${PROJECT} and its dependencies
# Job 1: Install dependencies, format code, and lint
install_project
:
# This single job is more efficient than the previous multi-job chain.
stage
:
setup_and_format
validate_code
:
stage
:
validate
tags
:
tags
:
-
git-run-ia2
-
git-run-ia2
script
:
before_script
:
-
echo "Current directory $(pwd)"
-
ls -la
-
echo "Python version $(python -v)"
-
pip install --upgrade pip
-
pip install --upgrade pip
-
echo "Installing project '${PROJECT}' and its dependencies..."
# Install all tools at once
-
pip install -e .
-
pip install ".[dev]"
# Assuming you have a pyproject.toml with dev dependencies like isort, autopep8, pylint
-
echo "${PROJECT} installation complete."
# Or install them manually:
artifacts
:
# - pip install -e .
paths
:
# - pip install isort autopep8 pylint
# Pass the entire workspace. This includes the checked-out code
# or if -e . modifies local files (e.g. .egg-info).
-
.
# The current working directory state
# Job 2: Remove Trailing Whitespaces
fix_trailing_whitespaces
:
stage
:
setup_and_format
tags
:
-
git-run-ia2
needs
:
-
job
:
install_project
artifacts
:
true
script
:
script
:
-
echo "Current directory $(pwd)"
# --- STEP 1: Format Code ---
-
ls -la
-
echo "Removing trailing whitespaces..."
-
echo "Removing trailing whitespaces from '${FORMAT_TARGETS}' directory..."
-
find "${FORMAT_TARGETS}" -type f -name "*.py" -exec sed -i 's/[[:space:]]*$//' {} \;
-
find "${FORMAT_TARGETS}" -type f -name "*.py" -exec sed -i 's/[[:space:]]*$//' {} \;
-
echo "Trailing whitespaces removed."
artifacts
:
paths
:
-
.
# Pass the modified workspace
# Job 3: Apply isort
-
echo "Applying isort..."
apply_isort
:
stage
:
setup_and_format
tags
:
-
git-run-ia2
needs
:
-
job
:
fix_trailing_whitespaces
artifacts
:
true
before_script
:
-
pip install isort
script
:
-
echo "Current directory $(pwd)"
-
ls -la
-
echo "Applying isort to '${FORMAT_TARGETS}' directory..."
# isort will use pyproject.toml for configuration
-
isort "${FORMAT_TARGETS}"
-
isort "${FORMAT_TARGETS}"
-
echo "isort formatting complete."
artifacts
:
paths
:
-
.
# Pass the modified workspace
# Job 4: Apply autopep8
-
echo "Applying autopep8..."
apply_autopep8
:
stage
:
setup_and_format
tags
:
-
git-run-ia2
needs
:
-
job
:
apply_isort
artifacts
:
true
before_script
:
-
pip install autopep8
script
:
-
echo "Current directory $(pwd)"
-
ls -la
-
echo "Applying autopep8 to '${FORMAT_TARGETS}' directory..."
-
autopep8 --in-place --recursive --aggressive --aggressive "${FORMAT_TARGETS}"
-
autopep8 --in-place --recursive --aggressive --aggressive "${FORMAT_TARGETS}"
-
echo "autopep8 formatting complete."
-
echo "Formatting complete."
artifacts
:
paths
:
-
.
# Pass the modified workspace
# Job 5: Run Pylint
# --- STEP 2: Lint the formatted code ---
run_pylint
:
-
echo "Running pylint..."
stage
:
lint
-
pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py
tags
:
-
git-run-ia2
needs
:
-
job
:
apply_autopep8
artifacts
:
true
before_script
:
-
pip install pylint
script
:
-
echo "Current directory $(pwd)"
-
echo "Running pylint on '${PYLINT_TARGETS}'..."
-
pylint --version
-
pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py || echo "Pylint finished with exit code $(( $? &2)) (non-zero indicates issues)"
-
echo "Pylint check complete."
-
echo "Pylint check complete."
#rules:
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# - when: manual
# allow_failure: true # Allow manual trigger to not fail overall pipeline if desired
artifacts
:
# Pass the formatted code to the commit job
paths
:
-
"
${PROJECT}/"
-
"
.pylintrc"
# And any other relevant files
# Job 6: Create documentation
# Job 2: Create and deploy documentation to GitLab Pages
# This defines a job named 'pages'. GitLab recognizes this special name
# and knows that its purpose is to deploy a website to GitLab Pages.
pages
:
pages
:
stage
:
deploy
_docs
stage
:
deploy
tags
:
tags
:
-
git-run-ia2
-
git-run-ia2
before_script
:
before_script
:
-
pip install --upgrade pip
-
pip install --upgrade pip
-
echo "
Install
ing
project
'${PROJECT}'
an
d
i
ts dependencies..."
#
Install project
so Sphinx c
an i
mport it
-
pip install -e .
-
pip install -e .
-
echo "${PROJECT} installation complete."
# Install doc dependencies
-
pip install -r docs/requirements.txt
-
pip install -r docs/requirements.txt
script
:
script
:
-
echo "
Current directory $(pwd)
"
-
echo "
Building documentation...
"
-
echo "Building docs..."
-
sphinx-apidoc -o docs/source ${PROJECT}
-
sphinx-apidoc -o docs/source noctua
# The final output directory MUST be named 'public' for GitLab Pages
-
sphinx-build -b html docs/source
docs/
public
/html
-
sphinx-build -b html docs/source public
artifacts
:
artifacts
:
paths
:
paths
:
-
public
-
public
rules
:
rules
:
# Only run on the default branch
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Job
7
:
c
ommit
in
branch
# Job
3
:
C
ommit
the formatted code to a new
branch
commit_formatted_code
:
commit_formatted_code
:
stage
:
auto_commit
stage
:
auto_commit
tags
:
tags
:
-
git-run-ia2
-
git-run-ia2
needs
:
needs
:
-
job
:
run_pylint
# Must pass pylint
-
job
:
validate_code
# Depends on the single validation job
-
job
:
apply_autopep8
# Needs the final code state from formatting
artifacts
:
true
artifacts
:
true
before_script
:
before_script
:
-
git config --global user.email "davide.ricci@inaf.it"
-
git config --global user.email "${GIT_USER_EMAIL}"
-
git config --global user.name "CI Bot"
-
git config --global user.name "${GIT_USER_NAME}"
-
git checkout "$CI_COMMIT_SHA"
script
:
script
:
-
echo "Checking for changes and committing to ${FORMATTED_BRANCH_NAME} branch..."
-
echo "Creating/updating branch '${FORMATTED_BRANCH_NAME}' with formatted code..."
# Create the new branch from the original commit
-
git checkout -B "${FORMATTED_BRANCH_NAME}"
# Add all the changes from the formatted code (which came from artifacts)
-
git add .
-
git add .
-
echo "Creating/updating branch '${FORMATTED_BRANCH_NAME}' based on commit $CI_COMMIT_SHA..."
-
git checkout -B "${FORMATTED_BRANCH_NAME}" "$CI_COMMIT_SHA"
# Check if there's anything to commit
-
MAIN_COMMIT_MSG=$(git log -1 --pretty=%B $CI_COMMIT_SHA)
-
|
-
|
git commit -m "$MAIN_COMMIT_MSG
if git diff --staged --quiet; then
- Source Commit: $CI_COMMIT_SHA
echo "No formatting changes to commit."
- Date: $(date +"%Y-%m-%d %H:%M:%S")
else
- Job ID: $CI_JOB_ID
echo "Committing formatting changes..."
- Pipeline ID: $CI_PIPELINE_ID
MAIN_COMMIT_MSG=$(git log -1 --pretty=%B $CI_COMMIT_SHA)
- [skip ci]"
git commit -m "style: Apply automatic formatting
-
git push --force https://davide.ricci:$GITLAB_TOKEN@www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo.git ${FORMATTED_BRANCH_NAME}
${MAIN_COMMIT_MSG}
---
CI Job: $CI_JOB_ID
Source Commit: $CI_COMMIT_SHA
[skip ci]"
# Push the new branch to the repository
git push --force "https://gitlab-ci-token:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${FORMATTED_BRANCH_NAME}"
fi
rules
:
# Only run this when pushing to a non-default branch, to avoid loops.
-
if
:
$CI_COMMIT_BRANCH != $CI_DEFAULT_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
sign in
to comment