Skip to content

Commit ff3fa73

Browse files
Migrate to GitHub actions (#11)
1 parent eb408f7 commit ff3fa73

File tree

15 files changed

+162
-71
lines changed

15 files changed

+162
-71
lines changed

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
name: CI
3+
4+
env:
5+
ROLE_NAME: wcm_io_devops.jenkins_configuration_as_code
6+
7+
defaults:
8+
run:
9+
working-directory: 'wcm_io_devops.jenkins_configuration_as_code'
10+
11+
'on':
12+
pull_request:
13+
push:
14+
branches:
15+
- master
16+
17+
jobs:
18+
19+
lint:
20+
name: "Lint (${{ matrix.NAME }})"
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
include:
25+
- NAME: min_ansible_version
26+
ANSIBLE_VERSION: "==2.7.*"
27+
ANSIBLE_LINT_VERSION: "==4.2.*"
28+
- NAME: latest
29+
ANSIBLE_VERSION: ""
30+
ANSIBLE_LINT_VERSION: ""
31+
32+
steps:
33+
- name: Check out the codebase.
34+
uses: actions/checkout@v2
35+
with:
36+
path: '${{ env.ROLE_NAME }}'
37+
38+
- name: Cache PIP
39+
uses: actions/cache@v2
40+
with:
41+
path: ~/.cache/pip
42+
key: ${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}-${{ hashFiles('**/requirements.txt') }}
43+
restore-keys: |
44+
${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}-
45+
46+
- name: Create ansible.cfg
47+
run: "printf '[defaults]\nroles_path=./tests/requirements/:../' > ansible.cfg"
48+
49+
- name: Install role requirements
50+
uses: BSFishy/pip-action@v1
51+
with:
52+
requirements: "${{ env.ROLE_NAME }}/requirements.txt"
53+
54+
- name: Set up Python 3.
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: '3.x'
58+
59+
- name: Install pip tools.
60+
run: |
61+
pip3 install wheel --upgrade
62+
63+
- name: Install test dependencies.
64+
run: >
65+
pip3 install yamllint
66+
ansible${{ matrix.ANSIBLE_VERSION }}
67+
ansible-lint${{ matrix.ANSIBLE_LINT_VERSION }}
68+
--upgrade
69+
70+
- name: Install Galaxy requirements.
71+
run: |
72+
ansible-galaxy install -r tests/requirements.yml -p ./tests/requirements
73+
74+
- name: Lint code.
75+
run: |
76+
yamllint .
77+
ansible-lint
78+
79+
- name: Test syntax.
80+
run: |
81+
ansible-playbook tests/test.yml -i tests/inventory --syntax-check
82+
83+
galaxy:
84+
name: "Ansible Galaxy import"
85+
needs:
86+
- lint
87+
if: github.ref == 'refs/heads/master'
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: Trigger a new import on Galaxy.
91+
uses: robertdebock/galaxy-action@affc5472cd0b08f64a51eafba49b08898c1bbeb8
92+
with:
93+
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Release
3+
4+
'on':
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Trigger a new import on Galaxy.
16+
uses: robertdebock/galaxy-action@affc5472cd0b08f64a51eafba49b08898c1bbeb8
17+
with:
18+
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}

.travis.yml

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

.yamllint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 120
7+
level: warning
8+
truthy:
9+
allowed-values: ['true', 'false', 'yes', 'no']
10+
11+
ignore: |
12+
.travis.yml
13+
tests/requirements/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.com/wcm-io-devops/ansible-jenkins-configuration-as-code.svg?branch=master)](https://travis-ci.com/wcm-io-devops/ansible-jenkins-configuration-as-code)
1+
[![CI](https://github.com/wcm-io-devops/ansible-jenkins-configuration-as-code/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/wcm-io-devops/ansible-jenkins-configuration-as-code/actions?query=workflow%3ACI)
22

33
# wcm_io_devops.jenkins_configuration_as_code
44

defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
# Jenkins admin username
23
jenkins_casc_admin_username: admin
34

@@ -52,4 +53,4 @@ jenkins_casc_plugins_present:
5253

5354
# Plugins no longer needed for configuration-as-code
5455
jenkins_casc_plugins_absent:
55-
- name: configuration-as-code-support
56+
- name: configuration-as-code-support

handlers/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
- name: wcm_io_devops.jenkins_configuration_as_code reload
23
include_tasks: reload.yml

meta/main.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
galaxy_info:
23
role_name: jenkins_configuration_as_code
34
author: Tobias Richter
@@ -8,18 +9,18 @@ galaxy_info:
89
min_ansible_version: 2.7
910

1011
platforms:
11-
- name: EL
12-
versions:
13-
- all
14-
- name: Debian
15-
versions:
16-
- all
17-
- name: Ubuntu
18-
versions:
19-
- all
20-
- name: GenericLinux
21-
versions:
22-
- all
12+
- name: EL
13+
versions:
14+
- all
15+
- name: Debian
16+
versions:
17+
- all
18+
- name: Ubuntu
19+
versions:
20+
- all
21+
- name: GenericLinux
22+
versions:
23+
- all
2324

2425
galaxy_tags:
2526
- wcmio
@@ -29,18 +30,16 @@ galaxy_info:
2930

3031
dependencies:
3132
# install plugins
32-
- { role: wcm_io_devops.jenkins_plugins,
33-
version: 1.5.0,
34-
jenkins_plugins_admin_username: "{{ jenkins_casc_admin_username }}",
35-
jenkins_plugins_admin_password: "{{ jenkins_casc_admin_password }}",
36-
jenkins_plugins_jenkins_hostname: "{{ jenkins_casc_jenkins_hostname }}",
37-
jenkins_plugins_jenkins_port: "{{ jenkins_casc_jenkins_port }}",
38-
jenkins_plugins_jenkins_home: "{{ jenkins_casc_jenkins_home }}",
39-
jenkins_plugins_jenkins_url_prefix: "{{ jenkins_casc_jenkins_url_prefix }}",
40-
jenkins_plugins_present: "{{ jenkins_casc_plugins_present }}",
41-
tags: [
42-
"dependency",
43-
"jenkins_configuration_as_code_plugins",
44-
"wcm_io_devops.jenkins_plugins"
45-
]
46-
}
33+
- role: wcm_io_devops.jenkins_plugins
34+
version: 1.5.0
35+
jenkins_plugins_admin_username: "{{ jenkins_casc_admin_username }}"
36+
jenkins_plugins_admin_password: "{{ jenkins_casc_admin_password }}"
37+
jenkins_plugins_jenkins_hostname: "{{ jenkins_casc_jenkins_hostname }}"
38+
jenkins_plugins_jenkins_port: "{{ jenkins_casc_jenkins_port }}"
39+
jenkins_plugins_jenkins_home: "{{ jenkins_casc_jenkins_home }}"
40+
jenkins_plugins_jenkins_url_prefix: "{{ jenkins_casc_jenkins_url_prefix }}"
41+
jenkins_plugins_present: "{{ jenkins_casc_plugins_present }}"
42+
tags:
43+
- "dependency"
44+
- "jenkins_configuration_as_code_plugins"
45+
- "wcm_io_devops.jenkins_plugins"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This role needs to have the following PIP components installed

tasks/configure.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- name: "configure : check if '{{ jenkins_casc_config_path }}' exists."
23
stat:
34
path: "{{ jenkins_casc_config_path }}"

0 commit comments

Comments
 (0)