Skip to content

Commit

Permalink
Attempt to make this more consumable.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-de-bock committed Dec 18, 2023
1 parent 0eca30b commit a9ed516
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ jobs:
- role: ansible-role-preferences
- role: ansible-role-minimal
- role: ansible-role-version
- role: ansible-role-default
options:
- generate_gitignore: no

steps:
- name: checkout
uses: actions/checkout@v3
- run: |
pip install pre-commit
cd tests/${{ matrix.config.role }}
if [ ! -z "${{ matrix.config.options }}" ]; then
../../generate.yml
else
../../generate.yml --extra-vars '{ ${{ matrix.config.options | join(,) }} }'
fi
23 changes: 23 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,26 @@ sponsored_message: yes

# A custom message can be placed with this content.
custom_message: "Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles."

# The below settings determine what the generator will generate.
generate_gitignore: yes
generate_yamllint: yes
generate_pre_commit: yes
generate_readme: yes
generate_ansible_lint: yes
generate_tox: yes
generate_github_settings: yes
generate_license: yes
generate_security: yes
generate_molecule: yes
generate_contributing: yes
generate_github_action_molecule: yes
generate_github_action_galaxy: yes
generate_github_action_todo: yes
generate_gitlab_ci: yes
generate_requirements_txt: yes
generate_requirements2png: yes
generate_github_funding: yes
generate_github_issue_template: yes
generate_github_feature_template: yes
generate_install_pre_commit: yes
26 changes: 26 additions & 0 deletions generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
- name: Load generators defaults/main.yml
ansible.builtin.include_vars:
file: defaults/main.yml
when:
- generate_readme

- name: Load meta/main.yml
ansible.builtin.include_vars:
file: "{{ role_path }}/meta/main.yml"
name: meta
when:
- generate_readme or
generate_github_action_molecule or
generate_gitlab_ci

- name: Check meta/preferences.yml
ansible.builtin.stat:
Expand Down Expand Up @@ -64,29 +70,37 @@
ansible.builtin.slurp:
src: "{{ role_path }}/molecule/default/converge.yml"
register: example
when:
- generate_readme

- name: Check molecule/default/prepare.yml
ansible.builtin.stat:
path: "{{ role_path }}/molecule/default/prepare.yml"
register: check_prepare
when:
- generate_readme

- name: Load molecule/default/prepare.yml
ansible.builtin.slurp:
src: "{{ role_path }}/molecule/default/prepare.yml"
register: prepare
when:
- generate_readme
- check_prepare.stat.exists | bool

- name: Check molecule/default/verify.yml
ansible.builtin.stat:
path: "{{ role_path }}/molecule/default/verify.yml"
register: verify
when:
- generate_readme

- name: Load molecule/default/verify.yml
ansible.builtin.slurp:
src: "{{ role_path }}/molecule/default/verify.yml"
register: verifyyml
when:
- generate_readme
- verify.stat.exists | bool

- name: Load galaxy_id
Expand All @@ -95,6 +109,8 @@
register: galaxy_id
changed_when: no
failed_when: no
when:
- generate_readme

- name: Create .github directories
ansible.builtin.file:
Expand All @@ -105,6 +121,14 @@
- .github
- .github/workflows
- .github/ISSUE_TEMPLATE
when:
- generate_github_settings or
generate_github_action_molecule or
generate_github_action_galaxy or
generate_github_action_todo or
generate_github_funding or
generate_github_issue_template or
generate_github_feature_template

- name: Copy file
ansible.builtin.copy:
Expand Down Expand Up @@ -163,3 +187,5 @@
ansible.builtin.command:
cmd: pre-commit install
creates: .git/hooks/pre-commit
when:
- generate_pre_commit
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ A few roles to let CI try rendering files in different situations.
- `ansible-role-default` - A default role, as generated by the [skeleton](https://github.com/robertdebock/ansible-role-skeleton) template.
- `ansible-role-preferences` - Use `preferences.yml` to change behaviour.
- `ansible-role-minimal` - A role that has the minimum amount of files.
- `ansible-role-version` - A role that sets tox versions in `tox.ini`.

0 comments on commit a9ed516

Please sign in to comment.