Skip to content

Commit

Permalink
🔧 Standardise CI (#9)
Browse files Browse the repository at this point in the history
See marvel-nccr/quantum-mobile#132

Co-authored-by: Augustin Degomme <adegomme@gmail.com>
  • Loading branch information
chrisjsewell and adegomme authored Oct 20, 2020
1 parent 657c041 commit 0dbf13a
Show file tree
Hide file tree
Showing 16 changed files with 233 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
warn_list: # or 'skip_list' to silence them completely
- '106' # Role name {} does not match ``^[a-z][a-z0-9_]+$`` pattern
- '208' # File permissions unset or incorrect
- '503' # Tasks that run when changed should likely be handlers
72 changes: 72 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
branches: [master]
tags:
- 'v*'
pull_request:

env:
galaxy-name: "marvel-nccr.bigdft"

jobs:

pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0

molecule:

strategy:
matrix:
distro: [ubuntu1604, ubuntu1804]
fail-fast: false

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2
with:
path: ${{ env.galaxy-name }}

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

- name: Upgrade pip
run: |
pip install --upgrade pip
pip --version
- name: Install requirements
run: |
pip install wheel
pip install -r requirements.txt
working-directory: ${{ env.galaxy-name }}

- name: Run molecule
run: molecule test
working-directory: ${{ env.galaxy-name }}
env:
MOLECULE_DISTRO: ${{ matrix.distro }}

release:
name: Publish to ansible-galaxy
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [pre-commit, molecule]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: robertdebock/galaxy-action@1.0.3
with:
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*.swp
.DS_Store
.galaxy_install_info
.vscode/
.tox/
22 changes: 15 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
# For use with pre-commit.
# See usage instructions at https://pre-commit.com
- repo: local
repos:

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v1.5.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, "2", --preserve-quotes]

- repo: https://github.com/adrienverge/yamllint
rev: v1.25.0
hooks:
- id: yamllint
name: yamllint
description: This hook runs yamllint.
entry: yamllint
language: system
types: [file, yaml]

- repo: https://github.com/ansible/ansible-lint
rev: v4.3.5
hooks:
- id: ansible-lint
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .yamllint

This file was deleted.

9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default
rules:
document-start: disable
line-length:
max: 200
level: warning
indentation:
spaces: 2
indent-sequences: false
57 changes: 52 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Build Status](https://travis-ci.org/marvel-nccr/ansible-role-bigdft.svg?branch=master)](https://travis-ci.org/marvel-nccr/ansible-role-bigdft)
[![CI](https://github.com/marvel-nccr/ansible-role-bigdft/workflows/CI/badge.svg)](https://github.com/marvel-nccr/ansible-role-bigdft/actions)
[![Ansible Role](https://img.shields.io/ansible/role/37783.svg)](https://galaxy.ansible.com/marvel-nccr/bigdft)
[![Release](https://img.shields.io/github/tag/marvel-nccr/ansible-role-bigdft.svg)](https://github.com/marvel-nccr/ansible-role-bigdft/releases)

# Ansible Role: marvel-nccr.bigdft

An Ansible role that installs [BigDFT](https://bigdft.org) on Ubuntu.
Expand All @@ -14,14 +17,58 @@ See `defaults/main.yml`
## Example Playbook

```yaml
- hosts: servers
roles:
- role: marvel-nccr.bigdft
- hosts: servers
roles:
- role: marvel-nccr.bigdft
```
## Development and testing
This role uses [Molecule](https://molecule.readthedocs.io/en/latest/#) and [Docker](https://www.docker.com/) for tests.
After installing [Docker](https://www.docker.com/):
Clone the repository into a package named `marvel-nccr.bigdft` (the folder must be named the same as the Ansible Galaxy name)

```bash
git clone https://github.com/marvel-nccr/ansible-role-bigdft marvel-nccr.bigdft
cd marvel-nccr.bigdft
```

Then run:

```bash
pip install -r requirements.txt # Installs molecule
molecule test # runs tests
```

or use tox (see `tox.ini`):

```bash
pip install tox
tox
```

## Code style

Code style is formatted and linted with [pre-commit](https://pre-commit.com/).

```bash
pip install pre-commit
pre-commit run -all
```

## Deployment

Deployment to Ansible Galaxy is automated *via* GitHub Actions.
Simply tag a release `vX.Y.Z` to initiate the CI and release workflow.
Note, the release will only complete if the CI tests pass.

## License

MIT - BigDFT code is licensed under GNU GPL v2
MIT

BigDFT code is licensed under GNU GPL v2

## Contact

Expand Down
15 changes: 7 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
bigdft_version: "1.9.0"
bigdft_src: bigdft-suite-{{ bigdft_version }}
bigdft_src_archive: "{{ bigdft_src }}.tar.gz"
bigdft_version: "4855f2cd" # "1.9.0"
bigdft_code_folder: "/tmp"
bigdft_prefix: "/usr/local"
bigdft_python_path: "{{ ansible_python_interpreter | default('/usr/bin/python') }}"
bigdft_url: "https://gitlab.com/l_sim/bigdft-suite/-/archive/{{ bigdft_version }}/{{ bigdft_src_archive }}"
bigdft_topdir: "{{ bigdft_code_folder }}/bigdft-suite"
# bigdft_src: bigdft-suite-{{ bigdft_version }}
# bigdft_src_archive: "{{ bigdft_src }}.tar.gz"
# bigdft_url: "https://gitlab.com/l_sim/bigdft-suite/-/archive/{{ bigdft_version }}/{{ bigdft_src_archive }}"
bigdft_executables:
- name: bigdft
folder: "{{ bigdft_prefix }}/bin"
plugin: bigdft
- name: bigdft
folder: "{{ bigdft_prefix }}/bin"
plugin: bigdft
15 changes: 7 additions & 8 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
allow_duplicates: false

galaxy_info:
Expand All @@ -8,11 +7,11 @@ galaxy_info:
license: MIT
min_ansible_version: 2.7
platforms:
- name: Ubuntu
versions:
- xenial
- bionic
- name: Ubuntu
versions:
- xenial
- bionic
galaxy_tags:
- ubuntu
- application
- science
- ubuntu
- application
- science
15 changes: 10 additions & 5 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
---
- hosts: all
become: true

vars:
ansible_python_interpreter: /usr/bin/python3

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=3600
when: ansible_os_family == 'Debian'
- name: Update apt cache.
become: true
apt:
name:
- software-properties-common
- git
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'

roles:
- role: marvel-nccr.bigdft
- role: marvel-nccr.bigdft
23 changes: 13 additions & 10 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
---
dependency:
name: galaxy
# requirements_file: molecule/default/requirements.yml
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint -x 503
platforms:
- name: instance
image: "${DOCKER_IMAGE:-marvelnccr/ubuntu-docker-base}:${DOCKER_IMAGE_VERSION:-latest}"
command: "${DOCKER_COMMAND:-sleep infinity}"
privileged: true
pre_build_image: true
- name: instance
image: "marvelnccr/docker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest"
command: "${MOLECULE_DOCKER_COMMAND:-sleep infinity}"
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
provisioner:
name: ansible
playbooks:
converge: converge.yml
# Remove Ansible no_log settings for debugging
# log: true
8 changes: 3 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# for running
ansible~=2.9
ansible~=2.10.0
# for testing
docker
molecule~=3.0
yamllint~=1.17
ansible-lint~=4.1
molecule[docker]~=3.1.0
docker~=4.2
Loading

0 comments on commit 0dbf13a

Please sign in to comment.