-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (80 loc) · 2.86 KB
/
hosted-smoke.yml
File metadata and controls
94 lines (80 loc) · 2.86 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
name: Hosted Remote Smoke
on:
workflow_dispatch:
inputs:
grpc_address:
description: "Hosted SochDB gRPC address"
required: false
default: "studio.agentslab.host:50053"
type: string
namespace:
description: "Hosted namespace"
required: false
default: "default"
type: string
skip_if_unreachable:
description: "Skip with a warning when the hosted endpoint is unreachable from the runner"
required: false
default: true
type: boolean
permissions:
contents: read
concurrency:
group: hosted-smoke-node
cancel-in-progress: false
jobs:
smoke:
name: Hosted Node Smoke
runs-on: ubuntu-latest
timeout-minutes: 15
env:
SOCHDB_GRPC_ADDRESS: ${{ inputs.grpc_address }}
SOCHDB_NAMESPACE: ${{ inputs.namespace }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Check hosted endpoint reachability
id: reachability
run: |
node <<'NODE'
const net = require('node:net');
const fs = require('node:fs');
const address = process.env.SOCHDB_GRPC_ADDRESS;
const [host, portText] = address.split(':');
const port = Number(portText);
const output = process.env.GITHUB_OUTPUT;
const writeOutput = (reachable, reason = '') => {
fs.appendFileSync(output, `reachable=${reachable}\n`);
fs.appendFileSync(output, `reason=${String(reason).replace(/\n/g, ' ')}\n`);
};
const socket = net.createConnection({ host, port, timeout: 5000 });
socket.on('connect', () => {
writeOutput('true');
socket.end();
});
socket.on('timeout', () => {
writeOutput('false', 'connection timed out');
socket.destroy();
});
socket.on('error', (error) => {
writeOutput('false', error.message);
});
NODE
- name: Warn and skip when endpoint is unreachable
if: steps.reachability.outputs.reachable != 'true' && inputs.skip_if_unreachable
run: echo "::warning::Hosted endpoint ${SOCHDB_GRPC_ADDRESS} is unreachable from this runner; skipping hosted smoke."
- name: Fail when endpoint is unreachable
if: steps.reachability.outputs.reachable != 'true' && !inputs.skip_if_unreachable
run: |
echo "::error::Hosted endpoint ${SOCHDB_GRPC_ADDRESS} is unreachable from this runner: ${{ steps.reachability.outputs.reason }}"
exit 1
- name: Run hosted smoke script
if: steps.reachability.outputs.reachable == 'true'
run: npm run smoke:hosted