LinterURL fix #866
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: PR Check - Integration Tests | ||
on: | ||
push: | ||
branches: [choreo] | ||
pull_request: | ||
branches: [choreo] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
USER_SOURCE_REPO: VirajSalaka/proxy-from-gh | ||
MAX_HEAP: 2048m | ||
MIN_HEAP: 512m | ||
APIM_ENDPOINT: https://sts.preview-dv.choreo.dev | ||
RUDDER_ENDPOINT: http://dp-rudder | ||
SUB_PATH: adminService | ||
ORG_UUID: e615dff6-6691-4cec-96af-45be2a11a2ca | ||
LINTER_ENDPOINT: undefined | ||
LINTER_URL: undefined | ||
SERVICE_SOURCE_DIR: proxy-dir | ||
COMPONENT_ID: 5f7ad903-54ab-4724-aa4b-5cedf8604c88 | ||
PROJECT_ID: 01fe8d09-0f76-458a-b40f-d15afbc69f8c | ||
CP_GW_ENDPOINT: https://apis.preview-dv.choreo.dev | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install python dependencies | ||
id: "install_python_deps" | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install tabulate | ||
- name: Echo string | ||
id: "validate_linting" | ||
run: |- | ||
Check failure on line 35 in .github/workflows/main.yml GitHub Actions / PR Check - Integration TestsInvalid workflow file
|
||
sleep 3 | ||
LINTER_URL="${{env.CP_GW_ENDPOINT}}/governance/v1.0/projects/${{env.PROJECT_ID}}/components/${{env.COMPONENT_ID}}/endpoints/${{env.COMPONENT_ID}}/rule-adherence" >> $GITHUB_OUTPUT | ||
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X GET "${{LINTER_URL}}" -H "Authorization: Bearer ${{github.events.inputs.userToken}}") >> $GITHUB_OUTPUT | ||
RESPONSE=$(curl -o response.json -s -w "%{http_code}" ${LINTER_URL}) | ||
if [[ $RESPONSE != "200" ]]; then | ||
echo "Governance Validation Failed Internally" | ||
exit 1 | ||
fi | ||
cat response.json | python3 -c " | ||
import json; | ||
import sys; | ||
from tabulate import tabulate; | ||
def visualize_trivy_like_table(json_data): | ||
data = json.loads(json_data) | ||
print(\"Summary:\") | ||
print(f\" Violated rulesets: {data['summary']['ruleset']['violated']}\") | ||
print(f\" Adhered rulesets: {data['summary']['ruleset']['adhered']}\") | ||
print(f\" Total rulesets: {data['summary']['ruleset']['total']}\") | ||
print() | ||
table_data = [] | ||
for ruleset in data['list']: | ||
if ruleset['status'] == 'violated': | ||
for rule in ruleset['violatedRules']['list']: | ||
if rule['severity'] in ['error', 'warn']: | ||
severity = rule['severity'].upper() | ||
ruleset_name = ruleset['rulesetName'] | ||
# rule_id = rule['ruleId'] | ||
message = rule['message'] | ||
pathsList = [] | ||
for path in rule['paths']['list']: | ||
if len(path[2:]) <= 43: | ||
pathsList.append(path) | ||
else: | ||
pathsList.append(f\"{path[:1]}...{path[-41:]}\") | ||
paths = '\n'.join(pathsList) | ||
table_data.append([severity, ruleset_name, message, paths]) | ||
if table_data: | ||
headers = [\"SEVERITY\", \"RULESET\", \"MESSAGE\", \"PATHS\"] | ||
maxcolwidths = [10, 30, 30, None] | ||
print(tabulate(table_data, headers=headers, tablefmt=\"grid\", maxcolwidths=maxcolwidths)) | ||
else: | ||
print(\"No errors or warnings found.\") | ||
print(f\"\nTotal rulesets evaluated: {data['count']}\") | ||
json_payload = sys.stdin.read() | ||
visualize_trivy_like_table(json_payload) | ||