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

Module 1 & 2 #18

Closed
wants to merge 2 commits into from
Closed
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: 42 additions & 0 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ansible-test

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ansible_collections/ohioit/github

steps:
- name: Clone the repo
uses: actions/checkout@v2
with:
path: ansible_collections/ohioit/github

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

- name: Install Ansible
run: pip install ansible

- name: Install PyGithub
run: pip install PyGithub

- name: Perform sanity testing with ansible-test on module files
run: ansible-test sanity --python 3.6 --skip-test import plugins/modules/*

- name: Perform unit testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.11
pre-test-cmd: echo This runs before the ansible-test invocation
python-version: 3.6
target-python-version: 3.6
testing-type: units
test-deps: >-
ansible.netcommon
ansible.utils
26 changes: 26 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pylint

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Checkout PyTorch
uses: actions/checkout@master
- name: Install flake8
run: pip install flake8
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
with:
checkName: 'flake8_py3'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a consistent version of python in the GitHub workflows. The ansible test workflow is using 3.6.9. Please use 3.9.x for all workflows.

91 changes: 90 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,91 @@
# Ansible Collection for GitHub
The OHIO IT collection of Ansible modules for GitHub.

### The OHIO IT collection of Ansible modules for GitHub.

The collection includes a variety of Ansible modules to help automate the management of organizations, repositories, and user permissions in GitHub.

---

## Version Compatibility

Tested against:
`Ansible Version >=2.11`
`Python >=3.8`
`PyGitHub >=1.55`

## Installation

Install this collection via [Ansible Galaxy](https://galaxy.ansible.com/ohioit/github):

```bash
ansible-galaxy collection install ohioit.github
```

Content in this collection requires the [PyGitHub package](https://github.com/PyGithub/PyGithub) to interact with [GitHub REST API](https://docs.github.com/en/rest). You can install it with:

```bash
pip install PyGithub
```

## Included Content

### Modules

| Name | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| [repository_information](https://github.com/senior-design-21-22/ansible-collection-github/blob/development/docs/repository_information.rst) | Output repositories along with vital information from an (user specified) organization |
| [collaborator_information](https://github.com/senior-design-21-22/ansible-collection-github/blob/development/docs/collaborator_information.rst) | View and manage repository collaborators |

## Usage

### Repository Information (From organization)

```
- name: "List GitHub repositories within a non-enterprise organization"
ohioit.github.repository_information:
token: "<API TOKEN>"
organization_name: "<ORGANIZATION NAME>"
register: result

- name: "List GitHub repositories within an enterprise organization"
ohioit.github.repository_information:
token: "<TOKEN>"
organization_name: "<ORGANIZATION NAME>"
enterprise_url: "https://github.<ENTERPRISE DOMAIN>/api/v3/"
register: result
```
### Collaborator Information (From organization)

```
- name: "Functions of Collaborator information module"
ohioit.github.collaborator_information:
token: "<API TOKEN>"
organization_name: "<ORGANIZATION NAME>"
enterprise_url: "https://github.<ENTERPRISE DOMAIN>/api/v3/"
repos:
- "<REPO 1>"
- "<REPO 2>"
- "<REPO 3>"
collaborators_to_add:
<GITHUB USERNAME>: "<triage, pull, push or admin>"
check_collaborator:
<GITHUB USERNAME>: "<triage, pull, push or admin>"
collaborators_to_change:
<GITHUB USERNAME>: "<triage, pull, push or admin>"
collaborators_to_remove:
- "<GITHUB USERNAME>"
```

###### _**NOTE**: Tokens should be encrypted and only decrypted at runtime_

## Testing with 'ansible-test'

Testing has been made available using the [ansible-test](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html). These tests include [unit](https://github.com/senior-design-21-22/ansible-collection-github/blob/development/docs/unit_testing.rst), [sanity](https://github.com/senior-design-21-22/ansible-collection-github/tree/repo-information-module/unit/sanity), [integration](https://github.com/senior-design-21-22/ansible-collection-github/blob/development/docs/integration_testing.rst).

The tests are runnable using the following commands:

```bash
ansible-test units --python 3.<YOUR PYTHON VERSION> --venv
ansible-test sanity --python 3.<YOUR PYTHON VERSION> plugins/modules/*
ansible-test integration --python 3.<YOUR PYTHON VERSION>
```
Loading