Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/actions/db-inserts-verify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run report and verify inserts
description: Runs a command, parses ROWS_INSERTED=N, and enforces zero policy

inputs:
report_name:
description: Logical name of the report (for messages)
required: true
run:
description: Shell command to run the report (must print ROWS_INSERTED=N)
required: true
zero_ok:
description: 'Allow zero inserts without failing (true/false)'
required: false
default: 'false'
parse_regex:
description: RegEx to capture ROWS_INSERTED=NNN (advanced override)
required: ''
default: 'ROWS_INSERTED\s*=\s*([0-9]+)'

runs:
using: composite
steps:
- name: Run report
id: runreport
shell: bash
run: |
set -euo pipefail
echo "[verify] running: ${{ inputs.run }}"
bash -lc '${{ inputs.run }}' 2>&1 | tee report.out


# Pick regex
regex='ROWS_INSERTED=([0-9]+)'

# Find last match
count="$(grep -Eo "${{ inputs.parse_regex }}" report.out | sed -E 's/.*=([0-9]+).*/\1/' | tail -n1 || true)"
if [[ -z "${count:-}" ]]; then count=0; fi
echo "rows_inserted=${count}" >> "$GITHUB_OUTPUT"

- name: Show parsed count
shell: bash
run: echo "[verify] parsed rows_inserted=${{ steps.runreport.outputs.rows_inserted }}"

- name: Enforce non-zero inserts
if: steps.runreport.outputs.rows_inserted == '0' && inputs.zero_ok != 'true'
shell: bash
run: |
echo "::error::Report '${{ inputs.report_name }}' expected inserts but got 0"
echo "[verify] rows_inserted=0; showing last 200 lines of report.out for debugging"
tail -n 200 report.out || true
exit 1

- name: Diagnostic (zero allowed)
if: steps.runreport.outputs.rows_inserted == '0' && inputs.zero_ok == 'true'
shell: bash
run: |
echo "::warning::Report '${{ inputs.report_name }}' inserted 0 rows (allowed)"
echo "[verify] rows_inserted=0; showing last 100 lines of report.out for context"
tail -n 100 report.out || true
75 changes: 75 additions & 0 deletions .github/workflows/demo-db-insert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Demo - Verify DB insert / delete

on:
pull_request:
push:
branches:
- rpapa-db-verify
workflow_dispatch:
inputs:
branchName:
description: 'Default branch'
required: true
default: 'master'

jobs:
deploy:
name: Demo - Verify DB insert / delete
runs-on: ubuntu-latest

steps:
- name: Check out source repository
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Establish Cloud SQL Proxy
uses: mattes/gce-cloudsql-proxy-action@v1
with:
creds: ${{ secrets.GCLOUD_AUTH }}
instance: ${{ secrets.CLOUD_SQL_CONNECTION_NAME }}
port: ${{ secrets.CLOUD_SQL_DATABASE_PORT }}

- name: Install requirements
run: |
pip install -r requirements.txt

- name: Set env vars
run: |
echo "CLOUD_SQL_DATABASE_USERNAME=${{ secrets.CLOUD_SQL_DATABASE_USERNAME }}" >> $GITHUB_ENV
echo "CLOUD_SQL_DATABASE_PASSWORD=${{ secrets.CLOUD_SQL_DATABASE_PASSWORD }}" >> $GITHUB_ENV
echo "CLOUD_SQL_DATABASE_NAME=preflight" >> $GITHUB_ENV
echo "CLOUD_SQL_DATABASE_PORT=${{ secrets.CLOUD_SQL_DATABASE_PORT }}" >> $GITHUB_ENV
echo "TESTRAIL_HOST=${{ secrets.TESTRAIL_HOST }}" >> $GITHUB_ENV
echo "TESTRAIL_USERNAME=${{ secrets.TESTRAIL_USERNAME }}" >> $GITHUB_ENV
echo "TESTRAIL_PASSWORD=${{ secrets.TESTRAIL_PASSWORD }}" >> $GITHUB_ENV
echo "ATLASSIAN_API_TOKEN=${{ secrets.ATLASSIAN_API_TOKEN }}" >> $GITHUB_ENV
echo "ATLASSIAN_HOST=${{ secrets.ATLASSIAN_HOST }}" >> $GITHUB_ENV
echo "ATLASSIAN_USERNAME=${{ secrets.ATLASSIAN_USERNAME }}" >> $GITHUB_ENV
echo "JIRA_HOST=${{ secrets.JIRA_HOST }}" >> $GITHUB_ENV
echo "JIRA_USER=${{ secrets.JIRA_USER }}" >> $GITHUB_ENV
echo "JIRA_PASSWORD=${{ secrets.JIRA_PASSWORD }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "BUGZILLA_API_KEY=${{ secrets.BUGZILLA_API_KEY }}" >> $GITHUB_ENV
echo "BITRISE_HOST=${{ secrets.BITRISE_HOST }}" >> $GITHUB_ENV
echo "BITRISE_APP_SLUG=${{ secrets.BITRISE_APP_SLUG }}" >> $GITHUB_ENV
echo "BITRISE_TOKEN=${{ secrets.BITRISE_TOKEN }}" >> $GITHUB_ENV
echo "SENTRY_HOST=${{ secrets.SENTRY_HOST }}" >> $GITHUB_ENV
echo "SENTRY_API_TOKEN=${{ secrets.SENTRY_API_TOKEN_CSO }}" >> $GITHUB_ENV
echo "SENTRY_ORGANIZATION_SLUG=${{ secrets.SENTRY_ORGANIZATION_SLUG }}" >> $GITHUB_ENV
echo "SENTRY_PROJECT_ID=${{ secrets.SENTRY_PROJECT_ID }}" >> $GITHUB_ENV

# TestRail
- name: Mobile Test Case Coverage & DB verify
uses: ./.github/actions/db-inserts-verify
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is to demo how this works and if it will fill our needs for DB insert validation.
I have coded this for on push to a personal branch but this is temporary and can be changed.
The idea is to remove this demo workflow altogether but add these few lines to our other workflows where DB validation is required

with:
report_name: Mobile Test Case Coverage
run: python ./__main__.py --report-type testrail-test-case-coverage --platform mobile --project ALL
zero_ok: 'false'

#- name: Mobile testrail milestones
# run: python3 ./__main__.py --platform mobile --project ALL --report-type testrail-milestones

Loading