4
4
workflow_dispatch : {}
5
5
push :
6
6
branches : ['test', 'cypress/*']
7
+ pull_request :
8
+ branches : ['dev']
7
9
8
10
env :
9
11
DASHBOARD_PROJECT_ID : ${{ secrets.CY_DASHBOARD_PRJ_ID }}
21
23
steps :
22
24
- name : Build GWA API Image
23
25
run : |
24
- git clone https://github.com/bcgov/gwa-api.git
26
+ git clone https://github.com/bcgov/gwa-api.git --branch v1.0.40
25
27
cd gwa-api/microservices/gatewayApi
26
28
docker build -t gwa-api:e2e .
27
29
@@ -47,30 +49,37 @@ jobs:
47
49
48
50
- name : Execute Tests & Clean Up
49
51
run : |
52
+ # Start following logs in the background with continuous output
53
+ docker logs -f cypress-e2e 2>&1 &
54
+ LOG_PID=$!
55
+
50
56
while true; do
51
57
if [ "$(docker ps -aq -f status=exited -f name=cypress-e2e)" ]; then
58
+ echo "Cypress tests completed."
52
59
# cleanup
53
60
docker compose down
54
61
break
55
62
else
56
- echo "Waiting for Cypress to Complete E2E Tests....."
57
- sleep 1m
63
+ sleep 30s
58
64
fi
59
65
done
60
66
61
67
- name : Upload E2E Test Results HTML Report
68
+ if : always()
62
69
uses : actions/upload-artifact@v4
63
70
with :
64
71
name : test-results-html
65
72
path : ${{ github.workspace }}/e2e/results/report
66
73
67
74
- name : Upload E2E Test Results JSON Report
75
+ if : always()
68
76
uses : actions/upload-artifact@v4
69
77
with :
70
78
name : test-results-json
71
79
path : ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json
72
80
73
81
- name : Upload E2E Code Coverage Report
82
+ if : always()
74
83
uses : actions/upload-artifact@v4
75
84
with :
76
85
name : code-coverage
81
90
with :
82
91
name : astra-scan-results
83
92
path : ${{ github.workspace }}/e2e/cypress/fixtures/state/scanResult.json
93
+
94
+ - name : Check for failed tests and create Issue
95
+ if : always()
96
+ env :
97
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98
+ run : |
99
+ FAILURE_COUNT=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq '.stats.failures')
100
+ if [[ "$FAILURE_COUNT" -gt 0 ]]; then
101
+ FAILED_TESTS=$(jq -r '
102
+ .results[] |
103
+ (.file | split("/") | .[2:] | join("/")) as $file |
104
+ .. |
105
+ .tests? // empty |
106
+ .[] |
107
+ select(.fail == true) |
108
+ "- " + $file + " - " + .title
109
+ ' ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json)
110
+ STATS=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq -r '.stats | to_entries | map("\(.key)\t\(.value)") | .[]' | column -t)
111
+ echo -e "Stats: $STATS\n\nFailed Tests:\n$FAILED_TESTS\n\nRun Link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" > msg
112
+ export MSG=$(cat msg)
113
+ gh issue create --title "FAILED: Automated Tests($FAILURE_COUNT)" --body "$MSG" --label "automation" --assignee "${{ env.GIT_COMMIT_AUTHOR }}"
114
+ exit 1
115
+ fi
84
116
85
117
- name : Instrument the code for coverage analysis
86
118
run : |
92
124
#npx nyc instrument --compact=false . --in-place
93
125
94
126
- name : SonarCloud Scan
95
- uses : sonarsource/sonarcloud-github -action@master
127
+ uses : sonarsource/sonarqube-scan -action@master
96
128
with :
97
129
args : >
98
130
-Dsonar.organization=bcgov-oss
@@ -106,28 +138,6 @@ jobs:
106
138
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107
139
SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
108
140
109
- - name : Check for failed tests and create Issue
110
- env :
111
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
112
- run : |
113
- FAILURE_COUNT=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq '.stats.failures')
114
- if [[ "$FAILURE_COUNT" -gt 0 ]]; then
115
- FAILED_TESTS=$(jq -r '
116
- .results[] |
117
- (.file | split("/") | .[2:] | join("/")) as $file |
118
- .. |
119
- .tests? // empty |
120
- .[] |
121
- select(.fail == true) |
122
- "- " + $file + " - " + .title
123
- ' ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json)
124
- STATS=$(cat ${{ github.workspace }}/e2e/results/bcgov-aps-e2e-report.json | jq -r '.stats | to_entries | map("\(.key)\t\(.value)") | .[]' | column -t)
125
- echo -e "Stats: $STATS\n\nFailed Tests:\n$FAILED_TESTS\n\nRun Link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" > msg
126
- export MSG=$(cat msg)
127
- gh issue create --title "FAILED: Automated Tests($FAILURE_COUNT)" --body "$MSG" --label "automation" --assignee "${{ env.GIT_COMMIT_AUTHOR }}"
128
- exit 1
129
- fi
130
-
131
141
- name : Set up Python 3.9
132
142
if : failure()
133
143
uses : actions/setup-python@v2
0 commit comments