-
Notifications
You must be signed in to change notification settings - Fork 17
144 lines (133 loc) · 4.38 KB
/
ssc-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
138
139
140
141
142
143
144
name: SSC test
on:
workflow_dispatch:
inputs:
owner:
description: 'SC4S repository owner'
required: false
default: 'splunk'
type: string
repo:
description: 'SC4S repository'
required: false
default: 'splunk-connect-for-syslog'
type: string
ref:
description: 'SC4S ref (branch, tag, commit id)'
required: false
type: string
syslog-ng-image-version:
description: 'syslog-ng image version'
required: false
default: 'latest'
type: string
workflow_call:
inputs:
owner:
description: 'SC4S repository owner'
required: false
default: 'splunk'
type: string
repo:
description: 'SC4S repository'
required: false
default: 'splunk-connect-for-syslog'
type: string
ref:
description: 'SC4S ref (branch, tag, commit id)'
required: false
type: string
syslog-ng-image-version:
description: 'syslog-ng image version'
required: false
default: 'latest'
type: string
pull_request:
paths:
- 'ssc/**'
- '.github/workflows/**'
push:
paths:
- 'ssc/**'
- '.github/workflows/**'
env:
SC4S_OWNER: ${{ inputs.owner || 'splunk' }}
SC4S_REPO: ${{ inputs.repo || 'splunk-connect-for-syslog' }}
SYSLOG_NG_IMG_VERSION: ${{ inputs.syslog-ng-image-version || 'latest' }}
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.ref }}
steps:
- name: Detect SC4S version
id: version
uses: actions/github-script@v6
with:
script: |
const input_ref = '${{ inputs.ref }}';
if (input_ref) {
console.log('Version from workflow input: ' + input_ref);
core.setOutput('ref', input_ref);
return;
}
const { SC4S_OWNER, SC4S_REPO } = process.env;
const latest_release = await github.rest.repos.getLatestRelease({
owner: SC4S_OWNER,
repo: SC4S_REPO,
});
if (!/^v[0-9]/.test(latest_release.data.tag_name)) {
core.setFailed('Latest release tag mismatch');
return;
}
console.log('Version (latest): ' + latest_release.data.tag_name);
core.setOutput('ref', latest_release.data.tag_name)
build-and-test:
runs-on: ubuntu-latest
needs: version
services:
splunk:
image: splunk/splunk:latest
ports:
- 8000:8000
- 8088:8088
- 8089:8089
env:
SPLUNK_HEC_TOKEN: 70b6ae71-76b3-4c38-9597-0c5b37ad9630
SPLUNK_PASSWORD: Changed@11
SPLUNK_START_ARGS: --accept-license
SPLUNK_APPS_URL: https://github.com/splunk/splunk-configurations-base-indexes/releases/download/v1.0.0/splunk_configurations_base_indexes-1.0.0.tar.gz
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Checkout SC4S source
uses: actions/checkout@v3
with:
repository: ${{ env.SC4S_OWNER }}/${{ env.SC4S_REPO }}
ref: ${{ needs.version.outputs.version }}
path: ssc/splunk-connect-for-syslog
- name: Build and export Docker image
uses: docker/build-push-action@v5
with:
context: ssc/splunk-connect-for-syslog
file: ssc/splunk-connect-for-syslog/package/Dockerfile
load: true
tags: ssc:test
build-args: |
SYSLOGNG_VERSION=${{ env.SYSLOG_NG_IMG_VERSION }}
REVISION=${{ needs.version.outputs.version }}
- name: Smoke test
working-directory: ssc/splunk-connect-for-syslog
run: |
docker run -d --network host \
-e SC4S_DEST_SPLUNK_HEC_DEFAULT_URL="https://127.0.0.1:8088" \
-e SC4S_DEST_SPLUNK_HEC_DEFAULT_TOKEN="70b6ae71-76b3-4c38-9597-0c5b37ad9630" \
-e SC4S_DEST_SPLUNK_HEC_DEFAULT_TLS_VERIFY="no" \
-e SC4S_DEBUG_CONTAINER="yes" \
ssc:test
pip3 install poetry
#workaround for https://github.com/yaml/pyyaml/issues/728
poetry add pyyaml@5.3.1
poetry install
poetry run pytest -v -n8 --splunk_type=external --splunk_hec_token=70b6ae71-76b3-4c38-9597-0c5b37ad9630 \
tests/test_loggen.py