Skip to content

Commit

Permalink
Add custom cargo command on workflow_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburnham committed Dec 13, 2023
1 parent 1f7f544 commit ee13e1d
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/cargo-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Commit a temporary `cargo-command.env` on the desired local branch before running workflow
name: Run custom `cargo` command

on:
workflow_dispatch:
inputs:
command:
description: 'Cargo command to run'
required: true
type: string
runner:
description: 'GitHub Actions runner'
required: true
default: 'ubuntu-latest'
type: choice
options:
- ubuntu-latest
- buildjet-32vcpu-ubuntu-2204
- gpu-bench

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
gpu-script:
name: Run custom `ci-script.sh` on GPU
if: github.event.inputs.runner == 'gpu-bench'
runs-on: [self-hosted, "${{ github.event.inputs.runner }}", "NVIDIA L4"]
steps:
- uses: actions/checkout@v4
# Install dependencies
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
- name: Set up GPU if applicable
run: |
nvidia-smi
nvcc --version
CUDA_ARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | sed 's/\.//g')
echo "EC_GPU_CUDA_NVCC_ARGS=--fatbin --gpu-architecture=sm_$CUDA_ARCH --generate-code=arch=compute_$CUDA_ARCH,code=sm_$CUDA_ARCH" | tee -a $GITHUB_ENV
echo "CUDA_ARCH=$CUDA_ARCH" | tee -a $GITHUB_ENV
echo "EC_GPU_FRAMEWORK=cuda" | tee -a $GITHUB_ENV
env | grep -E "LURK|EC_GPU|CUDA"
- uses: cardinalby/export-env-action@v2
with:
envFile:
'cargo-command.env'
# Checks if command starts with `cargo`
- name: Run command
run: |
CARGO_CMD=$(echo ${{ inputs.command }} | awk '{ print $1 }')
if [ "$CARGO_CMD" != "cargo" ];
then
echo 'Invalid `cargo` command'
exit 1
else
${{ inputs.command }}
fi

0 comments on commit ee13e1d

Please sign in to comment.