@@ -55,6 +55,7 @@ NC='\033[0m' # No Color
5555declare -a PASSED_TESTS=()
5656declare -a FAILED_TESTS=()
5757declare -a SKIPPED_TESTS=()
58+ declare -A TEST_RUN_URLS=() # maps test name -> actions run URL (when available)
5859
5960# Helper function to safely execute commands that might fail
6061# Usage: safe_run "operation description" command arg1 arg2...
@@ -635,6 +636,7 @@ trigger_workflow_dispatch_and_await_completion() {
635636
636637 if [[ " $after_run_id " != " $before_run_id " && -n " $after_run_id " ]]; then
637638 local result=0
639+ TEST_RUN_URLS[" $workflow_name " ]=" https://github.com/$REPO_OWNER /$REPO_NAME /actions/runs/$after_run_id "
638640 wait_for_workflow " $workflow_name " " $after_run_id " || result=1
639641
640642 # Disable the workflow after running
@@ -688,6 +690,7 @@ trigger_workflow_with_inputs() {
688690
689691 if [[ " $after_run_id " != " $before_run_id " && -n " $after_run_id " ]]; then
690692 local result=0
693+ TEST_RUN_URLS[" $workflow_name " ]=" https://github.com/$REPO_OWNER /$REPO_NAME /actions/runs/$after_run_id "
691694 wait_for_workflow " $workflow_name " " $after_run_id " || result=1
692695
693696 # Disable the workflow after running
@@ -1823,11 +1826,133 @@ print_final_report() {
18231826 echo " ============================================"
18241827
18251828 if [[ ${# FAILED_TESTS[@]} -gt 0 ]]; then
1829+ {
1830+ for _t in " ${FAILED_TESTS[@]} " ; do
1831+ local _url=" ${TEST_RUN_URLS[$_t]:- } "
1832+ if [[ -n " $_url " ]]; then
1833+ echo " $_t $_url "
1834+ else
1835+ echo " $_t "
1836+ fi
1837+ done
1838+ } > fails.txt
1839+ info " Failures written to fails.txt (run './e2e.sh report' to file issues)"
1840+ exit 1
1841+ fi
1842+ }
1843+
1844+ run_report () {
1845+ if [[ ! -f " fails.txt" ]]; then
1846+ error " fails.txt not found. Run e2e tests first to generate failure records."
1847+ exit 1
1848+ fi
1849+
1850+ local repo_full=" $REPO_OWNER /$REPO_NAME "
1851+ local created_count=0
1852+ local failed_count=0
1853+
1854+ info " Creating GitHub issues for failures listed in fails.txt..."
1855+
1856+ while IFS= read -r line || [[ -n " $line " ]]; do
1857+ [[ -z " $line " ]] && continue
1858+
1859+ local test_name run_url
1860+ read -r test_name run_url <<< " $line"
1861+
1862+ progress " Processing failure: $test_name "
1863+
1864+ # Use the run URL recorded in fails.txt; fall back to gh run list lookup
1865+ if [[ -z " $run_url " ]]; then
1866+ local workflow_file=" ${test_name} .lock.yml"
1867+ local run_id
1868+ run_id=$( gh run list \
1869+ --repo " $repo_full " \
1870+ --workflow=" $workflow_file " \
1871+ --limit=10 \
1872+ --json databaseId,conclusion \
1873+ --jq ' .[] | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out") | .databaseId' 2> /dev/null | head -1 || echo " " )
1874+
1875+ # Fall back to most recent run if no conclusively-failed run found
1876+ if [[ -z " $run_id " ]]; then
1877+ run_id=$( gh run list \
1878+ --repo " $repo_full " \
1879+ --workflow=" $workflow_file " \
1880+ --limit=1 \
1881+ --json databaseId \
1882+ --jq ' .[0].databaseId' 2> /dev/null || echo " " )
1883+ fi
1884+
1885+ if [[ -n " $run_id " ]]; then
1886+ run_url=" https://github.com/$repo_full /actions/runs/$run_id "
1887+ fi
1888+ fi
1889+
1890+ local run_ref=" ${run_url:- " (run URL not found for $test_name )" } "
1891+
1892+ local issue_body
1893+ issue_body=$( cat << ISSUEBODY
1894+ Workflow failure run: $run_ref
1895+
1896+ Debug this workflow failure using your favorite Agent CLI and the agentic-workflows prompt.
1897+
1898+ ## Action Required
1899+
1900+ ### Option 1: Assign this issue to Copilot
1901+
1902+ Assign this issue to Copilot using the agentic-workflows sub-agent to automatically debug and fix the workflow failure.
1903+
1904+ ### Option 2: Manually invoke the agent
1905+
1906+ Debug this workflow failure using your favorite Agent CLI and the agentic-workflows prompt.
1907+
1908+ * Start your agent
1909+ * Load the agentic-workflows prompt from \` .github/agents/agentic-workflows.agent.md\` or https://github.com/github/gh-aw/blob/main/.github/agents/agentic-workflows.agent.md
1910+ * Type \` debug the agentic workflow repo-assist failure in $run_ref \`
1911+ ISSUEBODY
1912+ )
1913+
1914+ local issue_url
1915+ # Try with Copilot CCA assignment first
1916+ if issue_url=$( gh issue create \
1917+ --repo " $repo_full " \
1918+ --title " Debug agentic-workflow failure: $test_name " \
1919+ --body " $issue_body " \
1920+ --assignee " copilot" 2> /dev/null) ; then
1921+ success " Created issue (assigned to Copilot) for '$test_name ': $issue_url "
1922+ created_count=$(( created_count + 1 ))
1923+ else
1924+ # Fall back without assignee if copilot assignment is not available
1925+ if issue_url=$( gh issue create \
1926+ --repo " $repo_full " \
1927+ --title " Debug agentic-workflow failure: $test_name " \
1928+ --body " $issue_body " 2> /dev/null) ; then
1929+ success " Created issue for '$test_name ': $issue_url "
1930+ warning " Could not assign to Copilot CCA automatically. Assign manually via the issue UI if desired."
1931+ created_count=$(( created_count + 1 ))
1932+ else
1933+ error " Failed to create issue for '$test_name '"
1934+ failed_count=$(( failed_count + 1 ))
1935+ fi
1936+ fi
1937+ done < " fails.txt"
1938+
1939+ echo
1940+ if [[ $created_count -gt 0 ]]; then
1941+ success " Created $created_count issue(s) for failed tests"
1942+ fi
1943+ if [[ $failed_count -gt 0 ]]; then
1944+ error " Failed to create $failed_count issue(s)"
18261945 exit 1
18271946 fi
18281947}
18291948
18301949main () {
1950+ # Handle 'report' subcommand before any other processing
1951+ if [[ " ${1:- } " == " report" ]]; then
1952+ run_report
1953+ return 0
1954+ fi
1955+
18311956 echo -e " ${CYAN} 🧪 GitHub Agentic Workflows End-to-End Testing${NC} "
18321957 echo -e " ${CYAN} =================================================${NC} "
18331958 echo
@@ -1844,6 +1969,10 @@ main() {
18441969 ;;
18451970 --help|-h)
18461971 echo " Usage: $0 [OPTIONS] [TEST_PATTERNS...]"
1972+ echo " $0 report"
1973+ echo " "
1974+ echo " Subcommands:"
1975+ echo " report Create GitHub issues for failures in fails.txt"
18471976 echo " "
18481977 echo " Options:"
18491978 echo " --dry-run, -n Show what would be tested without running"
0 commit comments