forked from edehvictor/StellarYield
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (100 loc) · 3.7 KB
/
Copy pathrelease-smoke-report.yml
File metadata and controls
108 lines (100 loc) · 3.7 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
name: Release smoke report
on:
workflow_dispatch:
inputs:
frontend_url:
description: "Production or preview frontend base URL (no trailing slash)"
required: true
type: string
backend_url:
description: "Production or staging backend base URL (no trailing slash)"
required: true
type: string
issue_or_pr_number:
description: "Optional: issue or PR number to post the report on (same repo only)"
required: false
type: string
backend_health_path:
description: "Backend health path"
required: false
default: "/api/health"
type: string
backend_yields_path:
description: "Backend yields path"
required: false
default: "/api/yields"
type: string
frontend_asset_path:
description: "Frontend static asset path (e.g. favicon)"
required: false
default: "/favicon.svg"
type: string
permissions:
contents: read
issues: write
pull-requests: write
jobs:
smoke:
name: Run smoke checks and publish report
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Run release smoke checks
id: smoke
env:
FRONTEND_URL: ${{ github.event.inputs.frontend_url }}
BACKEND_URL: ${{ github.event.inputs.backend_url }}
BACKEND_HEALTH_PATH: ${{ github.event.inputs.backend_health_path }}
BACKEND_YIELDS_PATH: ${{ github.event.inputs.backend_yields_path }}
FRONTEND_ASSET_PATH: ${{ github.event.inputs.frontend_asset_path }}
run: node scripts/smoke-test.js --report --markdown-out=smoke-report.md
- name: Add report to job summary
if: always()
run: |
if [ -f smoke-report.md ]; then
cat smoke-report.md >> "$GITHUB_STEP_SUMMARY"
else
echo "## Release smoke report" >> "$GITHUB_STEP_SUMMARY"
echo "_Report file was not generated._" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload smoke report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: release-smoke-report-${{ github.run_id }}
path: smoke-report.md
if-no-files-found: ignore
retention-days: 30
- name: Comment on issue or PR
if: always() && github.event.inputs.issue_or_pr_number != ''
uses: actions/github-script@v7
env:
TARGET: ${{ github.event.inputs.issue_or_pr_number }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
const fs = require("fs");
const num = Number.parseInt(process.env.TARGET, 10);
if (!Number.isFinite(num) || num <= 0) {
core.setFailed(`Invalid issue_or_pr_number: ${process.env.TARGET}`);
return;
}
let body = "";
try {
body = fs.readFileSync("smoke-report.md", "utf8");
body = body.replace(/^#\s+Release smoke report\s*\n+/m, "");
} catch {
body = `_Smoke report file missing. See [workflow run](${process.env.RUN_URL})._`;
}
const header = `## Release smoke report\n\n_Action: [\`${context.workflow}\`](${process.env.RUN_URL}) · ${new Date().toISOString()}_\n\n`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: num,
body: header + body,
});