forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (192 loc) · 6.32 KB
/
ansible.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Ansible
# The workflow triggered by any change in deployments/ansible/.
# 1. Run lint checks and Ansible Molecule tests.
# 2. Push a new "ansible-v<VERSION>" tag, if the version was updated
# in deployments/ansible/galaxy.yml.
on:
push:
paths:
- '.github/workflows/ansible.yml'
- 'deployments/ansible/galaxy.yml'
branches:
- main
pull_request:
paths:
- '.github/workflows/ansible.yml'
- 'deployments/ansible/**'
- '!**.md'
concurrency:
group: ansible-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
defaults:
run:
working-directory: 'deployments/ansible'
jobs:
lint:
name: Lint
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install yamllint.
run: pip3 install yamllint
- name: Lint code.
run: yamllint .
linux-test:
name: Linux Test
needs: lint
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
ansible:
- ansible~=2.10.0
- ansible~=6.0
- ansible~=7.0
distro:
- amazonlinux2
- amazonlinux2023
- centos7
- centos8
- centos9
- debian9
- debian10
- debian11
- opensuse12
- opensuse15
- ubuntu1604
- ubuntu1804
- ubuntu2004
- ubuntu2204
exclude:
# ansible<6 unsupported on Amazon Linux 2023
- distro: amazonlinux2023
ansible: ansible~=2.10.0
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- uses: DamianReeves/write-file-action@v1.2
with:
path: "${{ github.workspace }}/requirements.txt"
contents: |
${{ matrix.ansible }}
molecule==3.3.0
molecule-docker==0.2.4
docker==5.0.0
ansible-lint==5.4.0
urllib3<2
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
cache-dependency-path: "${{ github.workspace }}/requirements.txt"
- name: Install test dependencies.
run: |
# workaround for https://github.com/yaml/pyyaml/issues/724
pip3 install 'wheel==0.40.0'
pip3 install 'Cython<3.0' 'PyYaml~=5.0' --no-build-isolation
pip3 install --use-pep517 -r ${GITHUB_WORKSPACE}/requirements.txt
- name: Run Molecule tests.
run: molecule --base-config ./molecule/config/docker.yml test --all
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
windows-test:
name: Windows Test
needs: lint
# Need to run on macos-12 since it is the only image with native support for ansible, vagrant, and virtualbox.
# https://docs.ansible.com/ansible/latest/os_guide/windows_faq.html#windows-faq-ansible
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
runs-on: macos-12
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
ansible:
- ansible~=2.10.0
- ansible~=6.0
- ansible~=7.0
distro:
- "2012"
- "2016"
- "2019"
- "2022"
scenario:
- default
- custom_vars
- with_instrumentation
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- uses: DamianReeves/write-file-action@v1.2
with:
path: "${{ github.workspace }}/requirements.txt"
contents: |
${{ matrix.ansible }}
ansible-compat==2.2.7
ansible-lint==5.4.0
molecule==4.0.4
molecule-vagrant==2.0.0
pywinrm==0.4.3
- name: Set up Python 3.
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
cache-dependency-path: "${{ github.workspace }}/requirements.txt"
- name: Install test dependencies.
run: pip3 install --use-pep517 -r ${GITHUB_WORKSPACE}/requirements.txt
- name: Run Molecule tests.
run: molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }}
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
push-release-tag:
name: Push Release Tag
needs: lint
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read current version of the Ansible Collection
id: read-galaxy-yaml
uses: cumulusds/get-yaml-paths-action@v1
with:
file: deployments/ansible/galaxy.yml
version: version
- name: Ensure version is fetched from galaxy.yml
if: steps.read-galaxy-yaml.outputs.version == ''
run: echo "Fail to read version from galaxy.yml" && exit 1
- name: Push new release tag if it doesn't exist
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tagRef = "tags/ansible-v${{ steps.read-galaxy-yaml.outputs.version }}"
const existingRefs = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: tagRef
})
if (existingRefs.data.length === 0) {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/" + tagRef,
sha: context.sha
})
} else {
console.log(tagRef + " already exists")
}