forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (118 loc) · 4.17 KB
/
chef-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
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
name: chef-test
# Only run tests if there are relevant changes
on:
push:
branches:
- main
paths:
- '.github/workflows/chef-test.yml'
- 'deployments/chef/**'
- '!**.md'
pull_request:
paths:
- '.github/workflows/chef-test.yml'
- 'deployments/chef/**'
- '!**.md'
schedule:
- cron: '0 0 * * 2,5' # Every Tuesday and Friday at midnight UTC
concurrency:
group: chef-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: 'deployments/chef'
env:
CHEF_VERSION: "22.12.1024"
CHEF_LICENSE: accept
jobs:
chef-lint-spec-test:
name: chef-lint-spec-test
# 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: lint
run: make lint
- name: Rake spec
run: |
make rake-spec
chef-kitchen-matrix:
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Get linux distros and suites
id: get-linux-matrix
run: |
distros=$(yq '[.platforms[] | "\"" + (.name | sub("_", "-") | sub("\.", "")) + "\""] | join(", ")' kitchen.yml)
if [ -z "$distros" ]; then
echo "Failed to get platforms from kitchen.yml!" >&2
exit 1
fi
echo "matrix={'DISTRO': [${distros}]}" >> $GITHUB_OUTPUT
- name: Get windows distros and suites
id: get-win-matrix
run: |
distros=$(yq '[.platforms[] | "\"" + (.name | sub("_", "-") | sub("\.", "")) + "\""] | join(", ")' kitchen.windows.yml)
if [ -z "$distros" ]; then
echo "Failed to get platforms from kitchen.windows.yml!" >&2
exit 1
fi
suites=$(yq '[.suites[] | "\"" + (.name | sub("_", "-") | sub("\.", "")) + "\""] | join(", ")' kitchen.windows.yml)
if [ -z "$suites" ]; then
echo "Failed to get suites from kitchen.windows.yml!" >&2
exit 1
fi
echo "matrix={'DISTRO': [${distros}], 'SUITE': [${suites}]}" >> $GITHUB_OUTPUT
outputs:
linux-matrix: ${{ steps.get-linux-matrix.outputs.matrix }}
win-matrix: ${{ steps.get-win-matrix.outputs.matrix }}
chef-kitchen-linux:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: [chef-lint-spec-test, chef-kitchen-matrix]
strategy:
matrix: ${{ fromJSON(needs.chef-kitchen-matrix.outputs.linux-matrix) }}
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install chef
uses: actionshub/chef-install@3.0.0
with:
version: ${{ env.CHEF_VERSION }}
- run: kitchen test ${{ matrix.DISTRO }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.DISTRO }}
path: deployments/chef/.kitchen/logs/*
chef-kitchen-windows:
runs-on: ${{ matrix.DISTRO }}
needs: [chef-lint-spec-test, chef-kitchen-matrix]
strategy:
matrix: ${{ fromJSON(needs.chef-kitchen-matrix.outputs.win-matrix) }}
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install chef
uses: actionshub/chef-install@3.0.0
with:
version: ${{ env.CHEF_VERSION }}
- name: Install kitchen-docker
run: chef gem install kitchen-docker -v 2.12.0
- name: kitchen test ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
run: |
kitchen test ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
# For some reason, kitchen returns 0 here even if there are test failures, so check the log instead.
grep -q '0 failures' .kitchen/logs/kitchen.log || exit 1
shell: bash
env:
KITCHEN_YAML: kitchen.windows.yml
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.SUITE }}-${{ matrix.DISTRO }}
path: deployments/chef/.kitchen/logs/*