-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
111 lines (100 loc) · 3.32 KB
/
Copy pathaction.yml
File metadata and controls
111 lines (100 loc) · 3.32 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
109
110
111
name: "SiliconRig HIL"
description: "Flash and test firmware on real embedded hardware in CI/CD"
author: "RAWS Labs"
branding:
icon: "cpu"
color: "green"
inputs:
api-key:
description: "siliconrig API key"
required: true
board:
description: "Board type: esp32-s3, stm32-h753, stm32-f446, or rp2350"
required: true
firmware:
description: "Path to firmware binary"
required: false
serial-timeout:
description: "Serial capture duration (e.g., 30s, 2m)"
required: false
default: "30s"
serial-log:
description: "File to save serial output"
required: false
default: "serial-output.txt"
cli-version:
description: "srig-cli version to install (default: latest)"
required: false
default: "latest"
outputs:
session-id:
description: "The session ID that was created"
value: ${{ steps.session.outputs.session_id }}
serial-log:
description: "Path to the serial output log file"
value: ${{ inputs.serial-log }}
runs:
using: "composite"
steps:
- name: Install srig-cli
shell: bash
run: |
if [ "${{ inputs.cli-version }}" = "latest" ]; then
# -L matters: if the repo ever moves, the API answers 301 with a JSON
# body and jq would silently resolve the tag to "null".
TAG=$(curl -fsSL https://api.github.com/repos/raws-labs/srig-cli/releases/latest | jq -r .tag_name)
else
TAG="${{ inputs.cli-version }}"
fi
if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then
echo "::error::Could not resolve a srig-cli version to install"
exit 1
fi
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
armv7l) ARCH="armv7" ;;
esac
VERSION="${TAG#v}"
URL="https://github.com/raws-labs/srig-cli/releases/download/${TAG}/srig_${VERSION}_${OS}_${ARCH}.tar.gz"
echo "Downloading srig-cli ${TAG} for ${OS}/${ARCH}..."
curl -fsSL "$URL" | tar xz -C /usr/local/bin srig
chmod +x /usr/local/bin/srig
srig version
- name: Create session
id: session
shell: bash
env:
SRIG_API_KEY: ${{ inputs.api-key }}
run: |
SESSION=$(srig session create --board "${{ inputs.board }}" --json | jq -r .id)
echo "session_id=${SESSION}" >> "$GITHUB_OUTPUT"
echo "Session created: ${SESSION}"
- name: Flash firmware
if: inputs.firmware != ''
shell: bash
env:
SRIG_API_KEY: ${{ inputs.api-key }}
run: |
srig flash "${{ inputs.firmware }}" --session "${{ steps.session.outputs.session_id }}"
- name: Capture serial output
if: inputs.firmware != ''
shell: bash
env:
SRIG_API_KEY: ${{ inputs.api-key }}
run: |
srig serial \
--session "${{ steps.session.outputs.session_id }}" \
--timeout "${{ inputs.serial-timeout }}" \
--log "${{ inputs.serial-log }}" || true
echo "--- Serial output ---"
cat "${{ inputs.serial-log }}" 2>/dev/null || echo "(no output captured)"
- name: End session
if: always()
shell: bash
env:
SRIG_API_KEY: ${{ inputs.api-key }}
run: |
srig session end "${{ steps.session.outputs.session_id }}" || true