Skip to content

Commit b0f296b

Browse files
authored
ci(release): add canary triggered after release workflow (#298)
1 parent a0ab195 commit b0f296b

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Release Canary
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Release tag to test (e.g. devel, v1.2.3)"
8+
required: true
9+
type: string
10+
workflow_run:
11+
workflows: ["Release Dev", "Release Tag"]
12+
types: [completed]
13+
14+
permissions:
15+
contents: read
16+
packages: read
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
jobs:
23+
acceptance:
24+
name: Canary (${{ matrix.arch }})
25+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- arch: amd64
31+
runner: build-amd64
32+
target: x86_64-unknown-linux-musl
33+
- arch: arm64
34+
runner: build-arm64
35+
target: aarch64-unknown-linux-musl
36+
runs-on: ${{ matrix.runner }}
37+
timeout-minutes: 30
38+
container:
39+
image: ghcr.io/nvidia/openshell/ci:latest
40+
credentials:
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
options: --privileged
44+
volumes:
45+
- /var/run/docker.sock:/var/run/docker.sock
46+
env:
47+
OPENSHELL_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Determine release tag
52+
id: release
53+
run: |
54+
set -euo pipefail
55+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
56+
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
57+
else
58+
WORKFLOW_NAME="${{ github.event.workflow_run.name }}"
59+
if [ "$WORKFLOW_NAME" = "Release Dev" ]; then
60+
echo "tag=devel" >> "$GITHUB_OUTPUT"
61+
elif [ "$WORKFLOW_NAME" = "Release Tag" ]; then
62+
TAG="${{ github.event.workflow_run.head_branch }}"
63+
if [ -z "$TAG" ]; then
64+
echo "::error::Could not determine release tag from workflow_run"
65+
exit 1
66+
fi
67+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
68+
else
69+
echo "::error::Unexpected triggering workflow: ${WORKFLOW_NAME}"
70+
exit 1
71+
fi
72+
fi
73+
74+
- name: Install CLI from GitHub Release
75+
run: |
76+
set -euo pipefail
77+
TAG="${{ steps.release.outputs.tag }}"
78+
ASSET="openshell-${{ matrix.target }}.tar.gz"
79+
80+
echo "Downloading ${ASSET} from release ${TAG}..."
81+
gh release download "${TAG}" \
82+
--repo "${{ github.repository }}" \
83+
--pattern "${ASSET}" \
84+
--output "/tmp/${ASSET}"
85+
86+
tar -xzf "/tmp/${ASSET}" -C /tmp
87+
install -m 755 /tmp/openshell /usr/local/bin/openshell
88+
rm -f "/tmp/${ASSET}" /tmp/openshell
89+
env:
90+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
92+
- name: Verify CLI installation
93+
run: openshell --version
94+
95+
- name: Run canary test
96+
run: |
97+
set -euo pipefail
98+
99+
echo "Creating sandbox and running 'echo hello world'..."
100+
OUTPUT=$(openshell sandbox create --no-keep --no-tty -- echo "hello world" 2>&1) || {
101+
EXIT_CODE=$?
102+
echo "::error::openshell sandbox create failed with exit code ${EXIT_CODE}"
103+
echo "$OUTPUT"
104+
exit $EXIT_CODE
105+
}
106+
107+
echo "$OUTPUT"
108+
109+
if echo "$OUTPUT" | grep -q "hello world"; then
110+
echo "Canary test passed: 'hello world' found in output"
111+
else
112+
echo "::error::Canary test failed: 'hello world' not found in output"
113+
exit 1
114+
fi

0 commit comments

Comments
 (0)