Skip to content

Commit 12259fb

Browse files
committed
Issue #359: Convert tests to use GitHub Actions for CI.
1 parent 50913b6 commit 12259fb

File tree

4 files changed

+152
-129
lines changed

4 files changed

+152
-129
lines changed

.github/workflows/ci.yml

Lines changed: 112 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,129 @@ name: CI
55
push:
66
branches:
77
- master
8+
schedule:
9+
- cron: "10 2 * * 0"
810

911
jobs:
12+
scripts:
13+
name: Scripts
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- test_script: collection
19+
- test_script: molecule
20+
- test_script: orchestration
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.x'
1028

11-
test:
12-
name: Molecule
29+
- name: Run test script.
30+
run: tests/${{ matrix.test_script }}.sh
31+
32+
playbooks:
33+
name: Playbooks
1334
runs-on: ubuntu-latest
1435
strategy:
1536
matrix:
16-
distro:
17-
- centos8
18-
- debian10
37+
include:
38+
- playbook: deployments.yml
39+
distro: ubuntu2004
40+
test_idempotence: false
41+
42+
# TODO: Not easy to test in CI at this time.
43+
# - playbook: deployments-balancer.yml
44+
# distro: ubuntu2004
45+
46+
- playbook: deployments-rolling.yml
47+
distro: ubuntu2004
48+
49+
- playbook: docker.yml
50+
distro: ubuntu2004
51+
test_idempotence: false
52+
53+
- playbook: docker-flask.yml
54+
distro: ubuntu2004
55+
test_idempotence: false
56+
57+
- playbook: docker-hubot.yml
58+
distro: ubuntu2004
59+
test_idempotence: false
60+
61+
- playbook: drupal.yml
62+
distro: ubuntu2004
63+
64+
# TODO: Not easy to test in CI at this time.
65+
# - playbook: dynamic-inventory.yml
66+
# distro: ubuntu2004
67+
68+
- playbook: elk.yml
69+
distro: ubuntu2004
70+
71+
- playbook: first-ansible-playbook.yml
72+
distro: centos7
73+
74+
- playbook: galaxy-role-servers.yml
75+
distro: ubuntu2004
76+
77+
# TODO: Not easy to test in CI at this time.
78+
# - playbook: gluster.yml
79+
# distro: ubuntu2004
80+
81+
- playbook: https-self-signed.yml
82+
distro: ubuntu2004
83+
84+
- playbook: https-nginx-proxy.yml
85+
distro: debian10
86+
87+
- playbook: includes.yml
88+
distro: ubuntu2004
89+
90+
- playbook: jenkins.yml
91+
distro: ubuntu2004
92+
93+
# TODO: Not easy to test in CI at this time.
94+
# - playbook: kubernetes.yml
95+
# distro: debian9
96+
97+
# TODO: Not easy to test in CI at this time.
98+
# - playbook: lamp-infrastructure.yml
99+
# distro: ubuntu2004
100+
101+
- playbook: nodejs.yml
102+
distro: centos7
103+
104+
- playbook: nodejs-role.yml
105+
distro: centos7
106+
107+
- playbook: security.yml
108+
distro: centos8
109+
110+
- playbook: solr.yml
111+
distro: ubuntu2004
112+
113+
- playbook: test-plugin.yml
114+
distro: centos7
19115

20116
steps:
21-
- name: Check out the codebase.
22-
uses: actions/checkout@v2
117+
- uses: actions/checkout@v2
23118

24-
- name: Set up Python 3.
25-
uses: actions/setup-python@v2
119+
- uses: actions/setup-python@v2
26120
with:
27121
python-version: '3.x'
28122

29-
- name: Install test dependencies.
30-
run: pip3 install molecule[docker] yamllint ansible-lint
123+
- name: Download test shim.
124+
run: |
125+
wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
126+
chmod +x tests/test.sh
31127
32-
- name: Run Molecule tests.
33-
run: molecule test
128+
- name: Run playbook with test shim.
129+
run: tests/test.sh
34130
env:
35-
PY_COLORS: '1'
36-
ANSIBLE_FORCE_COLOR: '1'
37-
MOLECULE_DISTRO: ${{ matrix.distro }}
38-
working-directory: molecule
131+
playbook: ${{ matrix.playbook }}
132+
distro: ${{ matrix.distro }}
133+
test_idempotence: ${{ matrix.test_idempotence }}

.github/workflows/molecule-ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: CI
3+
'on':
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
11+
test:
12+
name: Molecule
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
distro:
17+
- centos8
18+
- debian10
19+
20+
steps:
21+
- name: Check out the codebase.
22+
uses: actions/checkout@v2
23+
24+
- name: Set up Python 3.
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Install test dependencies.
30+
run: pip3 install molecule[docker] yamllint ansible-lint
31+
32+
- name: Run Molecule tests.
33+
run: molecule test
34+
env:
35+
PY_COLORS: '1'
36+
ANSIBLE_FORCE_COLOR: '1'
37+
MOLECULE_DISTRO: ${{ matrix.distro }}
38+
working-directory: molecule

.travis.yml

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

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ansible for DevOps Examples
22

3-
[![Build Status](https://travis-ci.com/geerlingguy/ansible-for-devops.svg?branch=master)](https://travis-ci.com/geerlingguy/ansible-for-devops) [![GitHub CI](https://github.com/geerlingguy/ansible-for-devops/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/ansible-for-devops/actions)
3+
[![CI](https://github.com/geerlingguy/ansible-for-devops/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/ansible-for-devops/actions?query=workflow%3ACI) [![Molecule CI](https://github.com/geerlingguy/ansible-for-devops/workflows/Molecule%20CI/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/ansible-for-devops/actions)
44

55
This repository contains Ansible examples developed to support different sections of [Ansible for DevOps](https://www.ansiblefordevops.com/), a book on [Ansible](http://www.ansible.com/) by [Jeff Geerling](https://www.jeffgeerling.com/).
66

@@ -72,7 +72,7 @@ Here is an outline of all the examples contained in this repository, by chapter:
7272
### Chapter 13
7373

7474
- [`molecule`](molecule/): A Molecule example used for testing and developing an Ansible playbook, or for testing in a Continuous Integration (CI) environment.
75-
- [`ci.yml` GitHub Actions workflow](.github/workflows/ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.
75+
- [`molecule-ci.yml` GitHub Actions workflow](.github/workflows/molecule-ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.
7676

7777
### Chapter 14
7878

0 commit comments

Comments
 (0)