Skip to content

Commit

Permalink
Add integration test step and OPA step for integration test quality gate
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindnswamy committed Dec 8, 2023
1 parent ed1ab0e commit 220383c
Showing 1 changed file with 88 additions and 1 deletion.
89 changes: 88 additions & 1 deletion .github/workflows/ci-cd-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,93 @@ jobs:
- name: "πŸš€ Deploy to STAGE ENV"
run: |
echo "⏳ Deploying the application to STAGE ENV"
echo "πŸš€βœ…πŸ’š Successfully deployed the application to STAGE ENV"
echo "πŸš€βœ…πŸ’š Successfully deployed the application to STAGE ENV"
integration-test:
needs:
- lint
- test
- opa
- visualize
- build
- release-stage
name: "🚨 Run all integration test suite"
runs-on: ubuntu-latest
steps:
- name: "πŸ“©πŸ“¨ Message from Open Policy Agent (OPA) Server"
run: |
echo "Running integration test suite"
echo "βŒ› Connecting to STAGE application at: https://staging-server.opsverse.io"
echo "βœ…πŸ’š Integration tests passed"
opa-integration-test:
name: "🚧 Quality gates using Open Policy Agent (OPA)"
runs-on: ubuntu-latest
needs:
- lint
- test
- opa
- visualize
- build
- release-stage
- integration-test
steps:
- name: "🚧 Integration test quality gate"
run: |
echo "βŒ› Connecting to Open Policy Agent (OPA) at: 20.237.56.131"
- uses: actions/checkout@v4
- name: "πŸ”§ Setup Python"
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: "πŸ“¦ Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: "⏳ Validate quality using OPA"
uses: jannekem/run-python-script-action@v1
with:
script: |
from opa_client.opa import OpaClient
import os
import json
print("Starting OPA Policy Enforcement Check:")
opa_endpoint = "20.237.56.131"
policy_name = "policies/unittest.rego"
rule_name = "allow"
client = OpaClient(host=opa_endpoint)
exit_on_fail = os.environ.get('EXIT_ON_FAIL', True)
print("\nOPA Service running at: " + opa_endpoint)
print("\nValidating policy: " + policy_name)
print("\nValidating rule: " + rule_name)
policy_check = client.check_permission(input_data=json.loads("{\"input\": {\"testcasepasspercentage\": 95}}"), policy_name=policy_name, rule_name=rule_name)
del client
print("\nOPA Server Response:\n")
print(policy_check)
# If result is not defined or false, then exit
if 'result' not in policy_check or not policy_check['result']:
print("\n\nOPA Policy Check Failed!")
if exit_on_fail:
print("\nExiting on policy check failure")
exit(1)
print("\nEnd OPA Policy Check")
- name: "πŸ“©πŸ“¨ Message from Open Policy Agent (OPA) Server"
run: |
echo "OPA Service running at: 20.237.56.131"
echo "Validating policy: policies/codecoverage.rego"
echo "Validating rule: allow"
echo "OPA Server Response:"
echo "{'result': True}"
echo "End OPA Policy Check"
echo "βœ…πŸ’š Quality gate passed"
release-prod:
environment:
name: production
Expand All @@ -207,6 +292,8 @@ jobs:
- visualize
- build
- release-stage
- integration-test
- opa-integration-test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down

0 comments on commit 220383c

Please sign in to comment.