Skip to content

Commit 28d7e83

Browse files
authored
Merge pull request #360 from geerlingguy/359-ci-to-gh-actions
Issue #359: Convert tests to use GitHub Actions for CI.
2 parents 50913b6 + 8929b08 commit 28d7e83

File tree

4 files changed

+158
-129
lines changed

4 files changed

+158
-129
lines changed

.github/workflows/ci.yml

Lines changed: 118 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,135 @@ 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+
# TODO: This started failing on GitHub Actions.
47+
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
48+
# - playbook: deployments-rolling.yml
49+
# distro: ubuntu2004
50+
51+
- playbook: docker.yml
52+
distro: ubuntu2004
53+
test_idempotence: false
54+
55+
- playbook: docker-flask.yml
56+
distro: ubuntu2004
57+
test_idempotence: false
58+
59+
- playbook: docker-hubot.yml
60+
distro: ubuntu2004
61+
test_idempotence: false
62+
63+
- playbook: drupal.yml
64+
distro: ubuntu2004
65+
66+
# TODO: Not easy to test in CI at this time.
67+
# - playbook: dynamic-inventory.yml
68+
# distro: ubuntu2004
69+
70+
- playbook: elk.yml
71+
distro: ubuntu2004
72+
73+
- playbook: first-ansible-playbook.yml
74+
distro: centos7
75+
76+
- playbook: galaxy-role-servers.yml
77+
distro: ubuntu2004
78+
79+
# TODO: Not easy to test in CI at this time.
80+
# - playbook: gluster.yml
81+
# distro: ubuntu2004
82+
83+
- playbook: https-self-signed.yml
84+
distro: ubuntu2004
85+
86+
- playbook: https-nginx-proxy.yml
87+
distro: debian10
88+
89+
# TODO: This started failing on GitHub Actions.
90+
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
91+
# - playbook: includes.yml
92+
# distro: ubuntu2004
93+
94+
# TODO: This started failing on GitHub Actions.
95+
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
96+
# - playbook: jenkins.yml
97+
# distro: ubuntu2004
98+
99+
# TODO: Not easy to test in CI at this time.
100+
# - playbook: kubernetes.yml
101+
# distro: debian9
102+
103+
# TODO: Not easy to test in CI at this time.
104+
# - playbook: lamp-infrastructure.yml
105+
# distro: ubuntu2004
106+
107+
- playbook: nodejs.yml
108+
distro: centos7
109+
110+
- playbook: nodejs-role.yml
111+
distro: centos7
112+
113+
- playbook: security.yml
114+
distro: centos8
115+
116+
- playbook: solr.yml
117+
distro: ubuntu2004
118+
119+
- playbook: test-plugin.yml
120+
distro: centos7
19121

20122
steps:
21-
- name: Check out the codebase.
22-
uses: actions/checkout@v2
123+
- uses: actions/checkout@v2
23124

24-
- name: Set up Python 3.
25-
uses: actions/setup-python@v2
125+
- uses: actions/setup-python@v2
26126
with:
27127
python-version: '3.x'
28128

29-
- name: Install test dependencies.
30-
run: pip3 install molecule[docker] yamllint ansible-lint
129+
- name: Download test shim.
130+
run: |
131+
wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
132+
chmod +x tests/test.sh
31133
32-
- name: Run Molecule tests.
33-
run: molecule test
134+
- name: Run playbook with test shim.
135+
run: tests/test.sh
34136
env:
35-
PY_COLORS: '1'
36-
ANSIBLE_FORCE_COLOR: '1'
37-
MOLECULE_DISTRO: ${{ matrix.distro }}
38-
working-directory: molecule
137+
playbook: ${{ matrix.playbook }}
138+
distro: ${{ matrix.distro }}
139+
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: Molecule 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?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?event=push)](https://github.com/geerlingguy/ansible-for-devops/actions?query=workflow%3A%22Molecule+CI%22)
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)