Scheduled E2E tests #453
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: Scheduled E2E tests | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 7-19/4 * * 1-5' | |
permissions: | |
contents: read | |
packages: write | |
deployments: write | |
id-token: write | |
actions: write | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
jobs: | |
test_web: | |
name: Test Web Playwright | |
uses: ./.github/workflows/reusable-web-e2e.yml | |
secrets: inherit | |
with: | |
ee: true | |
test_widget: | |
name: Test Widget Cypress | |
uses: ./.github/workflows/reusable-widget-e2e.yml | |
with: | |
ee: true | |
secrets: inherit | |
test_unit_api: | |
name: Test API | |
strategy: | |
matrix: | |
name: ['novu/api-ee', 'novu/api'] | |
uses: ./.github/workflows/reusable-api-e2e.yml | |
with: | |
ee: ${{ contains (matrix.name,'-ee') }} | |
test-e2e-affected: true | |
test-e2e-ee-affected: true | |
job-name: ${{ matrix.name }} | |
secrets: inherit | |
release_decision: | |
name: Release Decision | |
# TODO: Remove the conditional for next when we fully switch to main/prod branching model | |
if: github.ref_name == 'next' || github.ref_name == 'prod' || github.ref_name == 'main' | |
runs-on: ubuntu-latest | |
needs: | |
- test_widget | |
- test_web | |
- test_unit_api | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check and manage workflows | |
run: | | |
needs_json='${{ toJSON(needs) }}' | |
web_status=$(echo "$needs_json" | jq -r '.test_web.result') | |
widget_status=$(echo "$needs_json" | jq -r '.test_widget.result') | |
api_status=$(echo "$needs_json" | jq -r '.test_unit_api.result') | |
workflows_map=$(cat << EOF | |
prod-deploy-embed.yml: $widget_status | |
prod-deploy-widget.yml: $widget_status | |
prod-deploy-web.yml: $web_status | |
prod-deploy-api.yml: $api_status | |
prod-deploy-webhook.yml: $api_status | |
prod-deploy-worker.yml: $api_status | |
prod-deploy-ws.yml: $api_status | |
EOF | |
) | |
while IFS= read -r line; do | |
filename=$(echo "$line" | awk -F ':' '{print $1}') | |
status=$(echo "$line" | awk -F ':' '{print $2}' | awk '{$1=$1};1') # Trim whitespace | |
echo "Workflow $filename status: $status" | |
if [[ "$status" == "failure" ]]; then | |
echo "Disabling workflow $filename. The E2E test has failed." | |
state=$(gh workflow list --all --limit 100 --json path,state | jq '.[] | select(.path ==".github/workflows/'$filename'")' | jq -r .state) | |
echo "Filename: $filename" | |
echo "State: $state" | |
if [[ "$state" == "active" ]]; then | |
gh workflow disable "$filename" | |
else | |
echo "Workflow $filename is not active, skipping disable action." | |
fi | |
elif [[ "$status" == "success" ]]; then | |
echo "Enabling workflow $filename. The E2E tests have passed." | |
gh workflow enable "$filename" | |
else | |
echo "Unknown status for workflow $filename: $status" | |
fi | |
done <<< "$workflows_map" |