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

Update pre-commit #443

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
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
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/'
- '*.py'
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]
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"
...
Empty file.
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
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).
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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/)

## Automation Hub API Spec

For development purposes it can help to have a version of the Automation Hub API spec available to you. You can find this by navigating to `https://<AH_HOST>/api/galaxy/v3/openapi.yaml`. VSCode extensions exist to render this file using Swagger.

## 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. Ensure this branch starts from an up to date pull of the `devel` branch (the default branch).
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/ansible/galaxy_collection/tree/devel/tests/playbooks) by adding a new role entry and adding the appropriate yaml file with test data in the ah_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 (against the `devel` branch). 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 our live chat 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/)
[supported ansible versions](https://docs.ansible.com/ansible-core/devel/reference_appendices/release_and_maintenance.html#ansible-core-release-cycle)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: Bug report
about: Create a bug report. Please test against the latest release before submitting
it. For anything else, please use Forums link below.
title: ''
labels: bug, new
assignees: ''

---

<!--- 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 -->

<!-- See a minimum complete verifiable example here: http://stackoverflow.com/help/mcve -->
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement, new
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
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.) -->
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
authors:
- Sean Sullivan @sean-m-sullivan
- Tom Page @Tompage1994
- David Danielsson @djdanielsson
dependencies: {}
description: Ansible content that interacts with the Ansible Automation Hub or Galaxy NG API.
documentation: https://github.com/redhat-cop/ah_configuration/blob/master/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
- galaxy
- ansible
- galaxy
- automation
build_ignore:
- tools
- setup.cfg
- galaxy.yml.j2
- template_galaxy.yml
- '*.tar.gz'
...
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
...
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'
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# https://github.com/marketplace/actions/issues-helper
name: Issue Labeled

on:
issues:
types: [labeled]

jobs:
issue-labeled:
runs-on: ubuntu-latest
steps:
- name: Create comment
uses: actions-cool/issues-helper@v3
if: github.event.label.name == 'inactive' || github.event.label.name == 'need info'
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}. Please ensure that you have filled out the issue template as much as possible and have answered any further questions asked. If you have not done so in the next 7 days this issue will be automatically closed.'
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# https://github.com/marketplace/actions/issues-helper
name: Issue Remove Labels

on:
issues:
types: [edited, reopened, labeled]
issue_comment:
types: [created, edited]

jobs:
remove-inactive:
runs-on: ubuntu-latest
steps:
- name: remove inactive
if: github.event.issue.state == 'open' && github.event.issue.user != 'github-actions'
uses: actions-cool/issues-helper@v3
with:
actions: 'remove-labels'
issue-number: ${{ github.event.issue.number }}
labels: 'inactive'
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# This workflow action will run pre-commit, which will execute ansible and yaml linting
# See .pre-commit-config.yaml for what hooks are executed
name: pre-commit tests


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

jobs:
pre-commit_and_sanity:
uses: "redhat-cop/ansible_collections_tooling/.github/workflows/pre_commit_and_sanity.yml@main"
with:
collection_namespace: galaxy
collection_name: galaxy
collection_version: 1.1.1-devel
collection_repo: https://github.com/ansible/galaxy_collection
collection_dependencies: ansible.hub
...
Loading