Skip to content

Commit d3d776f

Browse files
authored
👌 IMPROVE: Update to GH Actions (#4)
1 parent c3ff18d commit d3d776f

File tree

15 files changed

+235
-100
lines changed

15 files changed

+235
-100
lines changed

‎.ansible-lint‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# use `# noqa xxx` at the end of a line, to ignore a particular error
2+
# or add to the warn_list, to ignore for the whole project
3+
warn_list:
4+
- '208' # File permissions unset or incorrect
5+
- '503' # Tasks that run when changed should likely be handlers

‎.github/workflows/ci.yml‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
10+
env:
11+
galaxy-name: "marvel-nccr.yambo"
12+
13+
jobs:
14+
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up Python
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: 3.8
24+
- uses: pre-commit/action@v2.0.0
25+
26+
molecule:
27+
28+
strategy:
29+
matrix:
30+
distro: [ubuntu1604, ubuntu1804, ubuntu2004]
31+
fail-fast: false
32+
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
37+
- uses: actions/checkout@v2
38+
with:
39+
path: ${{ env.galaxy-name }}
40+
41+
- name: Set up Python 3.8
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: 3.8
45+
46+
- name: Upgrade pip
47+
run: |
48+
pip install --upgrade pip
49+
pip --version
50+
51+
- name: Install requirements
52+
run: |
53+
pip install wheel
54+
pip install -r requirements.txt
55+
working-directory: ${{ env.galaxy-name }}
56+
57+
- name: Run molecule
58+
run: molecule test
59+
working-directory: ${{ env.galaxy-name }}
60+
env:
61+
MOLECULE_DISTRO: ${{ matrix.distro }}
62+
63+
release:
64+
name: Publish to ansible-galaxy
65+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
66+
needs: [pre-commit, molecule]
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v2
70+
- uses: robertdebock/galaxy-action@1.0.3
71+
with:
72+
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
*.swp
2+
.DS_Store
3+
.galaxy_install_info
4+
.vscode/
5+
.tox/

‎.pre-commit-config.yaml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# For use with pre-commit.
2+
# See usage instructions at https://pre-commit.com
3+
repos:
4+
5+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
6+
rev: v1.5.0
7+
hooks:
8+
- id: pretty-format-yaml
9+
args: [--autofix, --indent, "2", --preserve-quotes]
10+
11+
- repo: https://github.com/adrienverge/yamllint
12+
rev: v1.25.0
13+
hooks:
14+
- id: yamllint
15+
16+
- repo: https://github.com/ansible/ansible-lint
17+
rev: v4.3.5
18+
hooks:
19+
- id: ansible-lint

‎.travis.yml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.yamllint‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎.yamllint.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extends: default
2+
rules:
3+
document-start: disable
4+
line-length:
5+
max: 200
6+
level: warning
7+
indentation:
8+
spaces: 2
9+
indent-sequences: false

‎README.md‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![CI](https://github.com/marvel-nccr/ansible-role-yambo/workflows/CI/badge.svg)](https://github.com/marvel-nccr/ansible-role-yambo/actions)
2+
[![Ansible Role](https://img.shields.io/ansible/role/25529.svg)](https://galaxy.ansible.com/marvel-nccr/yambo)
3+
[![Release](https://img.shields.io/github/tag/marvel-nccr/ansible-role-yambo.svg)](https://github.com/marvel-nccr/ansible-role-yambo/releases)
4+
15
# Ansible Role: marvel-nccr.yambo
26

37
An ansible role that installs [yambo](http://www.yambo-code.org/) on Ubuntu.
@@ -12,12 +16,54 @@ See `defaults/main.yml`
1216

1317
## Example Playbook
1418

19+
```yaml
20+
- hosts: servers
21+
roles:
22+
- role: marvel-nccr.yambo
23+
```
24+
25+
## Development and testing
26+
27+
This role uses [Molecule](https://molecule.readthedocs.io/en/latest/#) and [Docker](https://www.docker.com/) for tests.
28+
29+
After installing [Docker](https://www.docker.com/):
30+
31+
Clone the repository into a package named `marvel-nccr.yambo` (the folder must be named the same as the Ansible Galaxy name)
32+
33+
```bash
34+
git clone https://github.com/marvel-nccr/ansible-role-yambo marvel-nccr.yambo
35+
cd marvel-nccr.yambo
36+
```
37+
38+
Then run:
39+
40+
```bash
41+
pip install -r requirements.txt # Installs molecule
42+
molecule test # runs tests
1543
```
16-
- hosts: servers
17-
roles:
18-
- role: marvel-nccr.yambo
44+
45+
or use tox (see `tox.ini`):
46+
47+
```bash
48+
pip install tox
49+
tox
1950
```
2051

52+
## Code style
53+
54+
Code style is formatted and linted with [pre-commit](https://pre-commit.com/).
55+
56+
```bash
57+
pip install pre-commit
58+
pre-commit run -all
59+
```
60+
61+
## Deployment
62+
63+
Deployment to Ansible Galaxy is automated *via* GitHub Actions.
64+
Simply tag a release `vX.Y.Z` to initiate the CI and release workflow.
65+
Note, the release will only complete if the CI tests pass.
66+
2167
## License
2268

2369
MIT

‎defaults/main.yml‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
yambo_version: "4.5.2"
32
yambo_src: yambo-{{ yambo_version }}
43
yambo_src_archive: "{{ yambo_src }}.tar.gz"
@@ -7,14 +6,14 @@ yambo_prefix: "/usr/local"
76
yambo_url: "https://github.com/yambo-code/yambo/archive/{{ yambo_version }}.tar.gz"
87
yambo_topdir: "{{ yambo_code_folder }}/{{yambo_src}}"
98
yambo_executables:
10-
- name: yambo
11-
folder: "{{ yambo_prefix }}/bin"
12-
plugin: yambo.yambo
13-
version: "{{ yambo_version }}"
14-
- name: p2y
15-
folder: "{{ yambo_prefix }}/bin"
16-
plugin: yambo.yambo
17-
version: "{{ yambo_version }}"
18-
- name: ypp
19-
folder: "{{ yambo_prefix }}/bin"
20-
version: "{{ yambo_version }}"
9+
- name: yambo
10+
folder: "{{ yambo_prefix }}/bin"
11+
plugin: yambo.yambo
12+
version: "{{ yambo_version }}"
13+
- name: p2y
14+
folder: "{{ yambo_prefix }}/bin"
15+
plugin: yambo.yambo
16+
version: "{{ yambo_version }}"
17+
- name: ypp
18+
folder: "{{ yambo_prefix }}/bin"
19+
version: "{{ yambo_version }}"

‎meta/main.yml‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
allow_duplicates: false
32

43
galaxy_info:
@@ -8,11 +7,11 @@ galaxy_info:
87
license: MIT
98
min_ansible_version: 2.7
109
platforms:
11-
- name: Ubuntu
12-
versions:
13-
- xenial
14-
- bionic
10+
- name: Ubuntu
11+
versions:
12+
- xenial
13+
- bionic
1514
galaxy_tags:
16-
- ubuntu
17-
- application
18-
- science
15+
- ubuntu
16+
- application
17+
- science

0 commit comments

Comments
 (0)