Skip to content

Commit 3b9e78c

Browse files
committed
devx: add Xcode problem matcher; add tools/fetch-latest-ci-logs.sh; enable matcher in CI
1 parent 7ac50a3 commit 3b9e78c

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "xcodebuild",
5+
"pattern": [
6+
{
7+
"regexp": "^(.*?):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"severity": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}
18+

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
run: |
2828
rm -rf "$LOG_DIR" && mkdir -p "$LOG_DIR"
2929
30+
- name: Enable Xcode problem matcher
31+
run: echo "::add-matcher::.github/problem-matchers/xcodebuild.json"
32+
3033
- name: Install xcpretty
3134
run: |
3235
gem install xcpretty --no-document

tools/fetch-latest-ci-logs.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Fetch the latest ci-logs artifact for a branch (default: dev) using GitHub CLI
5+
# Requirements: gh CLI authenticated (GH_TOKEN or gh auth login)
6+
# Usage:
7+
# tools/fetch-latest-ci-logs.sh [branch] [output_dir]
8+
# tools/fetch-latest-ci-logs.sh --run <run-id> [output_dir]
9+
# tools/fetch-latest-ci-logs.sh --help
10+
11+
usage() {
12+
cat <<EOF
13+
Fetch latest ci-logs artifact from GitHub Actions.
14+
15+
Usage:
16+
$(basename "$0") [branch] [output_dir]
17+
$(basename "$0") --run <run-id> [output_dir]
18+
19+
Examples:
20+
$(basename "$0") # fetch from branch 'dev' into ./ci_logs
21+
$(basename "$0") main ./out # fetch from branch 'main' into ./out
22+
$(basename "$0") --run 123456789 # fetch by run id into ./ci_logs
23+
24+
Notes:
25+
- Requires 'gh' CLI with repo read access. Run: gh auth login
26+
- Artifact name expected: ci-logs (from CI workflow)
27+
EOF
28+
}
29+
30+
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
31+
usage; exit 0
32+
fi
33+
34+
if ! command -v gh >/dev/null 2>&1; then
35+
echo "Error: 'gh' CLI not found. Install from https://cli.github.com/" >&2
36+
exit 1
37+
fi
38+
39+
ARTIFACT_NAME="ci-logs"
40+
BRANCH="dev"
41+
RUN_ID=""
42+
OUTDIR="ci_logs"
43+
44+
if [[ "${1:-}" == "--run" ]]; then
45+
RUN_ID="${2:-}"
46+
if [[ -z "$RUN_ID" ]]; then echo "Error: --run requires a run id" >&2; exit 2; fi
47+
OUTDIR="${3:-$OUTDIR}"
48+
else
49+
BRANCH="${1:-$BRANCH}"
50+
OUTDIR="${2:-$OUTDIR}"
51+
fi
52+
53+
mkdir -p "$OUTDIR"
54+
55+
if [[ -n "$RUN_ID" ]]; then
56+
echo "Downloading artifact '$ARTIFACT_NAME' from run $RUN_ID into $OUTDIR ..."
57+
gh run download "$RUN_ID" --name "$ARTIFACT_NAME" --dir "$OUTDIR"
58+
else
59+
echo "Resolving latest run on branch '$BRANCH' ..."
60+
RUN_ID=$(gh run list --branch "$BRANCH" --limit 1 --json databaseId --jq '.[0].databaseId')
61+
if [[ -z "$RUN_ID" || "$RUN_ID" == "null" ]]; then
62+
echo "Error: No runs found on branch '$BRANCH'" >&2
63+
exit 3
64+
fi
65+
echo "Downloading artifact '$ARTIFACT_NAME' from run $RUN_ID into $OUTDIR ..."
66+
gh run download "$RUN_ID" --name "$ARTIFACT_NAME" --dir "$OUTDIR"
67+
fi
68+
69+
echo "Downloaded files:"
70+
find "$OUTDIR" -maxdepth 2 -type f -print
71+
72+
SUMMARY_FILE="$OUTDIR/ci-logs/ci_summary.txt"
73+
if [[ -f "$SUMMARY_FILE" ]]; then
74+
echo
75+
echo "--- CI Summary (tail) ---"
76+
tail -n 200 "$SUMMARY_FILE" || true
77+
fi
78+
79+
echo "Done."
80+

0 commit comments

Comments
 (0)