Skip to content

chore: upgrade to 4.4.0 #12

chore: upgrade to 4.4.0

chore: upgrade to 4.4.0 #12

Workflow file for this run

name: Test Quant Cloud Init Action
# Tests the quant-cloud-init-action with various scenarios:
# - Valid credentials and main branch logic
# - Invalid credentials (expected failures)
# - Non-existent applications (warnings)
# - Override functionality (app, environment, master branch)
# - Feature branch logic (unique environments and image tags)
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
paths:
- 'src/**'
- '.github/workflows/test.yml'
- 'package.json'
- 'package-lock.json'
jobs:
test:
runs-on: ubuntu-latest
services:
quant-mock-api:
image: ghcr.io/quantcdn/quant-mock-api:4.4.0
ports:
- 4010:4010
strategy:
matrix:
test-scenario: [
'valid-credentials',
'invalid-api-key',
'invalid-organization',
'non-existent-application',
'test-overrides'
]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build with ncc
run: npx ncc build src/index.ts
- name: Debug Action Files
run: |
ls -la
ls -la dist/
cat action.yml
- name: Test Valid Credentials
if: matrix.test-scenario == 'valid-credentials'
uses: ./
id: init-valid
with:
quant_api_key: ${{ secrets.QUANT_API_KEY }}
quant_organization: 'quant'
base_url: 'http://quant-mock-api:4010'
continue-on-error: false
- name: Test Invalid API Key (Expected Failure)
if: matrix.test-scenario == 'invalid-api-key'
uses: ./
id: init-invalid-key
with:
quant_api_key: 'invalid-key-12345'
quant_organization: 'quant'
base_url: 'http://quant-mock-api:4010'
continue-on-error: true
- name: Test Invalid Organization (Expected Failure)
if: matrix.test-scenario == 'invalid-organization'
uses: ./
id: init-invalid-org
with:
quant_api_key: ${{ secrets.QUANT_API_KEY }}
quant_organization: 'non-existent-org-12345'
base_url: 'http://quant-mock-api:4010'
continue-on-error: true
- name: Test Non-Existent Application (Expected Warning)
if: matrix.test-scenario == 'non-existent-application'
uses: ./
id: init-no-app
with:
quant_api_key: ${{ secrets.QUANT_API_KEY }}
quant_organization: 'quant'
quant_application: 'non-existent-app-12345'
base_url: 'http://quant-mock-api:4010'
continue-on-error: false
- name: Test Overrides
if: matrix.test-scenario == 'test-overrides'
uses: ./
id: init-overrides
with:
quant_api_key: ${{ secrets.QUANT_API_KEY }}
quant_organization: 'quant'
quant_application: 'test-override-app'
environment_name_override: 'staging'
master_branch_override: 'develop'
base_url: 'http://quant-mock-api:4010'
continue-on-error: false
- name: Test Feature Branch Logic (with overrides)
if: matrix.test-scenario == 'test-overrides'
uses: ./
id: init-feature-branch
with:
quant_api_key: ${{ secrets.QUANT_API_KEY }}
quant_organization: 'quant'
quant_application: 'feature-test-app'
# Simulate feature branch by overriding environment name
environment_name_override: 'feature-my-big-feature'
base_url: 'http://quant-mock-api:4010'
continue-on-error: false
- name: Validate Valid Credentials Outputs
if: matrix.test-scenario == 'valid-credentials'
run: |
echo "=== VALID CREDENTIALS TEST RESULTS ==="
echo "Project exists: ${{ steps.init-valid.outputs.project_exists }}"
echo "Environment exists: ${{ steps.init-valid.outputs.environment_exists }}"
echo "Application: ${{ steps.init-valid.outputs.quant_application }}"
echo "Environment: ${{ steps.init-valid.outputs.environment_name }}"
echo "Is production: ${{ steps.init-valid.outputs.is_production }}"
echo "Stripped endpoint: ${{ steps.init-valid.outputs.stripped_endpoint }}"
echo "Image suffix: ${{ steps.init-valid.outputs.image_suffix }}"
# Validate expected values for main branch
if [[ "${{ steps.init-valid.outputs.environment_name }}" != "production" ]]; then
echo "❌ Expected environment 'production', got '${{ steps.init-valid.outputs.environment_name }}'"
exit 1
fi
if [[ "${{ steps.init-valid.outputs.is_production }}" != "true" ]]; then
echo "❌ Expected is_production 'true', got '${{ steps.init-valid.outputs.is_production }}'"
exit 1
fi
if [[ "${{ steps.init-valid.outputs.image_suffix }}" != "-latest" ]]; then
echo "❌ Expected image_suffix '-latest', got '${{ steps.init-valid.outputs.image_suffix }}'"
exit 1
fi
echo "✅ Valid credentials test passed"
- name: Validate Invalid API Key Failure
if: matrix.test-scenario == 'invalid-api-key'
run: |
echo "=== INVALID API KEY TEST RESULTS ==="
if [[ "${{ steps.init-invalid-key.outcome }}" == "failure" ]]; then
echo "✅ Invalid API key correctly failed as expected"
else
echo "❌ Invalid API key should have failed but didn't"
exit 1
fi
- name: Validate Invalid Organization Failure
if: matrix.test-scenario == 'invalid-organization'
run: |
echo "=== INVALID ORGANIZATION TEST RESULTS ==="
if [[ "${{ steps.init-invalid-org.outcome }}" == "failure" ]]; then
echo "✅ Invalid organization correctly failed as expected"
else
echo "❌ Invalid organization should have failed but didn't"
exit 1
fi
- name: Validate Non-Existent Application Warning
if: matrix.test-scenario == 'non-existent-application'
run: |
echo "=== NON-EXISTENT APPLICATION TEST RESULTS ==="
echo "Project exists: ${{ steps.init-no-app.outputs.project_exists }}"
echo "Application: ${{ steps.init-no-app.outputs.quant_application }}"
if [[ "${{ steps.init-no-app.outputs.project_exists }}" == "false" ]]; then
echo "✅ Non-existent application correctly identified as not existing"
else
echo "❌ Non-existent application should show project_exists=false"
exit 1
fi
if [[ "${{ steps.init-no-app.outputs.quant_application }}" == "non-existent-app-12345" ]]; then
echo "✅ Application name correctly set to provided value"
else
echo "❌ Application name should match provided value"
exit 1
fi
echo "✅ Non-existent application test passed"
- name: Validate Overrides
if: matrix.test-scenario == 'test-overrides'
run: |
echo "=== OVERRIDES TEST RESULTS ==="
echo "Application: ${{ steps.init-overrides.outputs.quant_application }}"
echo "Environment: ${{ steps.init-overrides.outputs.environment_name }}"
echo "Is production: ${{ steps.init-overrides.outputs.is_production }}"
# Test quant_application override
if [[ "${{ steps.init-overrides.outputs.quant_application }}" != "test-override-app" ]]; then
echo "❌ Expected application 'test-override-app', got '${{ steps.init-overrides.outputs.quant_application }}'"
exit 1
fi
# Test environment_name_override
if [[ "${{ steps.init-overrides.outputs.environment_name }}" != "staging" ]]; then
echo "❌ Expected environment 'staging', got '${{ steps.init-overrides.outputs.environment_name }}'"
exit 1
fi
# Test master_branch_override (should affect is_production)
if [[ "${{ steps.init-overrides.outputs.is_production }}" != "false" ]]; then
echo "❌ Expected is_production 'false' with master_branch_override='develop', got '${{ steps.init-overrides.outputs.is_production }}'"
exit 1
fi
# Test image suffix with overrides
# When environment is overridden, image suffix should match the environment name
if [[ "${{ steps.init-overrides.outputs.image_suffix }}" != "-staging" ]]; then
echo "❌ Expected image_suffix '-staging' with environment_name_override='staging', got '${{ steps.init-overrides.outputs.image_suffix }}'"
exit 1
fi
echo "✅ All overrides test passed"
- name: Validate Feature Branch Logic
if: matrix.test-scenario == 'test-overrides'
run: |
echo "=== FEATURE BRANCH LOGIC TEST RESULTS ==="
echo "Application: ${{ steps.init-feature-branch.outputs.quant_application }}"
echo "Environment: ${{ steps.init-feature-branch.outputs.environment_name }}"
echo "Is production: ${{ steps.init-feature-branch.outputs.is_production }}"
echo "Image suffix: ${{ steps.init-feature-branch.outputs.image_suffix }}"
# Test feature branch environment name
if [[ "${{ steps.init-feature-branch.outputs.environment_name }}" != "feature-my-big-feature" ]]; then
echo "❌ Expected environment 'feature-my-big-feature', got '${{ steps.init-feature-branch.outputs.environment_name }}'"
exit 1
fi
# Test feature branch image suffix (should match environment name)
if [[ "${{ steps.init-feature-branch.outputs.image_suffix }}" != "-feature-my-big-feature" ]]; then
echo "❌ Expected image_suffix '-feature-my-big-feature', got '${{ steps.init-feature-branch.outputs.image_suffix }}'"
exit 1
fi
# Test that feature branches are not production
if [[ "${{ steps.init-feature-branch.outputs.is_production }}" != "false" ]]; then
echo "❌ Expected is_production 'false' for feature branch, got '${{ steps.init-feature-branch.outputs.is_production }}'"
exit 1
fi
echo "✅ Feature branch logic test passed"
- name: Test Summary
run: |
echo "=== TEST SUMMARY ==="
echo "Test scenario: ${{ matrix.test-scenario }}"
echo "Job status: ${{ job.status }}"
echo "Step outcomes:"
echo " - Valid credentials: ${{ steps.init-valid.outcome || 'N/A' }}"
echo " - Invalid API key: ${{ steps.init-invalid-key.outcome || 'N/A' }}"
echo " - Invalid org: ${{ steps.init-invalid-org.outcome || 'N/A' }}"
echo " - Non-existent app: ${{ steps.init-no-app.outcome || 'N/A' }}"
echo " - Overrides: ${{ steps.init-overrides.outcome || 'N/A' }}"
echo " - Feature branch logic: ${{ steps.init-feature-branch.outcome || 'N/A' }}"