Merge pull request #2 from corvus-migratorius/ci

CI
This commit is contained in:
Alexander Gorelyshev
2025-12-05 12:02:21 +04:00
committed by GitHub
14 changed files with 118 additions and 6 deletions

9
.ansible-lint Normal file
View File

@@ -0,0 +1,9 @@
---
profile: production
strict: true
# Enable checking of loop variable prefixes in roles
loop_var_prefix: "^(__|{role}_)"
exclude_paths:
- .github/

22
.github/workflows/kics.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
---
name: kics
on:
pull_request:
branches: ["master"]
jobs:
kics:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
name: Check out source code
- name: run a KICS scan
uses: checkmarx/kics-github-action@e01759d524f8abd5bd650d3d5bd4b96d46ebbc1d
with:
path: .
token: ${{ secrets.GITHUB_TOKEN }}
output_path: myResults/

46
.github/workflows/linters.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
---
name: linters
on:
pull_request:
branches: [ "master" ]
push:
branches: [ "master" ]
jobs:
ansible-lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: mamba-org/setup-micromamba@7f29b8b80078b1b601dfa018b0f7425c587c63bb
with:
micromamba-version: '2.4.0-0'
environment-file: ci/conda.yml
init-shell: bash
post-cleanup: 'all'
cache-environment: true
# - name: "Install role dependencies"
# run: ansible-galaxy install -r requirements.yml
# shell: micromamba-shell {0}
- name: Check workflow files themselves with ActionLint
run: actionlint
shell: micromamba-shell {0}
- name: Check environment files with YAMLLint
run: yamllint ci/*.yml
shell: micromamba-shell {0}
- name: "Install collection dependencies"
run: ansible-galaxy install -r requirements.yml
shell: micromamba-shell {0}
- name: Run ansible-lint
run: ansible-lint -c .ansible-lint
shell: micromamba-shell {0}

3
CHANGELOG.md Normal file
View File

@@ -0,0 +1,3 @@
# Changelog
All notable changes to this project will be documented in this file.

View File

@@ -1,5 +1,8 @@
# Ansible Collection - genlab.common
[![linters](https://github.com/corvus-migratorius/genlab.common/actions/workflows/linters.yml/badge.svg)](https://github.com/corvus-migratorius/genlab.common/actions/workflows/linters.yml)
[![kics](https://github.com/corvus-migratorius/genlab.common/actions/workflows/kics.yml/badge.svg)](https://github.com/corvus-migratorius/genlab.common/actions/workflows/kics.yml)
## Roles
- [mount_device](roles/mount_device/README.md)

11
ci/conda.yml Normal file
View File

@@ -0,0 +1,11 @@
---
name: genlab.common
channels:
- conda-forge
dependencies:
- python~=3.13.10
- pip==25.3
- actionlint
- pip:
- -r requirements.txt
- -r requirements.ci.txt

6
ci/requirements.ci.txt Normal file
View File

@@ -0,0 +1,6 @@
ansible-lint
molecule==24.12.0
molecule-plugins[docker]
docker~=7.1.0
requests==2.31.0 # pinned to the latest version not breaking Docker SDK
yamllint

1
ci/requirements.txt Normal file
View File

@@ -0,0 +1 @@
ansible-core==2.18.11

View File

@@ -9,6 +9,8 @@ description: >-
The genlab.common collection includes roles for performing deploying and configuring common infrastructural components
license_file: LICENSE
tags:
- linux
- infrastructure
- genlab
repository: https://github.com/corvus-migratorius/genlab.common
issues: https://github.com/corvus-migratorius/genlab.common/issues

6
renovate.json Normal file
View File

@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}

3
requirements.yml Normal file
View File

@@ -0,0 +1,3 @@
---
collections:
- name: ansible.posix

View File

@@ -10,7 +10,7 @@ galaxy_info:
platforms:
- name: "Ubuntu"
versions: [ "focal", "jammy", "noble" ]
versions: ["jammy", "noble"]
galaxy_tags: []

View File

@@ -5,19 +5,19 @@
pre_tasks:
- name: "Check if the disk file already exists"
register: mount_device_disk_file
ansible.builtin.stat:
path: /tmp/test_file
register: disk_file
- name: "Create a file to act as a disk if it doesn't exist"
when: not disk_file.stat.exists
when: not mount_device_disk_file.stat.exists
changed_when: false
ansible.builtin.shell: |
dd if=/dev/zero of=/tmp/test_file bs=1000000 count=100
mkfs.ext3 /tmp/test_file
roles:
- role: genlab.mount_device
- role: genlab.common.mount_device
devices:
- what: "/tmp/test_file"
where: "/test_mount"

View File

@@ -7,12 +7,12 @@
tasks:
- name: "Check mountpoint" # noqa: command-instead-of-module
changed_when: false
register: mounts
register: mount_device_mounts
ansible.builtin.command:
cmd: mount -l
- name: "Ensure test_file is mounted on test_mount"
ansible.builtin.assert:
that: "'/tmp/test_file on /test_mount type ext3' in mounts.stdout"
that: "'/tmp/test_file on /test_mount type ext3' in mount_device_mounts.stdout"
success_msg: "/test_mount is a mounted"
fail_msg: "/test_mount is not on the list of mounts"