-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (133 loc) · 5.18 KB
/
Copy pathreport.yml
File metadata and controls
161 lines (133 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Report
on:
repository_dispatch:
types: [e2e**]
workflow_dispatch:
inputs:
client_payload:
description: 'The client payload'
required: true
default: '{"branch": "test/test-branch","pr_number": "99999","pr_title": "This is a test PR.","report_name": "","repository": "Automattic/jetpack","run_id": "2259156708","run_number": "12345"}'
permissions:
contents: read
actions: read
jobs:
report:
name: "Create test report"
runs-on: ubuntu-latest
env:
LOCAL_REPORTS_PATH: reports
outputs:
matrix: ${{ steps.reports-matrix.outputs.matrix }}
steps:
- name: Setup Node
uses: actions/setup-node@v4
- name: Checkout
uses: actions/checkout@v4
- name: Set environment variables safely
env:
# inputs.client_payload for workflow_dispatch, event.client_payload for repository_dispatch
PAYLOAD: ${{ github.event.inputs.client_payload || toJson(github.event.client_payload) }}
run: |
# Use jq to safely extract values from client_payload
echo "PR_NUMBER=$(echo "$PAYLOAD" | jq -r '.pr_number // ""')" >> $GITHUB_ENV
echo "RUN_ID=$(echo "$PAYLOAD" | jq -r '.run_id // ""')" >> $GITHUB_ENV
echo "REPOSITORY=$(echo "$PAYLOAD" | jq -r '.repository // ""')" >> $GITHUB_ENV
echo "BRANCH=$(echo "$PAYLOAD" | jq -r '.branch // ""')" >> $GITHUB_ENV
echo "REPORT_NAME=$(echo "$PAYLOAD" | jq -r '.report_name // ""')" >> $GITHUB_ENV
# Store the entire payload as JSON for later use
echo 'CLIENT_PAYLOAD<<EOF' >> $GITHUB_ENV
echo "$PAYLOAD" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Validate inputs
run: ./bin/validate-inputs.sh
- name: Validate repository source
if: github.event_name == 'repository_dispatch'
run: |
# Only allow repository_dispatch from Automattic organization
if [[ ! "$REPOSITORY" =~ ^Automattic/.+ ]]; then
echo "::error::Repository '$REPOSITORY' is not in Automattic organization"
exit 1
fi
- name: Parse event information
run: ./bin/set-event-data.sh
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Allure
run: npm install -g allure-commandline@2.34.1
- name: Configure S3 Credentials
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Wait for artifacts to be available
run: ./bin/wait-for-artifacts.sh
- name: Download artifacts
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
with:
repo: Automattic/jetpack
workflow: e2e-tests.yml
workflow_conclusion: "completed"
run_id: ${{ env.RUN_ID }}
name: test-output-*
name_is_regexp: true
path: ../downloads
- name: Generate test report
env:
RESULTS_PATH: ../downloads
run: ./bin/generate-report-s3.sh
- name: Install dependencies
run: npm install
- name: Update dashboard data
run: |
echo "::group::Update reports list"
node ./bin/update-reports-list.js
echo "::endgroup::"
echo "::group::Update errors list"
node ./bin/update-errors-list.js
echo "::endgroup::"
echo "::group::Update tests list"
node ./bin/update-tests-list.js
echo "::endgroup::"
- name: "Output reports matrix"
id: reports-matrix
run: |
MATRIX="$(ls -m ${{ env.LOCAL_REPORTS_PATH }} | jq -Rnc 'inputs | split(", ")')"
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
alerts:
if: ${{ github.event.client_payload.pr_number == '' }}
name: "Alerts for ${{ matrix.report }}"
runs-on: ubuntu-latest
needs: report
strategy:
matrix:
report: ${{ fromJson(needs.report.outputs.matrix) }}
env:
REPORT_NAME: ${{ matrix.report }}
steps:
- name: Setup Node
uses: actions/setup-node@v4
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Set rule name
env:
MATRIX_REPORT: ${{ matrix.report }}
run: |
# Sanitize report name by removing all non-alphanumeric except underscore and hyphen
SANITIZED=$(echo "$MATRIX_REPORT" | tr -cd '[:alnum:]-_')
# Replace hyphens with underscores
RULE_NAME="consecutive_failures_${SANITIZED//-/_}"
echo "RULE_NAME=$RULE_NAME" >> "$GITHUB_ENV"
- name: Run ${{ env.RULE_NAME }} rule
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
slack_channel: ${{ secrets.SLACK_CHANNEL_ID }}
rule_name: ${{ env.RULE_NAME }}
uses: ./alerts