generated from 39services/ansible_collection_39systems.template
-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (91 loc) · 2.82 KB
/
ansible-full-test.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
---
name: Molecule Test
on:
pull_request:
types: [opened, reopened, edited, assigned, review_requested]
paths:
- "roles/**"
workflow_dispatch:
inputs:
roles:
description: 'Array of roles to test'
required: true
jobs:
find-molecule:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ env.matrix_output }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get changed roles
id: changed-roles
uses: tj-actions/changed-files@v41
with:
path: "roles"
diff_relative: "true"
files: "**"
dir_names: "true"
dir_names_max_depth: "1"
since_last_remote_commit: "true"
- name: Return roles that have molecule tests
id: matrix
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo 'matrix_output=${{ github.event.inputs.roles }}' >> "$GITHUB_ENV"
exit 0
else
roles=""
for role in ${{ steps.changed-roles.outputs.all_changed_and_modified_files }}; do
echo "Checking $role"
if [ -f roles/$role/molecule/default/molecule.yml ]; then
echo "Found molecule.yml in $role"
if [ -z "$roles" ]; then
roles="\"$role\""
else
roles="$roles, \"$role\""
fi
echo DEBUG $roles
fi
done
echo DEBUG "matrix_output=[$roles]"
echo "matrix_output=[$roles]" >> "$GITHUB_ENV"
fi
exit 0
molecule:
runs-on: ubuntu-20.04
needs:
- find-molecule
strategy:
matrix:
role: ${{ fromJson(needs.find-molecule.outputs.matrix) }}
steps:
- name: Need all the space we can get here...
uses: jlumbroso/free-disk-space@main
with:
android: true
dotnet: true
haskell: true
large-packages: false # https://github.com/jlumbroso/free-disk-space/issues/4
docker-images: true
swap-storage: true
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies.
working-directory: roles/${{ matrix.role }}
run: pip3 install -r requirements.txt
- name: Install Ansible dependencies.
run: ansible-galaxy install -r requirements.yml
- name: Install Ansible dependencies.
working-directory: roles/${{ matrix.role }}
run: ansible-galaxy install -r requirements.yml
- name: Run molecule
working-directory: roles/${{ matrix.role }}
run: "molecule test"
...