-
Notifications
You must be signed in to change notification settings - Fork 91
66 lines (61 loc) · 2.46 KB
/
run-as-coder.yml
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
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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