forked from Endeavors-of-National-Importance-LLC/OpenShell
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (121 loc) · 5.14 KB
/
Copy pathe2e-test.yml
File metadata and controls
130 lines (121 loc) · 5.14 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: E2E Test
on:
workflow_call:
inputs:
image-tag:
description: "Image tag to test (typically the commit SHA)"
required: true
type: string
runner:
description: "GitHub Actions runner label"
required: false
type: string
default: "linux-amd64-cpu8"
checkout-ref:
description: "Git ref to check out for test inputs (defaults to the workflow SHA)"
required: false
type: string
default: ""
permissions:
contents: read
packages: read
jobs:
e2e:
name: "E2E (${{ matrix.suite }})"
runs-on: ${{ inputs.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- suite: python
cmd: "mise run --no-deps --skip-deps e2e:python"
apt_packages: ""
- suite: rust-docker
cmd: "mise run --no-deps --skip-deps e2e:rust"
apt_packages: "openssh-client"
- suite: rust-podman
cmd: "mise run --no-deps --skip-deps e2e:podman"
apt_packages: "openssh-client podman"
- suite: rust-podman-rootless
cmd: "mise run --no-deps --skip-deps e2e:podman:rootless"
apt_packages: "openssh-client podman uidmap"
rootless: true
container:
image: ghcr.io/nvidia/openshell/ci:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --privileged
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/runner/_work:/home/runner/_work
env:
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_TAG: ${{ inputs.image-tag }}
OPENSHELL_REGISTRY: ghcr.io/nvidia/openshell
OPENSHELL_REGISTRY_HOST: ghcr.io
OPENSHELL_REGISTRY_NAMESPACE: nvidia/openshell
OPENSHELL_REGISTRY_USERNAME: ${{ github.actor }}
OPENSHELL_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
ref: ${{ inputs['checkout-ref'] || github.sha }}
- name: Install OS test dependencies
if: matrix.apt_packages != ''
env:
APT_PACKAGES: ${{ matrix.apt_packages }}
run: apt-get update && apt-get install -y ${APT_PACKAGES} && rm -rf /var/lib/apt/lists/*
- name: Log in to GHCR with Docker
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Log in to GHCR with Podman
if: startsWith(matrix.suite, 'rust-podman')
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Set up rootless Podman user
if: matrix.rootless
run: |
useradd -m openshell-test
echo "openshell-test:100000:65536" >> /etc/subuid
echo "openshell-test:100000:65536" >> /etc/subgid
mkdir -p "/run/user/$(id -u openshell-test)"
chown openshell-test: "/run/user/$(id -u openshell-test)"
chmod 700 "/run/user/$(id -u openshell-test)"
chown -R openshell-test: .
mkdir -p /home/openshell-test/.cache/mise /home/openshell-test/.cargo /home/openshell-test/.local/state/mise
chown -R openshell-test: /home/openshell-test/.cache /home/openshell-test/.cargo /home/openshell-test/.local
install -m 0755 "$(command -v mise)" /usr/local/bin/mise
chmod a+x /root /root/.local /root/.local/bin
for dir in /root/.cargo /root/.rustup /root/.local/share/mise /opt/mise; do
[ -d "$dir" ] && chmod -R a+rX "$dir"
done
- name: Install Python dependencies and generate protobuf stubs
if: matrix.suite == 'python'
run: uv sync --frozen && mise run --no-deps python:proto
- name: Run tests
env:
OPENSHELL_SUPERVISOR_IMAGE: ${{ format('ghcr.io/nvidia/openshell/supervisor:{0}', inputs.image-tag) }}
E2E_CMD: ${{ matrix.cmd }}
run: |
if [ "${{ matrix.rootless }}" = "true" ]; then
TESTUID="$(id -u openshell-test)"
runuser -u openshell-test -- env \
XDG_RUNTIME_DIR="/run/user/${TESTUID}" \
HOME="/home/openshell-test" \
PATH="/usr/local/bin:/root/.cargo/bin:/opt/mise/shims:/root/.local/bin:${PATH}" \
CARGO_HOME="/home/openshell-test/.cargo" \
RUSTUP_HOME="/root/.rustup" \
MISE_DATA_DIR="/opt/mise" \
MISE_CACHE_DIR="/home/openshell-test/.cache/mise" \
MISE_STATE_DIR="/home/openshell-test/.local/state/mise" \
OPENSHELL_SUPERVISOR_IMAGE="${OPENSHELL_SUPERVISOR_IMAGE}" \
OPENSHELL_REGISTRY="${OPENSHELL_REGISTRY}" \
OPENSHELL_REGISTRY_HOST="${OPENSHELL_REGISTRY_HOST}" \
OPENSHELL_REGISTRY_USERNAME="${OPENSHELL_REGISTRY_USERNAME}" \
OPENSHELL_REGISTRY_PASSWORD="${OPENSHELL_REGISTRY_PASSWORD}" \
IMAGE_TAG="${IMAGE_TAG}" \
MISE_GITHUB_TOKEN="${MISE_GITHUB_TOKEN}" \
bash -c "${E2E_CMD}"
else
${E2E_CMD}
fi