-
Notifications
You must be signed in to change notification settings - Fork 6
156 lines (136 loc) · 5.26 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: tests
on:
pull_request:
branches:
- master
- develop
permissions:
contents: read
actions: read
checks: write
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:
fail-fast: false
matrix:
version: [9.3.0, 9.2.2, 9.1.3, 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,https://splunkbase.splunk.com/app/2882/release/4.1.2/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: 20.11.1
- 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: |
docker cp assets/cicd/config/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: Tests execution prep
run: |
echo "Removing package-lock to avoid issues with splunk artifactory"
cd test
rm -rf package-lock.json
npm install
- name: Cypress run
uses: cypress-io/github-action@v6
# Set timeout to prevent hanging tasks
# NOTE: Careful! Tests timeouts can be impacted
timeout-minutes: 20
env:
DEBUG: '@cypress/github-action'
ELECTRON_EXTRA_LAUNCH_ARGS: --disable-gpu
with:
start: npm run test
wait-on: 'http://localhost:8000'
# No videos can be recorded w/ ff as per https://github.com/cypress-io/cypress/issues/18415
# browser: firefox
working-directory: test
# - name: Verify results availability
# run: |
# ls -la test/cypress/results
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: splunk${{ matrix.version }}-results
path: |
test/cypress/videos
test/cypress/screenshots
# Add a job in the page to visualize test result reports
- name: JUnit Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Cypress Tests
path: cypress/results/results-*.xml
reporter: java-junit
working-directory: test
fail-on-error: false