chore: add tests and lint checks #103
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: Gold TA CI | |
on: | |
push: | |
branches: | |
- "main" | |
- "develop" | |
pull_request: | |
branches: | |
- "**" | |
workflow_dispatch: | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: pre-commit/[email protected] | |
build: | |
needs: | |
- pre-commit | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.7" | |
- run: | | |
python3 -m venv .venv | |
source .venv/bin/activate | |
- run: pip install -r requirements-dev.txt | |
- run: ucc-gen build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Splunk_TA_Example-raw-output | |
path: output/* | |
# Taken from https://github.com/splunk/addonfactory-ucc-generator-action/blob/main/action.yml. | |
# Should resolve `check_for_expansive_permissions` check from AppInspect CLI. | |
- run: chmod -R +r output | |
shell: bash | |
- run: chmod -R go-w output | |
shell: bash | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: output | |
path: output/ | |
- run: ucc-gen package --path output/Splunk_TA_Example | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Splunk_TA_Example | |
path: Splunk_TA_Example*.tar.gz | |
ui-checks: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
working-directory: ui | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
cache: 'npm' | |
cache-dependency-path: 'ui/package-lock.json' | |
node-version-file: 'ui/package.json' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Code lint | |
run: npm run lint | |
- name: Unit tests | |
run: npm run test | |
splunk-appinspect-cli: | |
name: splunk-appinspect-cli ${{ matrix.tags }} | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
tags: | |
- "cloud" | |
- "appapproval" | |
- "deprecated_feature" | |
- "developer_guidance" | |
- "future" | |
- "self-service" | |
- "splunk_appinspect" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: Splunk_TA_Example | |
path: build/package | |
- uses: splunk/[email protected] | |
with: | |
app_path: build/package | |
included_tags: ${{ matrix.tags }} | |
psa-test: | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
permissions: | |
actions: read | |
deployments: read | |
contents: read | |
packages: read | |
statuses: read | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.7" | |
- uses: actions/download-artifact@v4 | |
with: | |
name: Splunk_TA_Example-raw-output | |
path: psa-output/ | |
- run: | | |
./scripts/run_splunk.sh | |
until curl -Lsk "https://localhost:8088/services/collector/health" &>/dev/null ; do echo -n "Waiting for HEC-" && sleep 5 ; done | |
timeout-minutes: 5 | |
- name: Set up virtual environment | |
run: | | |
python3 -m venv .venv | |
source .venv/bin/activate | |
- run: pip install --no-cache-dir -r requirements-dev.txt | |
- name: Run PSA knowledge tests | |
run : | | |
sudo chown -R runner:runner psa-output/Splunk_TA_Example/ | |
chmod u+rwx psa-output/Splunk_TA_Example/ | |
pytest --splunk-type=external --splunk-app=package/ --splunk-data-generator=tests/knowledge --splunk-host=localhost --splunk-port=8089 --splunk-user=admin --splunk-password=Chang3d! --splunk-hec-token=4a8a737d-5452-426c-a6f7-106dca4e813f | |
- name: Set output if steps failed | |
run: | | |
echo "failed=${{ env.failed }}" >> $GITHUB_ENV | |
outputs: | |
failed: ${{ env.failed }} |