mirror of
https://github.com/abraunegg/onedrive
synced 2026-03-14 14:35:46 +01:00
Update PR
* Update PR
This commit is contained in:
parent
0d063d6a0c
commit
8f2cc53d3d
2 changed files with 151 additions and 26 deletions
100
.github/workflows/e2e-personal.yaml
vendored
100
.github/workflows/e2e-personal.yaml
vendored
|
|
@ -8,6 +8,7 @@ on:
|
|||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
e2e_personal:
|
||||
|
|
@ -64,3 +65,102 @@ jobs:
|
|||
with:
|
||||
name: e2e-personal
|
||||
path: ci/e2e/out/**
|
||||
|
||||
pr_comment:
|
||||
name: Post PR summary comment
|
||||
needs: [ e2e_personal ]
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# Download the artifact produced by the e2e_personal job
|
||||
- name: Download artefact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: e2e-personal
|
||||
path: artifacts/e2e-personal
|
||||
|
||||
- name: Build markdown summary
|
||||
id: summary
|
||||
run: |
|
||||
set -euo pipefail
|
||||
f="artifacts/e2e-personal/results.json"
|
||||
if [ ! -f "$f" ]; then
|
||||
echo "md=⚠️ E2E ran but results.json was not found." >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
target=$(jq -r '.target // "personal"' "$f")
|
||||
total=$(jq -r '.cases | length' "$f")
|
||||
passed=$(jq -r '[.cases[] | select(.status=="pass")] | length' "$f")
|
||||
failed=$(jq -r '[.cases[] | select(.status=="fail")] | length' "$f")
|
||||
|
||||
# Build failures list
|
||||
failures=$(jq -r '.cases[]
|
||||
| select(.status=="fail")
|
||||
| "- Test Case \(.id // "????"): \(.name) — \(.reason // "no reason provided")"' "$f" || true)
|
||||
|
||||
md="## ${target^} Account Testing\n"
|
||||
md+="${total} Test Cases Run \n"
|
||||
md+="**${passed}** Test Cases Passed \n"
|
||||
md+="**${failed}** Test Cases Failed \n\n"
|
||||
|
||||
if [ "$failed" -gt 0 ] && [ -n "$failures" ]; then
|
||||
md+="### ${target^} Account Test Failures\n"
|
||||
md+="$failures\n"
|
||||
fi
|
||||
|
||||
echo "md<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo -e "$md" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Find PR associated with this commit
|
||||
id: pr
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const sha = context.sha;
|
||||
|
||||
const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||
owner, repo, commit_sha: sha
|
||||
});
|
||||
|
||||
if (!prs.data.length) {
|
||||
core.setOutput("found", "false");
|
||||
return;
|
||||
}
|
||||
|
||||
core.setOutput("found", "true");
|
||||
core.setOutput("number", String(prs.data[0].number));
|
||||
|
||||
- name: Post or update PR comment (sticky)
|
||||
if: steps.pr.outputs.found == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const issue_number = Number("${{ steps.pr.outputs.number }}");
|
||||
|
||||
const marker = "<!-- onedrive-e2e-personal-summary -->";
|
||||
const body = `${marker}\n${{ toJSON(steps.summary.outputs.md) }}`.slice(1, -1);
|
||||
|
||||
const comments = await github.rest.issues.listComments({
|
||||
owner, repo, issue_number, per_page: 100
|
||||
});
|
||||
|
||||
const existing = comments.data.find(c => c.body && c.body.includes(marker));
|
||||
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner, repo, comment_id: existing.id, body
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
owner, repo, issue_number, body
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ set -euo pipefail
|
|||
# ONEDRIVE_BIN
|
||||
# E2E_TARGET
|
||||
# RUN_ID
|
||||
#
|
||||
# Optional (provided by GitHub Actions):
|
||||
# RUNNER_TEMP
|
||||
|
||||
OUT_DIR="ci/e2e/out"
|
||||
SYNC_ROOT="$RUNNER_TEMP/sync-${E2E_TARGET}"
|
||||
SYNC_ROOT="${RUNNER_TEMP:-/tmp}/sync-${E2E_TARGET}"
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
mkdir -p "$SYNC_ROOT"
|
||||
|
|
@ -15,16 +18,43 @@ mkdir -p "$SYNC_ROOT"
|
|||
RESULTS_FILE="${OUT_DIR}/results.json"
|
||||
LOG_FILE="${OUT_DIR}/sync.log"
|
||||
|
||||
echo "E2E target: ${E2E_TARGET}"
|
||||
echo "Sync root: ${SYNC_ROOT}"
|
||||
|
||||
CASE_NAME="basic-resync"
|
||||
|
||||
# We'll collect cases as JSON objects in a bash array, then assemble results.json.
|
||||
declare -a CASES=()
|
||||
pass_count=0
|
||||
fail_count=0
|
||||
|
||||
# Helper: add a PASS case
|
||||
add_pass() {
|
||||
local id="$1"
|
||||
local name="$2"
|
||||
CASES+=("$(jq -cn --arg id "$id" --arg name "$name" \
|
||||
'{id:$id,name:$name,status:"pass"}')")
|
||||
pass_count=$((pass_count + 1))
|
||||
}
|
||||
|
||||
# Helper: add a FAIL case (with reason)
|
||||
add_fail() {
|
||||
local id="$1"
|
||||
local name="$2"
|
||||
local reason="$3"
|
||||
CASES+=("$(jq -cn --arg id "$id" --arg name "$name" --arg reason "$reason" \
|
||||
'{id:$id,name:$name,status:"fail",reason:$reason}')")
|
||||
fail_count=$((fail_count + 1))
|
||||
}
|
||||
|
||||
echo "E2E target: ${E2E_TARGET}"
|
||||
echo "Sync root: ${SYNC_ROOT}"
|
||||
|
||||
###############################################
|
||||
# Test Case 0001: basic resync
|
||||
###############################################
|
||||
TC_ID="0001"
|
||||
TC_NAME="basic-resync (sync + verbose + resync + resync-auth)"
|
||||
|
||||
echo "Running test case ${TC_ID}: ${TC_NAME}"
|
||||
echo "Running: onedrive --sync --verbose --resync --resync-auth"
|
||||
|
||||
# Stream output to console AND log file (Option A) while preserving exit code.
|
||||
set +e
|
||||
"$ONEDRIVE_BIN" \
|
||||
--sync \
|
||||
|
|
@ -37,34 +67,29 @@ rc=${PIPESTATUS[0]}
|
|||
set -e
|
||||
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
pass_count=1
|
||||
status="pass"
|
||||
add_pass "$TC_ID" "$TC_NAME"
|
||||
else
|
||||
fail_count=1
|
||||
status="fail"
|
||||
add_fail "$TC_ID" "$TC_NAME" "onedrive exited with code ${rc}"
|
||||
fi
|
||||
|
||||
# Write minimal results.json
|
||||
cat > "$RESULTS_FILE" <<EOF
|
||||
{
|
||||
"target": "${E2E_TARGET}",
|
||||
"run_id": ${RUN_ID},
|
||||
"cases": [
|
||||
{
|
||||
"name": "${CASE_NAME}",
|
||||
"status": "${status}"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
###############################################
|
||||
# Write results.json
|
||||
###############################################
|
||||
# Build JSON array from CASES[]
|
||||
cases_json="$(printf '%s\n' "${CASES[@]}" | jq -cs '.')"
|
||||
|
||||
jq -n \
|
||||
--arg target "$E2E_TARGET" \
|
||||
--argjson run_id "$RUN_ID" \
|
||||
--argjson cases "$cases_json" \
|
||||
'{target:$target, run_id:$run_id, cases:$cases}' \
|
||||
> "$RESULTS_FILE"
|
||||
|
||||
echo "Exit code: ${rc}"
|
||||
echo "Results written to ${RESULTS_FILE}"
|
||||
echo "Passed: ${pass_count}"
|
||||
echo "Failed: ${fail_count}"
|
||||
|
||||
# Fail job if command failed
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
echo "E2E failed - see sync.log"
|
||||
# Fail the job if any cases failed.
|
||||
if [ "$fail_count" -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue