Verified Commit 32cce162 authored by Silvio Rhatto's avatar Silvio Rhatto
Browse files

Feat: CI: switch to AnCIble

parent b5fa2d97
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ exclude_paths:
  - .cache/ # implicit unless exclude_paths is defined in config
  - .gitlab-ci.yml
  - .molecule/roles
  - vendor
  - vendors

# Enable checking of loop variable prefixes in roles
loop_var_prefix: "^(__|{role}_)"
+1 −0
Original line number Diff line number Diff line
__pycache__
molecule/podman/roles
molecule/local/roles
vendor*
+8 −57
Original line number Diff line number Diff line
---
#
# GitLab CI for the Onionprobe Ansible role
# GitLab CI for Ansible roles
#
# Copyright (C) 2024 The Tor Project, Inc.
# SPDX-License-Identifier: AGPL-3.0-or-later
#

# Linting
lint:
  stage: test
# Variables
variables:
  ROLE: onionprobe

  image: debian:bookworm

  before_script:
    - apt-get update
    - apt install -y python3-pip ansible
    - python3 -m pip install ansible-lint --break-system-packages
    - ansible --version
    - ansible-lint --version
    - mkdir -p molecule/podman/roles && ln -s ../../.. molecule/podman/roles/onionprobe
    - mkdir -p molecule/local/roles  && ln -s ../../.. molecule/local/roles/onionprobe

  script:
    - ansible-lint

# Podman CI workflow
molecule_podman:
  stage: test

  image:
    name: containers.torproject.org/tpo/tpa/base-images/podman:bookworm
    docker:
      user: root

  before_script:
    - apt-get update
    - apt install -y sudo python3-pip ansible
    - python3 -m pip install molecule-plugins[podman] --break-system-packages
    - sudo -u podman python3 --version
    - sudo -u podman ansible --version
    - sudo -u podman molecule --version
    - sudo -u podman podman info
    - sudo -u podman mkdir -p molecule/podman/roles && sudo -u podman ln -s ../../.. molecule/podman/roles/onionprobe

  script:
    - sudo -u podman molecule test -s podman

# Run Ansible tests directly in the CI containers
#molecule_local:
#  stage: test
#
#  image: debian:bookworm
#
#  before_script:
#    - apt-get update
#    - apt install -y python3-pip ansible
#    - python3 -m pip install molecule --break-system-packages
#    - python3 --version
#    - ansible --version
#    - molecule --version
#    - mkdir -p molecule/podman/roles && ln -s ../../.. molecule/podman/roles/onionprobe
#
#  script:
#    - molecule test -s local
include:
  - project: tpo/onion-services/ansible/ancible
    file:
      - .gitlab-ci-base.yml
+24 −18
Original line number Diff line number Diff line
#
# Makefile for developing the Onionprobe Ansible Role
# Makefile for developing the Ansible Roles
#
# Copyright (C) 2024 The Tor Project, Inc.
# SPDX-License-Identifier: AGPL-3.0-or-later
#

# Parameters
SERVICE = onionprobe
# Role name
ROLE = onionprobe

# Provisioning
provision:
	@./scripts/provision
# Folder relative to this Makefile pointing to where the AnCIble is
# installed.
#
# Customize to your needs in your main Makefile. Examples:
#
# ANCIBLE_PATH = vendor/ancible
# ANCIBLE_PATH = vendors/ancible
ANCIBLE_PATH ?= vendors/ancible

# Linting
lint:
	@ansible-lint
# The AnCIble repository URL
ANCIBLE_REPO = https://gitlab.torproject.org/tpo/onion-services/ansible/ancible.git

# Podman tests
test-podman:
	@molecule test -s podman
# Include the AnCIble Makefile
# See https://www.gnu.org/software/make/manual/html_node/Include.html
-include $(ANCIBLE_PATH)/Makefile.ancible

# Local tests
test-local:
	@molecule test -s local
	@echo Waiting for the service to boostrap before checking it...
	@sleep 30
	@sudo service $(SERVICE) status
# This is useful when developing your documentation locally and AnCIble is
# not yet installed on your project but you don't want it to be a Git submodule.
#
# If you use this approach, make sure to at the AnCIble path into your
# .gitignore.
vendoring:
	@test   -e $(ANCIBLE_PATH) && git -C $(ANCIBLE_PATH) pull || true
	@test ! -e $(ANCIBLE_PATH) && git clone $(ANCIBLE_REPO) $(ANCIBLE_PATH) || true
+12 −0
Original line number Diff line number Diff line
@@ -30,6 +30,18 @@ platforms:
    # A command that keeps the container running
    command: ${MOLECULE_DOCKER_COMMAND:-"sleep infinity"}

    extra_opts:
      # May fix "Error: crun: sethostname: Operation not permitted: OCI permission denied"
      # https://github.com/containers/podman/issues/14284#issuecomment-1130113553
      #- --group-add=keep-groups

      # May fix "sethostname: Operation not permitted: OCI permission denied"
      # Details at https://github.com/containers/podman/discussions/25061
      #- --cap-add=SYS_ADMIN

      # Debug output
      - --log-level=debug

    # The Python Debian container images ships with multiple Python
    # executables.
    #
Loading