-
Notifications
You must be signed in to change notification settings - Fork 6
142 lines (123 loc) · 4.86 KB
/
tests.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
name: tests
on:
pull_request:
branches:
- master
- develop
jobs:
slim-validate:
name: SLIM Validation
runs-on: ubuntu-latest
outputs:
app_name: ${{ steps.appinfo.outputs.app_name }}
app_id: ${{ steps.appinfo.outputs.app_id }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch and set app info
id: appinfo
run: |
APP_ID=$(cat packages/splunk-*/app.manifest | jq -r '.info.id.name')
echo "app_id=${APP_ID}" >> $GITHUB_OUTPUT
APP_NAME=$(echo "$APP_ID" | tr _ - )
echo "app_name=${APP_NAME}" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install splunk-packaging-toolkit
- name: Slim Validate
run: |
cp README.md packages/${{ steps.appinfo.outputs.app_id }}
slim validate packages/${{ steps.appinfo.outputs.app_id }}
splunk-test:
name: Deploy and test the Viz
runs-on: ubuntu-latest
needs: slim-validate
strategy:
matrix:
version: [9.1]
# version: [9.1, 9.0, 8.2.0]
services:
splunk:
image: splunk/splunk:${{ matrix.version }}
env:
SPLUNK_START_ARGS: --answer-yes --no-prompt --accept-license
SPLUNK_PASSWORD: password
SPLUNK_APPS_URL: https://splunkbase.splunk.com/app/2890/release/5.4.1/download
# TODO add the installation of the other dependency
# ,https://splunkbase.splunk.com/app/2882/release/4.2.0/download
SPLUNKBASE_USERNAME: ${{ secrets.SPLUNKBASE_USERNAME }}
SPLUNKBASE_PASSWORD: ${{ secrets.SPLUNKBASE_PASSWORD }}
DEBUG: true
options: >-
--health-interval 30s
--health-timeout 5s
--health-retries 5
--name splunk
ports:
- 8000:8000
- 8089:8089
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Copy app to service container and validate
# NOTE using volume mapping to add the app to the container will NOT work since checkout hasn't happened yet
run: |
docker cp packages/${{ needs.slim-validate.outputs.app_id }} ${{ job.services.splunk.id }}:/opt/splunk/etc/apps/${{ needs.slim-validate.outputs.app_id }}
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/apps
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/apps/${{ needs.slim-validate.outputs.app_id }}
- name: Disable SPL safeguards for all commands
run: |
cat >> web.conf << 'END'
[settings]
enable_risky_command_check = 0
enable_risky_command_check_dashboard = 0
END
docker cp web.conf ${{ job.services.splunk.id }}:/opt/splunk/etc/system/local/web.conf
echo "Validating 'web.conf' file creation"
docker exec -i ${{ job.services.splunk.id }} ls -a /opt/splunk/etc/system/local/
- name: Set container IP as env variable
run: |
echo "SPLUNK_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${{ job.services.splunk.id }})" >> $GITHUB_ENV
- name: Restart instance
run: |
curl -k -u admin:password https://$SPLUNK_IP:8089/services/server/control/restart -X POST
sleep 30
- name: Configure MLTK permissions
run: |
curl --retry-delay 5 --retry 5 -f -k -u admin:password https://$SPLUNK_IP:8089/services/apps/local/Splunk_ML_Toolkit/acl -d sharing=global -d owner=nobody -X POST
echo "Check MLTK permissions"
curl -k -u admin:password https://$SPLUNK_IP:8089/services/apps/local/Splunk_ML_Toolkit/acl?output_mode=json | jq -r '.entry | .[].acl.sharing'
- name: Print App Configuration
run: |
curl -k -u admin:password https://$SPLUNK_IP:8089/services/apps/local/${{ needs.slim-validate.outputs.app_id }}
- name: Run Tests
run: |
echo "Removing package-lock to avoid issues with splunk artifactory"
rm -rf test/package-lock.json
# echo "Running tests"
# make tests
- name: Cypress run
uses: cypress-io/github-action@v6
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: splunk${{ matrix.versions }}-results
path: |
test/cypress/videos
- name: JUnit Report
uses: dorny/test-reporter@v1
# if: always()
with:
name: Cypress Tests
path: cypress/results/results.xml
reporter: java-junit
fail-on-error: true