Skip to content

Commit

Permalink
🧪 Improve GH action (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Oct 7, 2020
1 parent 26fa0d9 commit ca89d67
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
37 changes: 30 additions & 7 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: CI

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

env:
galaxy-name: marvel-nccr.slurm

jobs:

pre-commit:
Expand All @@ -21,18 +26,21 @@ jobs:
molecule:

strategy:
fail-fast: false
matrix:
# ubuntu-16.04, ubuntu-18.04
docker-version: ["1.1", "2.2"]
include:
- os: ubuntu-16.04
docker-version: "1.1"
- os: ubuntu-18.04
docker-version: "2.2"
fail-fast: false

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:

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

- name: Set up Python 3.8
uses: actions/setup-python@v2
Expand All @@ -45,10 +53,25 @@ jobs:
pip --version
- name: Install requirements
run: pip install -r requirements.txt
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:
DOCKER_IMAGE: marvelnccr/ubuntu-docker-base
DOCKER_IMAGE_VERSION: ${{ docker-version }}
DOCKER_IMAGE_VERSION: ${{ matrix.docker-version }}

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 }}
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.org/marvel-nccr/ansible-role-slurm.svg?branch=master)](https://travis-ci.org/marvel-nccr/ansible-role-slurm)
[![CI](https://github.com/marvel-nccr/ansible-role-slurm/workflows/CI/badge.svg)](https://github.com/marvel-nccr/ansible-role-slurm/actions)
[![Galaxy](https://img.shields.io/badge/Galaxy-marvel--nccr.slurm-blue)](https://galaxy.ansible.com/marvel-nccr/slurm)

# Ansible Role: marvel-nccr.slurm

Expand Down Expand Up @@ -33,6 +34,15 @@ pip install -r requirements.txt
molecule test
```

## Code style

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

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

## License

MIT
Expand Down
5 changes: 4 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
- hosts: all

pre_tasks:

- name: Update apt cache.
become: true
apt: update_cache=yes cache_valid_time=600
apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == 'Debian'

vars:
Expand Down
4 changes: 4 additions & 0 deletions tasks/hostname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
become: true
hostname:
name: "{{ slurm_hostname }}"
# hostname works inconsistently on Docker containers: https://github.com/ansible/ansible/issues/19681
# it works for Ubuntu 18.04, but fails locally and on GH actions for 16.04
# raising: Failed to create bus connection: No such file or directory
when: not (cloud_platform is defined and cloud_platform == 'docker' and ansible_os_family == 'Debian' and ansible_distribution_major_version == '16')

# Yaml requires escaping backslashes in double quotes but not in single quotes
# This works for docker, both locally and on travis
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# configuration to run via tox
# to use a specific docker image: `DOCKER_IMAGE_VERSION=1.1 tox`

[tox]
envlist = py38

Expand All @@ -8,4 +11,7 @@ skip_install = true
deps = -rrequirements.txt
passenv =
HOME
commands = molecule test
DOCKER_IMAGE
DOCKER_IMAGE_VERSION
DOCKER_COMMAND
commands = molecule {posargs:test}

0 comments on commit ca89d67

Please sign in to comment.