Skip to content

Commit 5136c95

Browse files
committed
Run E2E every night of the week, on merge to main and push to main
1 parent 6741f0c commit 5136c95

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

.github/workflows/e2e-tests.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Run E2E Playwright tests
22
on:
33
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
schedule:
8+
- cron: '15 22 * * 1-5'
49

510
jobs:
611
e2e-test:
@@ -40,4 +45,43 @@ jobs:
4045
- name: Stop containers
4146
working-directory: extensions/ql-vscode/test/e2e
4247
if: always()
43-
run: docker-compose -f "docker-compose.yml" down -v
48+
run: docker-compose -f "docker-compose.yml" down -v
49+
report-failure:
50+
name: Report failure on the default branch
51+
runs-on: ubuntu-latest
52+
needs: [e2e-test]
53+
if: failure() && github.ref == 'refs/heads/main'
54+
permissions:
55+
contents: read
56+
issues: write
57+
env:
58+
GH_TOKEN: ${{ github.token }}
59+
steps:
60+
- name: Create GitHub issue
61+
run: |
62+
# Set -eu so that we fail if the gh command fails.
63+
set -eu
64+
65+
# Try to find an existing open issue if there is one
66+
ISSUE="$(gh issue list --repo "$GITHUB_REPOSITORY" --label "e2e-test-failure" --state "open" --limit 1 --json number -q '.[0].number')"
67+
68+
if [[ -n "$ISSUE" ]]; then
69+
echo "Found open issue number $ISSUE ($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/issues/$ISSUE)"
70+
else
71+
echo "Did not find an open tracking issue. Creating one."
72+
73+
ISSUE_BODY="issue-body.md"
74+
printf "E2e tests have failed on the default branch.\n\n@github/code-scanning-secexp-reviewers" > "$ISSUE_BODY"
75+
76+
ISSUE="$(gh issue create --repo "$GITHUB_REPOSITORY" --label "e2e-test-failure" --title "E2@ test failure" --body-file "$ISSUE_BODY")"
77+
# `gh issue create` returns the full issue URL, not just the number.
78+
echo "Created issue with URL $ISSUE"
79+
fi
80+
81+
COMMENT_FILE="comment.md"
82+
RUN_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
83+
printf 'E2@ test [%s](%s) failed on ref `%s`' "$GITHUB_RUN_ID" "$RUN_URL" "$GITHUB_REF" > "$COMMENT_FILE"
84+
85+
# `gh issue create` returns an issue URL, and `gh issue list | cut -f 1` returns an issue number.
86+
# Both are accepted here.
87+
gh issue comment "$ISSUE" --repo "$GITHUB_REPOSITORY" --body-file "$COMMENT_FILE"

0 commit comments

Comments
 (0)