Skip to content

Commit

Permalink
Migrate to GitHub actions (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-richter authored Feb 2, 2021
1 parent eb408f7 commit ff3fa73
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 71 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
name: CI

env:
ROLE_NAME: wcm_io_devops.jenkins_configuration_as_code

defaults:
run:
working-directory: 'wcm_io_devops.jenkins_configuration_as_code'

'on':
pull_request:
push:
branches:
- master

jobs:

lint:
name: "Lint (${{ matrix.NAME }})"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- NAME: min_ansible_version
ANSIBLE_VERSION: "==2.7.*"
ANSIBLE_LINT_VERSION: "==4.2.*"
- NAME: latest
ANSIBLE_VERSION: ""
ANSIBLE_LINT_VERSION: ""

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: '${{ env.ROLE_NAME }}'

- name: Cache PIP
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}-
- name: Create ansible.cfg
run: "printf '[defaults]\nroles_path=./tests/requirements/:../' > ansible.cfg"

- name: Install role requirements
uses: BSFishy/pip-action@v1
with:
requirements: "${{ env.ROLE_NAME }}/requirements.txt"

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install pip tools.
run: |
pip3 install wheel --upgrade
- name: Install test dependencies.
run: >
pip3 install yamllint
ansible${{ matrix.ANSIBLE_VERSION }}
ansible-lint${{ matrix.ANSIBLE_LINT_VERSION }}
--upgrade
- name: Install Galaxy requirements.
run: |
ansible-galaxy install -r tests/requirements.yml -p ./tests/requirements
- name: Lint code.
run: |
yamllint .
ansible-lint
- name: Test syntax.
run: |
ansible-playbook tests/test.yml -i tests/inventory --syntax-check
galaxy:
name: "Ansible Galaxy import"
needs:
- lint
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Trigger a new import on Galaxy.
uses: robertdebock/galaxy-action@affc5472cd0b08f64a51eafba49b08898c1bbeb8
with:
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Release

'on':
release:
types:
- published

jobs:

release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Trigger a new import on Galaxy.
uses: robertdebock/galaxy-action@affc5472cd0b08f64a51eafba49b08898c1bbeb8
with:
galaxy_api_key: ${{ secrets.GALAXY_API_KEY }}
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
extends: default

rules:
line-length:
max: 120
level: warning
truthy:
allowed-values: ['true', 'false', 'yes', 'no']

ignore: |
.travis.yml
tests/requirements/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![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)

# wcm_io_devops.jenkins_configuration_as_code

Expand Down
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Jenkins admin username
jenkins_casc_admin_username: admin

Expand Down Expand Up @@ -52,4 +53,4 @@ jenkins_casc_plugins_present:

# Plugins no longer needed for configuration-as-code
jenkins_casc_plugins_absent:
- name: configuration-as-code-support
- name: configuration-as-code-support
1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
- name: wcm_io_devops.jenkins_configuration_as_code reload
include_tasks: reload.yml
53 changes: 26 additions & 27 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
galaxy_info:
role_name: jenkins_configuration_as_code
author: Tobias Richter
Expand All @@ -8,18 +9,18 @@ galaxy_info:
min_ansible_version: 2.7

platforms:
- name: EL
versions:
- all
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
- name: GenericLinux
versions:
- all
- name: EL
versions:
- all
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
- name: GenericLinux
versions:
- all

galaxy_tags:
- wcmio
Expand All @@ -29,18 +30,16 @@ galaxy_info:

dependencies:
# install plugins
- { role: wcm_io_devops.jenkins_plugins,
version: 1.5.0,
jenkins_plugins_admin_username: "{{ jenkins_casc_admin_username }}",
jenkins_plugins_admin_password: "{{ jenkins_casc_admin_password }}",
jenkins_plugins_jenkins_hostname: "{{ jenkins_casc_jenkins_hostname }}",
jenkins_plugins_jenkins_port: "{{ jenkins_casc_jenkins_port }}",
jenkins_plugins_jenkins_home: "{{ jenkins_casc_jenkins_home }}",
jenkins_plugins_jenkins_url_prefix: "{{ jenkins_casc_jenkins_url_prefix }}",
jenkins_plugins_present: "{{ jenkins_casc_plugins_present }}",
tags: [
"dependency",
"jenkins_configuration_as_code_plugins",
"wcm_io_devops.jenkins_plugins"
]
}
- role: wcm_io_devops.jenkins_plugins
version: 1.5.0
jenkins_plugins_admin_username: "{{ jenkins_casc_admin_username }}"
jenkins_plugins_admin_password: "{{ jenkins_casc_admin_password }}"
jenkins_plugins_jenkins_hostname: "{{ jenkins_casc_jenkins_hostname }}"
jenkins_plugins_jenkins_port: "{{ jenkins_casc_jenkins_port }}"
jenkins_plugins_jenkins_home: "{{ jenkins_casc_jenkins_home }}"
jenkins_plugins_jenkins_url_prefix: "{{ jenkins_casc_jenkins_url_prefix }}"
jenkins_plugins_present: "{{ jenkins_casc_plugins_present }}"
tags:
- "dependency"
- "jenkins_configuration_as_code_plugins"
- "wcm_io_devops.jenkins_plugins"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This role needs to have the following PIP components installed
1 change: 1 addition & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: "configure : check if '{{ jenkins_casc_config_path }}' exists."
stat:
path: "{{ jenkins_casc_config_path }}"
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- include_tasks: upload.yml
tags:
- jcasc-upload
Expand Down
1 change: 1 addition & 0 deletions tasks/reload.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: "reload : reload Jenkins configuration as code configuration."
jenkins_script:
script: "{{ lookup('file', 'files/groovy/jcasc/reload.groovy') }}"
Expand Down
1 change: 1 addition & 0 deletions tasks/upload.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: "upload : calculate files to upload order to check that no files exist with overlapping names."
set_fact:
_jenkins_casc_found_config_files: "{{ _jenkins_casc_found_config_files | default([]) + [item] }}"
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
- name: wcm_io_devops.jenkins_plugins
version: master
3 changes: 2 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- name: test role syntax
hosts: test
roles:
- ansible-jenkins-configuration-as-code
- wcm_io_devops.jenkins_configuration_as_code

0 comments on commit ff3fa73

Please sign in to comment.