Skip to content

cross-repo-test

cross-repo-test #91

name: Cross-Repo System Test
on:
repository_dispatch:
types:
- cross-repo-test
jobs:
run-system-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Testing Repository
uses: actions/checkout@v3
- name: Create commit status - pending
if: github.event.client_payload.pull_request_url
run: |
PR_URL="${{ github.event.client_payload.pull_request_url }}"
REPO=$(echo "$PR_URL" | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/.*|\1|')
PR_NUMBER=$(echo "$PR_URL" | sed -E 's|.*/pull/([0-9]+).*|\1|')
echo "Fetching PR SHA for repo: $REPO, PR: $PR_NUMBER"
SHA=$(curl -s -H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/pulls/$PR_NUMBER | jq -r '.head.sha')
echo "Creating pending status for SHA: $SHA"
curl -X POST \
-H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/statuses/$SHA \
-d "{
\"state\": \"pending\",
\"target_url\": \"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",
\"description\": \"E2E system tests running...\",
\"context\": \"E2E System Tests\"
}"
- name: System testing (build + execution)
env:
GIT_TOKEN: "" #${{ secrets.PAT_TEST }}
run: |
chmod +x testing-local.sh
echo "starting system testing"
BRANCH_A=${{ github.event.client_payload.branch_A }}
BRANCH_B=${{ github.event.client_payload.branch_B }}
BRANCH_FRONTEND=${{ github.event.client_payload.branch_frontend }}
echo "evaluating branches..."
echo "Proxy branch: $BRANCH_A"
echo "Charging branch: $BRANCH_B"
echo "Frontend branch: $BRANCH_FRONTEND"
# Set defaults if not provided
if [[ -z $BRANCH_A ]]; then
BRANCH_A=master
fi
if [[ -z $BRANCH_B ]]; then
BRANCH_B=master
fi
if [[ -z $BRANCH_FRONTEND ]]; then
BRANCH_FRONTEND=master
fi
echo "final proxy branch: $BRANCH_A"
echo "final charging branch: $BRANCH_B"
echo "final frontend branch: $BRANCH_FRONTEND"
./testing-local.sh $BRANCH_A ${{ github.event.client_payload.repository_A }} $BRANCH_B ${{ github.event.client_payload.repository_B }} $BRANCH_FRONTEND ${{ github.event.client_payload.repository_frontend }} ${{ github.event.client_payload.tm_version }}
- name: Upload Cypress Screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: cypress/screenshots
retention-days: 7
- name: Create commit status - success
if: success() && github.event.client_payload.pull_request_url
run: |
PR_URL="${{ github.event.client_payload.pull_request_url }}"
REPO=$(echo "$PR_URL" | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/.*|\1|')
PR_NUMBER=$(echo "$PR_URL" | sed -E 's|.*/pull/([0-9]+).*|\1|')
echo "Fetching PR SHA for repo: $REPO, PR: $PR_NUMBER"
SHA=$(curl -s -H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/pulls/$PR_NUMBER | jq -r '.head.sha')
echo "Creating success status for SHA: $SHA"
curl -X POST \
-H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/statuses/$SHA \
-d "{
\"state\": \"success\",
\"target_url\": \"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",
\"description\": \"E2E system tests passed\",
\"context\": \"E2E System Tests\"
}"
- name: Create commit status - failure
if: failure() && github.event.client_payload.pull_request_url
run: |
PR_URL="${{ github.event.client_payload.pull_request_url }}"
REPO=$(echo "$PR_URL" | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/.*|\1|')
PR_NUMBER=$(echo "$PR_URL" | sed -E 's|.*/pull/([0-9]+).*|\1|')
echo "Fetching PR SHA for repo: $REPO, PR: $PR_NUMBER"
SHA=$(curl -s -H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/pulls/$PR_NUMBER | jq -r '.head.sha')
echo "Creating failure status for SHA: $SHA"
curl -X POST \
-H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/statuses/$SHA \
-d "{
\"state\": \"failure\",
\"target_url\": \"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",
\"description\": \"E2E system tests failed\",
\"context\": \"E2E System Tests\"
}"