Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: separate workflow files #13

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 5 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,11 @@ name: CI

jobs:

lint:
name: Run linters
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

# we need '../' so the actual role can be tested, and '/tmp' is where dependencies will be installed
- name: Create ansible.cfg
run: >
printf '[defaults]\nroles_path=../:/tmp'
> roles/proxmox_lxc/ansible.cfg
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install test dependencies
run: pip install --upgrade ansible ansible-lint yamllint

- name: Install Galaxy requirements
run: |
cd roles/proxmox_lxc
ansible-galaxy role install -r tests/requirements.yml -p /tmp
ansible-galaxy collection install -r tests/requirements.yml -p /tmp
- name: Run yamllint
run: yamllint .

- name: Run ansible-lint
run: ansible-lint

- name: Test syntax
run: |
cd roles/proxmox_lxc
ansible-playbook tests/test.yml -i tests/inventory --syntax-check
test-role-proxmox-lxc:
name: Test proxmox_lxc role
uses: ./.github/workflows/test_role.yml
with:
ROLE_NAME: proxmox_lxc

ansible-test:
name: Run ansible-test
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/test_role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Test an Ansible role

"on":
workflow_call:
inputs:
ROLE_NAME:
type: string
required: true

jobs:
lint:
name: Run linters
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

# we need '../' so the actual role can be tested, and '/tmp' is where dependencies will be installed
- name: Create ansible.cfg
run: >
printf '[defaults]\nroles_path=../:/tmp'
> roles/${{ inputs.ROLE_NAME }}/ansible.cfg

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install test dependencies
run: pip install --upgrade ansible ansible-lint yamllint

- name: Install Galaxy requirements
run: |
cd roles/${{ inputs.ROLE_NAME }}
ansible-galaxy role install -r tests/requirements.yml -p /tmp
ansible-galaxy collection install -r tests/requirements.yml -p /tmp

- name: Run yamllint
run: yamllint .

- name: Run ansible-lint
run: ansible-lint

- name: Test syntax
run: |
cd roles/${{ inputs.ROLE_NAME }}
ansible-playbook tests/test.yml -i tests/inventory --syntax-check
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

4 changes: 1 addition & 3 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
antsibull := 'pipenv run antsibull-changelog'

_default:
@just --list

# updates version in galaxy.yml and creates changelog
release VERSION:
@sed -i -e 's/^version: .*$/version: {{VERSION}}/' galaxy.yml
@{{antsibull}} release
@antsibull-changelog release
alias r := release
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

1,097 changes: 0 additions & 1,097 deletions Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: bellackn
name: homelab
version: 5.0.0
version: 5.0.1
readme: README.md
authors:
- Nico Bellack <[email protected]>
Expand Down
Loading