dedup yaml

This commit is contained in:
2025-07-29 17:01:32 -05:00
parent 6e8e67f560
commit 3ce7ccc6be
2 changed files with 23 additions and 42 deletions
+14 -41
View File
@@ -4,7 +4,7 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
environment: environment:
description: "Environment to deploy to" description: "Target environment"
required: true required: true
default: "testing" default: "testing"
type: choice type: choice
@@ -14,13 +14,13 @@ on:
- production - production
jobs: jobs:
testing: # YAML anchor for common job configuration
if: github.event.inputs.environment == 'testing' .integration-test: &integration-test
runs-on: general runs-on: general
container: container:
image: "ghcr.io/catthehacker/ubuntu:js-24.04" image: "ghcr.io/catthehacker/ubuntu:js-24.04"
environment: testing env:
TARGET_ENVIRONMENT: ${{ github.event.inputs.environment }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -30,49 +30,22 @@ jobs:
apt-get update apt-get update
apt-get install -y python3-pytest python3-requests apt-get install -y python3-pytest python3-requests
- name: Run test (Testing) - name: Run integration tests
run: | run: |
echo "Running integration tests for TESTING environment" echo "Running integration tests for ${TARGET_ENVIRONMENT^^} environment"
pytest run_test.py pytest run_test.py
testing:
if: github.event.inputs.environment == 'testing'
environment: testing
<<: *integration-test
staging: staging:
if: github.event.inputs.environment == 'staging' if: github.event.inputs.environment == 'staging'
runs-on: general
container:
image: "ghcr.io/catthehacker/ubuntu:js-24.04"
environment: staging environment: staging
<<: *integration-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
apt-get update
apt-get install -y python3-pytest python3-requests
- name: Run test (Staging)
run: |
echo "Running integration tests for STAGING environment"
pytest run_test.py
production: production:
if: github.event.inputs.environment == 'production' if: github.event.inputs.environment == 'production'
runs-on: general
container:
image: "ghcr.io/catthehacker/ubuntu:js-24.04"
environment: production environment: production
<<: *integration-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
apt-get update
apt-get install -y python3-pytest python3-requests
- name: Run test (Production)
run: |
echo "Running integration tests for PRODUCTION environment"
pytest run_test.py
+9 -1
View File
@@ -1,3 +1,4 @@
import os
import pytest import pytest
import requests import requests
@@ -11,7 +12,13 @@ def test_health_endpoint():
- The response is valid JSON - The response is valid JSON
- The response contains results.message == "ok" - The response contains results.message == "ok"
""" """
url = "https://api.cleverbrag.epsilon.cleverthis.com/v3/health" urls = {
"testing": "https://api.cleverbrag.epsilon.cleverthis.com",
"staging": "https://api.cleverbrag.delta.cleverthis.com",
"production": "https://api.cleverbrag.cleverthis.com",
}
url = urls[os.getenv("TARGET_ENVIRONMENT")]
# Make the HTTP request # Make the HTTP request
response = requests.get(url) response = requests.get(url)
@@ -35,6 +42,7 @@ def test_health_endpoint():
if __name__ == "__main__": if __name__ == "__main__":
print(f"Running pytest in {TARGET_ENVIRONMENT}")
# Allow running the test directly with python run_test.py # Allow running the test directly with python run_test.py
test_health_endpoint() test_health_endpoint()
print("Health endpoint test passed!") print("Health endpoint test passed!")