Skip to content

Commit 63344d8

Browse files
authored
test role via molecule (#1)
* test role via molecule Add continuous integration tests via the `molecule` package that run on Github actions. * undo change of default value * incorporate suggestions from code review * add server url * switch to compute canada server * remove SERVER URL again
1 parent bc9b2c0 commit 63344d8

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
pull_request:
8+
9+
env:
10+
galaxy-name: "cvmfs_contrib.cvmfs_client"
11+
12+
jobs:
13+
14+
molecule:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
distro: [centos8]
20+
fail-fast: false
21+
22+
steps:
23+
24+
- uses: actions/checkout@v2
25+
with:
26+
path: ${{ env.galaxy-name }}
27+
28+
- name: Set up Python 3.8
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: 3.8
32+
33+
- name: Upgrade pip
34+
run: |
35+
pip install --upgrade pip wheel
36+
pip --version
37+
38+
- name: Install requirements
39+
run: |
40+
pip install --use-feature=2020-resolver -r requirements.txt
41+
working-directory: ${{ env.galaxy-name }}
42+
43+
# See https://github.com/geerlingguy/raspberry-pi-dramble/issues/166
44+
- name: Force GitHub Actions' docker daemon to use vfs.
45+
run: |
46+
sudo systemctl stop docker
47+
echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' | sudo tee /etc/docker/daemon.json
48+
sudo systemctl start docker
49+
50+
- name: Run molecule
51+
run: molecule test
52+
working-directory: ${{ env.galaxy-name }}
53+
env:
54+
MOLECULE_DISTRO: ${{ matrix.distro }}
55+
56+
# release:
57+
# name: Publish to ansible-galaxy
58+
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
59+
# needs: [pre-commit, molecule]
60+
# runs-on: ubuntu-latest
61+
# steps:
62+
# - uses: actions/checkout@v2
63+
# - uses: robertdebock/galaxy-action@1.0.3
64+
# with:
65+
# galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}

molecule/default/converge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
3+
- name: Converge
4+
hosts: all
5+
become: true
6+
7+
pre_tasks:
8+
- name: Update apt cache.
9+
apt: update_cache=yes cache_valid_time=600
10+
when: ansible_os_family == 'Debian'
11+
12+
roles:
13+
- role: cvmfs_contrib.cvmfs_client
14+
vars:
15+
cvmfs_client_configure_storage: false
16+
cvmfs_cache_size: "1000" # small cache size for CI
17+
cvmfs_http_proxy: "DIRECT"

molecule/default/molecule.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
3+
dependency:
4+
name: galaxy
5+
options:
6+
role-file: ansible-role-requirements.yml
7+
driver:
8+
name: docker
9+
platforms:
10+
- name: instance
11+
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest"
12+
command: ${MOLECULE_DOCKER_COMMAND:-""}
13+
volumes:
14+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
15+
privileged: true
16+
pre_build_image: true
17+
provisioner:
18+
name: ansible
19+
playbooks:
20+
converge: converge.yml

molecule/default/verify.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
- name: Verify
4+
hosts: all
5+
become: true
6+
7+
tasks:
8+
- name: Test loading the Compute Canada module environment
9+
shell: source /cvmfs/soft.computecanada.ca/config/profile/bash.sh

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# for running tests
2+
molecule[docker]~=3.3.0
3+
docker~=4.4.4
4+
ansible~=4.8.0

0 commit comments

Comments
 (0)