Commit c3a351c3 authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

ci: add GitLab CI pipeline with lint, test, and docs stages

- Replace commented-out CI with full pipeline: secret-scan, yamllint,
  ansible-lint, syntax-check, python-smoke, docs, pages
- Add .yamllint with ansible-lint-compatible rules
- Update .ansible-lint with exclude_paths for local artifacts
- Add .gitignore entries for local inventory files and cache dirs
- Remove trailing whitespace across tracked YAML files
- Fix truthy values (yes/no -> true/false) in kubernetes.core.k8s
- Remove excess blank lines in kind-cluster tasks
- Pin docs requirements to mkdocs-material==9.6.14
parent b421403d
Loading
Loading
Loading
Loading
+10 −1
Changes for .ansible-lint: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
profile: min
exclude_paths:
  - .cache/
  - .git/
  - .gitlab-ci-local/
  - .mypy_cache/
  - .venv/
  - ansible/secrets.yml
  - ansible/venv/
  - public/
  - venv/
skip_list:
  - var-naming
  - yaml[line-length]
  - run-once[task]
  - no-handler
+3 −0
Changes for .gitignore: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ ansible/.ansible/
*.retry
ansible_facts/
ansible/secrets.yml
ansible/inventory/*.local.yml

# Automation folder - contains kubeconfig files generated by ansible
automation/
@@ -34,6 +35,8 @@ Thumbs.db

# Temporary files
/tmp/
.cache/
.mypy_cache/
*.tmp
*.log

+73 −19
Changes for .gitlab-ci.yml: 73 added lines, 19 removed lines.
Original line number Diff line number Diff line
image: python:3.9-alpine
image: python:3.12-slim

stages:
#   - lint
  - lint
  - test
  - docs
  - deploy

# ansible-lint:
#   stage: lint
#   image: python:3.9
#   script:
#     - pip install ansible-lint
#     - cd ansible
#     - chmod 700 .
#     - 'echo "profile: min" > .ansible-lint'
#     - 'echo "skip_list:" >> .ansible-lint'
#     - 'echo "  - var-naming" >> .ansible-lint'
#     - 'echo "  - yaml[line-length]" >> .ansible-lint'
#     - 'echo "  - run-once[task]" >> .ansible-lint'
#     - 'echo "  - no-handler" >> .ansible-lint'
#     - ansible-galaxy collection install -r requirements.yml --ignore-certs
#     - ansible-lint playbooks/ roles/
variables:
  ANSIBLE_CONFIG: ansible/ansible.cfg
  ANSIBLE_FORCE_COLOR: "true"
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

cache:
  paths:
    - .cache/pip

.ansible_setup:
  before_script:
    - python --version
    - python -m pip install --upgrade pip
    - python -m pip install -r ansible/requirements.txt
    - ansible-galaxy collection install -r ansible/requirements.yml

secret-scan:
  stage: lint
  image: alpine/git:2.49.0
  script:
    - |
      if git grep -nE 'g[l]pat-|g[h]p_|github_[p]at_' -- . ':!ansible/secrets.example.yml'; then
        exit 1
      fi
      begin_marker='-----BEGIN '
      key_marker='PRIVATE KEY'
      if git grep -n -e "$begin_marker" -- . ':!ansible/secrets.example.yml' | grep -E "$key_marker"; then
        exit 1
      fi

yamllint:
  stage: lint
  extends: .ansible_setup
  script:
    - yamllint .

ansible-lint:
  stage: lint
  extends: .ansible_setup
  script:
    - ansible-lint -c .ansible-lint ansible/playbooks ansible/roles ansible/role-template

syntax-check:
  stage: test
  extends: .ansible_setup
  script:
    - cd ansible
    - ansible-playbook -i inventory/hosts.yml --syntax-check playbooks/scenarios/full_oop/deploy-kubernetes.yml
    - ansible-playbook -i inventory/hosts.yml --syntax-check playbooks/scenarios/dual_oop/deploy-kubernetes.yml
    - ansible-playbook -i inventory/hosts.yml --syntax-check playbooks/scenarios/full_oop_existing_cluster/deploy.yml

python-smoke:
  stage: test
  script:
    - python -m py_compile docker-local-deployment/prepare_kubeconfig.py

docs:
  stage: docs
  script:
    - python -m pip install --upgrade pip
    - python -m pip install -r docs/requirements.txt
    - python -m mkdocs build --strict
  artifacts:
    paths:
      - public
    expire_in: 1 week

pages:
  stage: deploy
  script:
    - pip install -r docs/requirements.txt
    - python -m mkdocs build
    - python -m pip install --upgrade pip
    - python -m pip install -r docs/requirements.txt
    - python -m mkdocs build --strict
  artifacts:
    paths:
      - public

.yamllint

0 → 100644
+27 −0
Changes for .yamllint: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
---
extends: default

ignore: |
  .cache/
  .git/
  .gitlab-ci-local/
  .mypy_cache/
  .venv/
  ansible/secrets.yml
  ansible/venv/
  public/
  venv/

rules:
  braces:
    max-spaces-inside: 1
  comments:
    min-spaces-from-content: 1
  comments-indentation: disable
  document-start: disable
  line-length: disable
  octal-values:
    forbid-implicit-octal: true
    forbid-explicit-octal: true
  truthy:
    allowed-values: ["true", "false"]
+0 −2
Changes for ansible/roles/kind-cluster/tasks/cluster.yml: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -80,8 +80,6 @@
    cluster_exists: false
  when: cluster_deleted.changed or cluster_deleted_prompt.changed



- name: Set config directory for remote deployment
  ansible.builtin.set_fact:
    kubeconfig_dir: "/home/{{ ansible_user }}/kind-cluster-config"
Loading