-
Notifications
You must be signed in to change notification settings - Fork 122
54 lines (49 loc) · 1.94 KB
/
Copy pathrun-as-coder.yml
File metadata and controls
54 lines (49 loc) · 1.94 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
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: Run as coder user
defaults:
run:
shell: bash -exo pipefail {0}
on:
workflow_call:
inputs:
name: {type: string, required: true}
image: {type: string, required: true}
runner: {type: string, required: true}
command: {type: string, required: true}
env: { type: string, required: false, default: "" }
jobs:
run-as-coder:
name: ${{inputs.name}}
runs-on: ${{inputs.runner}}
container:
options: -u root
image: ${{inputs.image}}
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
permissions:
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
path: cuCollections
persist-credentials: false
- name: Move files to coder user home directory
run: |
cp -R cuCollections /home/coder/cuCollections
chown -R coder:coder /home/coder/
- name: Configure credentials and environment variables for sccache
uses: ./cuCollections/.github/actions/configure_cccl_sccache
- name: Run command
shell: su coder {0}
run: |
set -exo pipefail
cd ~/cuCollections
eval "${{inputs.command}}" || exit_code=$?
if [ ! -z "$exit_code" ]; then
echo "::error::Error! To checkout the corresponding code and reproduce locally, run the following commands:"
echo "git clone --branch $GITHUB_REF_NAME --single-branch --recurse-submodules https://github.com/$GITHUB_REPOSITORY.git && cd $(echo $GITHUB_REPOSITORY | cut -d'/' -f2) && git checkout $GITHUB_SHA"
echo "docker run --rm -it --gpus all --pull=always --volume \$PWD:/repo --workdir /repo ${{ inputs.image }} ${{inputs.command}}"
exit $exit_code
fi