Skip to content

Infrastructure as Code Smoke Tests #17611

Infrastructure as Code Smoke Tests

Infrastructure as Code Smoke Tests #17611

name: Infrastructure as Code Smoke Tests
on:
schedule:
- cron: '0 * * * *'
release:
types: [published]
workflow_call:
inputs:
is_skip_alert:
type: boolean
required: true
default: false
jobs:
run_iac_smoke_tests:
name: Run IaC smoke tests
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v3
with:
node-version: 16.16.0
- name: Install dependencies
run: |
npm install
- name: Build Snyk CLI
run: |
npm run build:prod
- name: Run IaC smoke tests - non-Windows
id: run_smoke_tests_non_windows
if: ${{ matrix.os != 'windows' }}
env:
IAC_SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.IAC_SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_COMMAND: ${{ format('node {0}/dist/cli/index.js', github.workspace) }}
run: |
npx jest --runInBand --testPathPattern '/test/smoke(/jest)?/iac/'
- name: Run IaC smoke tests - Windows
id: run_smoke_tests_windows
if: ${{ matrix.os == 'windows' }}
shell: pwsh
env:
IAC_SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.IAC_SMOKE_TESTS_SNYK_TOKEN }}
TEST_SNYK_COMMAND: ${{ format('node {0}\dist\cli\index.js', github.workspace) }}
run: |
npx jest --runInBand --testPathPattern '/test/smoke(/jest)?/iac/'
trigger_iac_cli_alert:
name: Alert for failed IaC smoke tests
needs: [run_iac_smoke_tests]
if: ${{ failure() && !inputs.is_skip_alert && needs.run_iac_smoke_tests.result == 'failure' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/iac-cli-alert
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: '16.16.0'
cache: 'npm'
- run: npm ci
- run: npm start
env:
IAC_SMOKE_TESTS_SLACK_WEBHOOK_URL: ${{ secrets.IAC_SMOKE_TESTS_SLACK_WEBHOOK_URL }}