-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (114 loc) · 3.37 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
name: CI
env:
ROLE_NAME: wcm_io_devops.conga_facts
defaults:
run:
working-directory: 'wcm_io_devops.conga_facts'
'on':
pull_request:
push:
branches:
- master
jobs:
tests:
name: "pytest (${{ matrix.NAME }})"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- NAME: Python 3.6
PYTHON_VERSION: 3.6
- NAME: Python 3.7
PYTHON_VERSION: 3.7
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.PYTHON_VERSION }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.PYTHON_VERSION }}-
- name: Set up Python.
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.PYTHON_VERSION }}'
- name: Install pip tools.
run: |
pip3 install wheel pytest --upgrade
- name: Install test dependencies.
run: >
pip3 install pytest mock ansible --upgrade
- name: Install role requirements.
run: |
pip3 install -r requirements.txt
- name: pytest.
run: |
pytest
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.NAME }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.NAME }}-
- name: Create ansible.cfg
run: "printf '[defaults]\nroles_path=./tests/requirements/:../' > ansible.cfg"
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.9.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 role requirements.
run: |
pip3 install -r requirements.txt
- 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 }}