Skip to content

Commit cbe081e

Browse files
authored
fix: nightly tests fix for release branch 4.15 - WPB-23154 (#4216)
1 parent d93c560 commit cbe081e

File tree

6 files changed

+284
-5
lines changed

6 files changed

+284
-5
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Add Allure report"
2+
3+
inputs:
4+
xcresult_search_path:
5+
required: false
6+
default: "artifacts"
7+
allure_artifact_name:
8+
required: false
9+
default: "html-report-${{ github.run_number }}"
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Setup Node.js
15+
if: always()
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
20+
- name: Generate Allure Report
21+
if: always()
22+
shell: bash
23+
run: bash ./scripts/run-generate-allure-report.sh "${{ inputs.xcresult_search_path }}"
24+
25+
- name: Upload Allure Report Artifact
26+
if: ${{ env.ALLURE_REPORT_AVAILABLE == 'true' }}
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: ${{ inputs.allure_artifact_name }}
30+
path: allure-reports/
31+
32+
- name: Patch Allure link into the Test Results comment
33+
if: always()
34+
shell: bash
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
run: bash ./scripts/run-update-comment.sh "Test Results" "${{ inputs.allure_artifact_name }}"

.github/workflows/_reusable_run_tests.yml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ jobs:
4444
name: Run tests
4545
runs-on: ghcr.io/cirruslabs/macos-runner:tahoe
4646
timeout-minutes: 90
47+
permissions:
48+
contents: read
49+
pull-requests: write
50+
checks: write
4751
outputs:
4852
xcresult_files: ${{ steps.find-xcresults.outputs.xcresult_files }}
4953
env:
@@ -82,7 +86,7 @@ jobs:
8286
- name: Load .env file
8387
uses: xom9ikk/dotenv@v2
8488
with:
85-
path: fastlane/
89+
path: fastlane/
8690

8791
- name: Restore Carthage Cache
8892
uses: actions/cache@v3
@@ -166,7 +170,7 @@ jobs:
166170
uses: actions/upload-artifact@v4
167171
with:
168172
name: XCResults for ${{ env.SANITIZED_BRANCH }} (${{ github.run_id }} - ${{ github.run_attempt}})
169-
path: artifacts/**/*.xcresult # Adjust this if necessary
173+
path: artifacts/**/*.xcresult
170174

171175
# Scripts
172176
- name: Test Scripts
@@ -196,14 +200,51 @@ jobs:
196200
app-group.zip
197201
fastlane/app-group.zip
198202
199-
- name: Prepare visual representation of test results
200-
uses: EnricoMi/publish-unit-test-result-action/macos@v2
203+
- name: Publish Test Results Summary
201204
if: always()
205+
uses: EnricoMi/publish-unit-test-result-action/macos@v2
202206
with:
203207
files: |
204208
build/reports/*.junit
205209
artifacts/**/*.junit
206210
compare_to_earlier_commit: false
211+
comment_title: "Test Results"
212+
213+
- name: Publish test results + Allure report
214+
if: always()
215+
uses: ./.github/actions/allure-reporting
216+
with:
217+
allure_artifact_name: "html-report-${{ github.run_number }}"
218+
xcresult_search_path: "artifacts"
219+
220+
- name: Add Allure Report to Job Summary
221+
if: ${{ always() && env.ALLURE_REPORT_AVAILABLE == 'true' }}
222+
shell: bash
223+
run: |
224+
{
225+
echo "## 📊 Allure Report Generated Successfully";
226+
echo "";
227+
echo "**Artifact Name:** \`html-report-${{ github.run_number }}\`";
228+
echo "";
229+
echo "### 📥 How to View the Report";
230+
echo "";
231+
echo "1. Download and extract the ZIP file";
232+
echo "2. **Double-click index.html** to open in your browser";
233+
echo "";
234+
echo "---";
235+
echo "";
236+
echo "_Report retention depends on repository artifact settings_";
237+
} >> "$GITHUB_STEP_SUMMARY"
238+
239+
- name: Add Allure Report Not Generated to Job Summary
240+
if: ${{ always() && env.ALLURE_REPORT_AVAILABLE != 'true' }}
241+
shell: bash
242+
run: |
243+
{
244+
echo "## 📊 Allure Report";
245+
echo "";
246+
echo "⚠️ No \`.xcresult\` found under \`artifacts\`. Allure report was not generated.";
247+
} >> "$GITHUB_STEP_SUMMARY"
207248
208249
- name: Archiving DerivedData Logs
209250
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,10 @@ vendor/*
103103
SnapshotResults
104104
artifacts/
105105

106+
# Allure Report
107+
allure-report/
108+
allure-results/
109+
.allure/
110+
106111
# AI
107-
.claude
112+
.claude
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
4+
#
5+
# Wire
6+
# Copyright (C) 2026 Wire Swiss GmbH
7+
#
8+
# This program is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see http://www.gnu.org/licenses/.
20+
#
21+
22+
XCRESULT_SEARCH_PATH="${1:-artifacts}"
23+
24+
echo "🔍 Searching for .xcresults under: ${XCRESULT_SEARCH_PATH}"
25+
26+
XCRESULTS=()
27+
while IFS= read -r -d '' xc; do
28+
XCRESULTS+=("$xc")
29+
done < <(find "${XCRESULT_SEARCH_PATH}" -type d -name "*.xcresult" -print0 2>/dev/null || true)
30+
31+
if [[ "${#XCRESULTS[@]}" -eq 0 ]]; then
32+
echo "⚠️ No .xcresult found under ./${XCRESULT_SEARCH_PATH}. Skipping Allure report generation."
33+
if [[ -n "${GITHUB_ENV:-}" ]]; then
34+
echo "ALLURE_REPORT_AVAILABLE=false" >> "${GITHUB_ENV}"
35+
fi
36+
exit 0
37+
fi
38+
39+
rm -rf allure-reports
40+
mkdir -p allure-reports
41+
42+
GENERATED_ANY=false
43+
44+
for XCRESULT in "${XCRESULTS[@]}"; do
45+
# Prefer parent schema name
46+
SCHEME="$(basename "$(dirname "${XCRESULT}")")"
47+
if [[ -z "${SCHEME}" ]]; then
48+
SCHEME="$(basename "${XCRESULT}")"
49+
SCHEME="${SCHEME%.xcresult}"
50+
fi
51+
52+
OUT_DIR="allure-reports/${SCHEME}"
53+
54+
rm -rf "${OUT_DIR}"
55+
mkdir -p "${OUT_DIR}"
56+
57+
echo "🧪 Allure: ${SCHEME}"
58+
if ! npx --yes allure awesome "${XCRESULT}" --single-file -o "${OUT_DIR}" >/dev/null; then
59+
echo "⚠️ Allure generation failed for '${SCHEME}' (continuing)"
60+
continue
61+
fi
62+
63+
if [[ -f "${OUT_DIR}/index.html" ]]; then
64+
GENERATED_ANY=true
65+
else
66+
echo "⚠️ Missing ${OUT_DIR}/index.html for '${SCHEME}' (continuing)"
67+
fi
68+
done
69+
70+
if [[ -n "${GITHUB_ENV:-}" ]]; then
71+
if [[ "${GENERATED_ANY}" == "true" ]]; then
72+
echo "ALLURE_REPORT_AVAILABLE=true" >> "${GITHUB_ENV}"
73+
else
74+
echo "ALLURE_REPORT_AVAILABLE=false" >> "${GITHUB_ENV}"
75+
fi
76+
fi
77+
78+
if [[ "${GENERATED_ANY}" == "true" ]]; then
79+
echo "✅ Allure reports generated under ./allure-reports"
80+
else
81+
echo "⚠️ No Allure reports were generated."
82+
fi

scripts/run-update-comment.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
4+
#
5+
# Wire
6+
# Copyright (C) 2026 Wire Swiss GmbH
7+
#
8+
# This program is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see http://www.gnu.org/licenses/.
20+
#
21+
22+
COMMENT_TITLE="${1:?comment_title is required}"
23+
ALLURE_ARTIFACT_NAME="${2:?allure_artifact_name is required}"
24+
HAS_ALLURE_REPORT=false
25+
OWNER="${GITHUB_REPOSITORY%/*}"
26+
REPO="${GITHUB_REPOSITORY#*/}"
27+
ALLURE_URL=""
28+
29+
# Determine PR number:
30+
# - PR events: refs/pull/<n>/merge
31+
# - Branch runs: find open PR where head branch == current branch
32+
PR_NUMBER=""
33+
34+
if [[ "${GITHUB_REF:-}" == refs/pull/* ]]; then
35+
PR_NUMBER="${GITHUB_REF#refs/pull/}"
36+
PR_NUMBER="${PR_NUMBER%/merge}"
37+
else
38+
HEAD_BRANCH="${GITHUB_REF_NAME:-${GITHUB_REF#refs/heads/}}"
39+
PR_NUMBER="$(gh pr list --state open --head "${HEAD_BRANCH}" --json number --jq '.[0].number' 2>/dev/null || true)"
40+
fi
41+
42+
if [[ -z "${PR_NUMBER}" || "${PR_NUMBER}" == "null" ]]; then
43+
echo "ℹ️ No open PR found for this run; skipping PR comment patch."
44+
exit 0
45+
fi
46+
47+
RUN_SUMMARY_URL="${GITHUB_SERVER_URL}/${OWNER}/${REPO}/actions/runs/${GITHUB_RUN_ID}"
48+
SUMMARY_URL="${RUN_SUMMARY_URL}"
49+
50+
if [[ -z "${ALLURE_URL}" ]]; then
51+
ARTIFACT_ID="$(gh api "/repos/${OWNER}/${REPO}/actions/runs/${GITHUB_RUN_ID}/artifacts" \
52+
--jq ".artifacts[] | select(.name == \"${ALLURE_ARTIFACT_NAME}\") | .id" \
53+
| head -n 1 || true)"
54+
55+
if [[ -n "${ARTIFACT_ID:-}" && "${ARTIFACT_ID}" != "null" ]]; then
56+
HAS_ALLURE_REPORT=true
57+
ALLURE_URL="${GITHUB_SERVER_URL}/${OWNER}/${REPO}/actions/runs/${GITHUB_RUN_ID}/artifacts/${ARTIFACT_ID}"
58+
fi
59+
fi
60+
61+
MARKER_START='<!-- allure-link-start -->'
62+
MARKER_END='<!-- allure-link-end -->'
63+
BLOCK="${MARKER_START}
64+
65+
**Summary:** [workflow run #${GITHUB_RUN_ID}](${SUMMARY_URL})"
66+
67+
if [[ "${HAS_ALLURE_REPORT}" == "true" ]]; then
68+
BLOCK="${BLOCK}
69+
**Allure report (download zip):** [${ALLURE_ARTIFACT_NAME}](${ALLURE_URL})"
70+
fi
71+
72+
BLOCK="${BLOCK}
73+
74+
${MARKER_END}"
75+
76+
COMMENTS_JSON=$(gh api \
77+
"/repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments?per_page=100")
78+
79+
COMMENT_ID=$(echo "$COMMENTS_JSON" | jq -r \
80+
--arg title "$COMMENT_TITLE" \
81+
'.[] | select(.body | contains($title)) | .id' | head -n 1)
82+
83+
if [[ -z "$COMMENT_ID" || "$COMMENT_ID" == "null" ]]; then
84+
echo "⚠️ Comment with title '${COMMENT_TITLE}' not found; skipping patch"
85+
exit 0
86+
fi
87+
88+
BODY=$(echo "$COMMENTS_JSON" | jq -r \
89+
--argjson id "$COMMENT_ID" \
90+
'.[] | select(.id == $id) | .body')
91+
92+
if [[ "$BODY" == *"$MARKER_START"* && "$BODY" == *"$MARKER_END"* ]]; then
93+
BODY="$(printf '%s' "$BODY" | sed "/$MARKER_START/,/$MARKER_END/d")"
94+
fi
95+
96+
BODY="${BODY%$'\n'}"$'\n\n'"${BLOCK}"
97+
98+
gh api --silent \
99+
-X PATCH \
100+
"/repos/${OWNER}/${REPO}/issues/comments/${COMMENT_ID}" \
101+
-f body="$BODY"
102+
103+
echo "✅ Allure link patched into PR comment (id=${COMMENT_ID})"

wire-ios-mono.xcworkspace/contents.xcworkspacedata

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)