-
Notifications
You must be signed in to change notification settings - Fork 3
99 lines (93 loc) · 3.46 KB
/
ci-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
name: Continuous Integration
on:
workflow_call:
inputs:
box-distribution:
description: "Vagrant Box Operating System"
type: string
required: true
box-repository:
description: "Vagrant Box repository"
type: string
required: true
ansible-connection:
description: "Ansible connection type for connecting to the Box"
type: string
required: false
default: ssh
ansible-group:
description: "Box's Ansible inventory group"
type: string
required: false
default: Linux
display-name:
description: "OS Name to display in workflow steps"
type: string
required: true
scenario-name:
description: "Name of the molecule scenario to execute"
type: string
required: true
# default: default
role-path:
description: "Relative path to the role to be linted"
type: string
required: false
default: extensions
jobs:
molecule-test:
name: "ansible-${{ matrix.versions.ansible }} (Python: ${{ matrix.versions.python }})"
runs-on: [self-hosted, Linux, X64, ansible-collection]
strategy:
fail-fast: false
matrix:
versions:
# ansible-core upstream development supports 3 releases at a time
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html
# - ansible: stable-2.12 # EOL 2023-05-23
# python: '3.10'
# - ansible: stable-2.13 # EOL 2023-11-06
# python: '3.10'
# - ansible: stable-2.14 # EOL 2024-05-20
# python: '3.10'
- ansible: stable-2.16 # EOL 2025-05 - last version to support Python <3.7
python: "3.12"
env:
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
S1_AGENT_SITE_TOKEN: ${{ secrets.S1_AGENT_SITE_TOKEN }}
S1_API_TOKEN: ${{ secrets.S1_API_TOKEN }}
S1_MANAGEMENT_CONSOLE: ${{ vars.S1_MANAGEMENT_CONSOLE }}
S1_MOLECULE_HOSTNAME: falling-lab
VAGRANT_DEFAULT_PROVIDER: virtualbox
VAGRANT_HOME: /opt/hostedtoolcache/Vagrant
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/ci-setup
with:
python-version: ${{ matrix.versions.python }}
ansible-version: ${{ matrix.versions.ansible }}
- name: Set environment
run: |
DISTRIBUTION=${{ inputs.box-distribution }}
REPOSITORY=${{ inputs.box-repository }}
GROUP=${{ inputs.ansible-group }}
echo "S1_VAGRANT_DISTRO=${DISTRIBUTION}" >> $GITHUB_ENV
echo "S1_VAGRANT_REPO=${REPOSITORY}" >> $GITHUB_ENV
if [ -n "$GROUP" ]; then echo "S1_VAGRANT_GROUP=${GROUP}" >> $GITHUB_ENV; fi
- name: Assert that variables are defined
if: ${{ (env.S1_VAGRANT_DISTRO == '') || (env.S1_VAGRANT_REPO == '') }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('S1_VAGRANT_DISTRO and S1_VAGRANT_REPO are not set!')
- name: Execute Molecule Scenarios
if: success()
run: >-
echo ${PWD} &&
molecule --version &&
ansible --version &&
molecule test --scenario-name ${{ inputs.scenario-name }}
working-directory: ${{ inputs.role-path }}