Skip to content

Commit

Permalink
Docs and tests (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tompage1994 authored Aug 17, 2023
1 parent 990a657 commit cbffd83
Show file tree
Hide file tree
Showing 35 changed files with 829 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# The exclude_paths does not appear to be working in pre-commit
# this issue describes similar behavior but suggested fix doesn't work
# https://github.com/ansible/ansible-lint/issues/371
# exclude_paths:
# - roles/master_role_example/
exclude_paths:
- '.github/'
- 'roles/master_role_example/'
- 'changelogs/'
parseable: true
use_default_rules: true
# https://github.com/ansible/ansible-lint/issues/808
# with verbosity set to 1, its dumping 'unknown file type messages'
# verbosity: 1
skip_list:
- meta-unsupported-ansible
- meta-runtime # This collection with the appropriate awx.awx or ansible.controller still works with older ansible.
- fqcn[keyword]
- role-name[path]
- var-naming[no-role-prefix]
- galaxy[version-incorrect] # Added because it doesn't like pre-v1.0.0 versions
warn_list:
- jinja[invalid] # Temporarily adding this due to https://github.com/ansible/ansible-lint/issues/3048
kinds:
- playbooks: "**/examples/*.{yml,yaml}"
- tasks: "**/examples/tasks/*.yml"
- vars: "**/examples/vars/*.yml"
...
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length=160
ignore=E402
extend-ignore = E203, W503
3 changes: 3 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Community Code of Conduct

Please see the [Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
61 changes: 61 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# How to Contribute

We welcome contributions from the community. Here are a few ways you can help us improve.

## Open an Issue

If you see something you'd like changed, but aren't sure how to change it, submit an issue describing what you'd like to see.

## Working Locally

Python's pre-commit tool can be installed, and hooks installed, to cleanup whitespace, newlines, and run yamllint and ansible-lint against your local changes before committing. This will help you avoid failures in the github workflows.

1. Create a local virtual environment for galaxy_configurations (suggested, its your system!)
2. Use pip to install pre-commit in your environment of choice: `pip install pre-commit`
3. Install pre-commit hooks with `pre-commit install --install-hooks -c .github/workflow-config/.pre-commit-config.yml`
4. With hooks installed, they will be run automatically when you call `git commit`, blocking commit if any hooks fail.
5. [Optional] If you want to ignore hook failures and commit anyway, use `git commit -n`
6. [Optional] Run pre-commit checks at any time with `pre-commit run --all -c .github/workflow-config/.pre-commit-config.yml`.

Please see pre-commit documentation for further explanation: [Pre-commit](https://pre-commit.com/)

## Submit a Pull Request

If you feel like getting your hands dirty, feel free to make the change yourself. Here's how:

1. Fork the repo on Github, and then clone it locally.
2. Create a branch named appropriately for the change you are going to make.
3. Make your code change.
4. If you are creating a new role, please add a test for it in our [testing playbooks.](https://github.com/redhat-cop/eda_configuration/blob/devel/tests/playbooks/) by adding a new role entry and adding the appropriate yaml file with test data in the eda_configs directory.
5. Add a changelog fragment in `changelogs/fragments` as per <https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs>
6. Push your code change up to your forked repo.
7. Open a Pull Request to merge your changes to this repo. The comment box will be filled in automatically via a template.
8. All Pull Requests will be subject to Ansible and Yaml Linting checks. Please make sure that your code complies and fix any warnings that arise. These are checks that appear at the bottom of your Pull Request.
9. All Pull requests are subject to Testing against being used in automation hub. As above there is a check at the bottom of your pull request for this named integration.

See [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) got more information on how to use GitHub PRs.

For an in depth guide on how to contribute see [this article](https://opensource.com/article/19/7/create-pull-request-github)

Note that we follow the [Automation Good Practices](https://redhat-cop.github.io/automation-good-practices) and so are you expected to do.

Use Github [discussions] forum or for a live chat experience try
Matrix room [#aap_config_as_code:ansible.com](https://matrix.to/#/#aap_config_as_code:ansible.com).

For the full list of Ansible IRC and Mailing list, please see the
[Ansible Communication] page.
Release announcements will be made to the [Ansible Announce] list.

Possible security bugs should be reported via email
to <mailto:[email protected]>.

## Code of Conduct

As with all Ansible projects, we have a [Code of Conduct].

[ansible announce](https://groups.google.com/forum/#!forum/ansible-announce)
[ansible communication](https://docs.ansible.com/ansible/latest/community/communication.html)
[code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
[creating your fork on github](https://guides.github.com/activities/forking/)
[discussions](https://github.com/redhat-cop/eda_configuration/discussions)
[supported ansible versions](https://docs.ansible.com/ansible-core/devel/reference_appendices/release_and_maintenance.html#ansible-core-release-cycle)
77 changes: 77 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Bug report
about: >
Create a bug report. Please test against the latest release before
submitting it. For anything else, please use discussions
link below.
labels: bug, new
---

<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release are affected -->

# Summary

<!--- Explain the problem briefly below -->

# Issue Type

- Bug Report

# Ansible, Collection, Private Automation Hub details

<!--- Paste verbatim output between triple backticks -->

```console (paste below)
ansible --version

ansible-galaxy collection list

Private Automation Hub version

```

- ansible installation method: one of source, pip, OS package, EE

# OS / ENVIRONMENT

<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->

# Desired Behavior

<!--- Describe what you expected to happen when running the steps above -->

# Actual Behavior

<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

Please give some details of what is actually happening.
Include a [minimum complete verifiable example] with:

- playbook / task
- configuration file / list
- error

<!--- Paste verbatim command output between triple backticks -->

```console (error)

```

# STEPS TO REPRODUCE

<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between triple backticks below -->

```yaml (playbook/task)

```

```yaml (config/list/array/variables)

```

<!--- HINT: You can paste gist.github.com links for larger files -->

[minimum complete verifiable example]: http://stackoverflow.com/help/mcve
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
blank_issues_enabled: false # default is true
contact_links:
- name: Feature requests
url: https://github.com/redhat-cop/ah_configuration/discussions/categories/ideas
about: Suggest an idea for this project
- name: Discussions
url: https://github.com/redhat-cop/ah_configuration/discussions
about: Any kind of questions should go on the forum.
- name: Ansible Code of Conduct
url: https://docs.ansible.com/ansible/latest/community/code_of_conduct.html
about: Be nice to other members of the community. Behave.
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--- markdownlint-disable MD041 -->
# What does this PR do?

<!--- Brief explanation of the code or documentation change you've made -->

# How should this be tested?

<!--- Automated tests are preferred, but not always doable - especially for infrastructure. Include commands to run your new feature, and also post-run commands to validate that it worked. (please use code blocks to format code samples) -->

# Is there a relevant Issue open for this?

<!--- Provide a link to any open issues that describe the problem you are solving. -->
resolves #[number]

# Other Relevant info, PRs, etc

<!--- Please provide link to other PRs that may be related (blocking, resolves, etc. etc.) -->
5 changes: 5 additions & 0 deletions .github/files/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
collections_paths=collections
roles_path=roles/
module_utils=plugins/module_utils
library=plugins/modules
33 changes: 33 additions & 0 deletions .github/files/galaxy.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
authors:
- Chris Renwick @crenwick93
- Tom Page @Tompage1994
- Sean Sullivan @sean-m-sullivan
- David Danielsson @djdanielsson
dependencies: {}
description: Ansible content that interacts with the Ansible EDA Controller.
documentation: https://github.com/redhat-cop/eda_configuration/blob/devel/README.md
license:
- GPL-3.0-only
namespace: {{ collection_namespace }}
name: {{ collection_name }}
version: {{ collection_version }}
readme: README.md
repository: {{ collection_repo }}
issues: {{ collection_repo }}/issues
tags:
- cloud
- infrastructure
- ansible
- event
- driven
- controller
- eda
- automation
build_ignore:
- tools
- setup.cfg
- galaxy.yml.j2
- template_galaxy.yml
- '*.tar.gz'
...
15 changes: 15 additions & 0 deletions .github/workflows/ci_standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Test roles and modules
on: [push, pull_request_target]

jobs:
ci_standalone:
strategy:
fail-fast: false
matrix:
eda_server_version:
- main
uses: "./.github/workflows/ci_standalone_versioned.yml"
with:
eda_server_version: ${{ matrix.eda_server_version }}
gh_ref: ${{ github.ref }}
71 changes: 71 additions & 0 deletions .github/workflows/ci_standalone_versioned.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Test roles and modules with galaxy_ng

on:
workflow_call:
inputs:
eda_server_version:
description: The version to pull of galaxy_ng
required: true
type: string
gh_ref:
description: The ref in the repository to pull
required: false
default: devel
type: string

jobs:

integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.gh_ref }}

- name: "Checkout galaxy_ng"
uses: actions/checkout@v2
with:
repository: ansible/eda-server
path: eda-server
ref: ${{ inputs.eda_server_version }}

- uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Update apt
run: sudo apt -y update

- name: Install docker-compose
run: curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose

- name: collect system info
run: whoami; id; pwd; ls -al; uname -a ; df -h .; mount ; cat /etc/issue; docker --version ; ps aux | fgrep -i docker; ls -al /var/run/containerd/containerd.sock

# We might also want to spin up an AWX later here and set EDA_CONTROLLER_URL and EDA_CONTROLLER_SSL_VERIFY for integration testing but for now we can skip.

# We should also consider setting EDA_IMAGE_URL and EDA_UI_IMAGE_URL from the eda_server_version once images are properly tagged. We may not need to pull a different version of the repo but instead just point at a different image.

- name: Pull Images
working-directory: eda-server/tools/docker
run: docker compose -p eda -f docker-compose-stage.yaml pull

- name: Start stack
working-directory: eda-server/tools/docker
run: docker compose -p eda -f docker-compose-stage.yaml up -d --wait

- name: Move ansible.cfg to root
run: mv .github/files/ansible.cfg .

- name: Build and install the collection
id: build
uses: redhat-cop/ansible_collections_tooling/actions/build_ansible_collection@main
with:
collection_namespace: infra
collection_name: automation_hub
collection_version: 0.0.1
collection_repo: https://github.com/redhat-cop/eda_configuration

- name: "Perform playbook collection tests"
run: ansible-playbook tests/playbooks/testing_collections_playbook.yml -v -e eda_server_version=${{ inputs.eda_server_version }} -e git_repo_name=${{ github.event.repository.name }}
20 changes: 20 additions & 0 deletions .github/workflows/issue-close-inactive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# https://github.com/marketplace/actions/issues-helper
name: Check inactive

on:
schedule:
- cron: "0 6 * * *"

jobs:
close-inactive-issues:
runs-on: ubuntu-latest
steps:
- name: close-issues
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
token: ${{ secrets.GITHUB_TOKEN }}
labels: 'need info, inactive'
inactive-day: 7
...
21 changes: 21 additions & 0 deletions .github/workflows/issue-find-inactive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# https://github.com/marketplace/actions/issues-helper
name: Check inactive

on:
schedule:
- cron: "0 5 * * *"

jobs:
check-inactive:
runs-on: ubuntu-latest
steps:
- name: check-inactive
uses: actions-cool/issues-helper@v3
with:
actions: 'check-inactive'
token: ${{ secrets.GITHUB_TOKEN }}
inactive-day: 30
issue-state: open
exclude-labels: 'backlog, help wanted'
...
Loading

0 comments on commit cbffd83

Please sign in to comment.