Major refactor #114
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.1.3] | |
version: [9.2.2, 9.1.3] | |
# 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 |