From 95fd3fc10e740547b53ce8e86a04c49509af6a41 Mon Sep 17 00:00:00 2001
From: nemo <nemo@ellipticresearch.com>
Date: Tue, 1 Oct 2024 15:50:52 -0400
Subject: [PATCH] Switch to self hosted CI (#324)

* feat: switch to self-hosted runner
* feat: only run CI on push, not push and PRs
---
 .github/workflows/ci.yml | 87 ++++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 43 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dd8623cd..3febf6cd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,6 +1,7 @@
 name: CI
 
-on: [pull_request, push]
+#on: [pull_request, push]
+on: [push]
 
 # Cancel a job if there's a new on on the same branch started.
 # Based on https://stackoverflow.com/questions/58895283/stop-already-running-workflow-job-in-github-actions/67223051#67223051
@@ -17,17 +18,18 @@ env:
 
 jobs:
   check_clippy:
-    runs-on: ubuntu-24.04
+#    runs-on: ubuntu-24.04
+    runs-on: self-hosted
     name: Clippy
     steps:
       - uses: actions/checkout@v4
-      - name: Install required packages
-        run: sudo apt install --no-install-recommends --yes libhwloc-dev nvidia-cuda-toolkit ocl-icd-opencl-dev
+#      - name: Install required packages
+#        run: sudo apt install --no-install-recommends --yes libhwloc-dev nvidia-cuda-toolkit ocl-icd-opencl-dev
       - name: Run cargo clippy
         run: cargo clippy --all-targets --workspace -- -D warnings
 
   check_fmt:
-    runs-on: ubuntu-24.04
+    runs-on: self-hosted
     name: Checking fmt
     steps:
       - uses: actions/checkout@v4
@@ -35,7 +37,7 @@ jobs:
         run: cargo fmt --all -- --check
 
   test_cpu:
-    runs-on: ubuntu-24.04
+    runs-on: self-hosted
     name: Test with CPU
     strategy:
       matrix:
@@ -47,40 +49,39 @@ jobs:
       - name: Show results (only for ignored tests)
         run: test -f aggregation.csv && cat aggregation.csv || true
 
-  # Enable these tests once there's a runner with a GPU.
-  #test_gpu:
-  #  runs-on: ubuntu-24.04
-  #  name: Test
-  #  env:
-  #    # Build the kernel only for the single architecture that is used on CI.
-  #    # This should reduce the overall compile-time significantly.
-  #    BELLMAN_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
-  #    # These are needed for SupraSeal only, but it shouldn't do any harm for
-  #    # the other cases.
-  #    CC: gcc-12
-  #    CXX: g++-12
-  #    NVCC_PREPEND_FLAGS: "-ccbin /usr/bin/g++-12"
-  #  strategy:
-  #    matrix:
-  #      include:
-  #        - name: "Test OpenCL only"
-  #          cargo-args: "--workspace --release --features opencl"
-  #          framework: ""
-  #        - name: "Test CUDA only"
-  #        - cargo-args: "--release --features cuda"
-  #          framework: ""
-  #        - name: "Test CUDA/OpenCL (CUDA at run-time)"
-  #          cargo-args: "--release --features cuda,opencl"
-  #          framework: cuda
-  #        - name: "Test CUDA/OpenCL (OpenCL at run-time)"
-  #          cargo-args: "--release --features cuda,opencl"
-  #          framework: cuda
-  #        - name: "Test SupraSeal"
-  #          cargo-args: "--release --features cuda-supraseal"
-  #          framework: ""
-  #  steps:
-  #    - uses: actions/checkout@v4
-  #    - name: Install required packages
-  #      run: sudo apt install --no-install-recommends --yes libhwloc-dev nvidia-cuda-toolkit ocl-icd-opencl-dev
-  #    - name: Test ${{ matrix.framework }} with ${{ matrix.cargo-args }}
-  #      run: BELLMAN_GPU_FRAMEWORK=${{ matrix.framework }} cargo test ${{ matrix.cargo-args }}
+  test_gpu:
+    runs-on: self-hosted
+    name: Test
+    env:
+      # Build the kernel only for the single architecture that is used on CI.
+      # This should reduce the overall compile-time significantly.
+      BELLMAN_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
+      # These are needed for SupraSeal only, but it shouldn't do any harm for
+      # the other cases.
+      CC: gcc-12
+      CXX: g++-12
+      NVCC_PREPEND_FLAGS: "-ccbin /usr/bin/g++-12"
+    strategy:
+      matrix:
+        include:
+          - name: "Test OpenCL only"
+            cargo-args: "--workspace --release --features opencl"
+            framework: ""
+          - name: "Test CUDA only"
+          - cargo-args: "--release --features cuda"
+            framework: ""
+          - name: "Test CUDA/OpenCL (CUDA at run-time)"
+            cargo-args: "--release --features cuda,opencl"
+            framework: cuda
+          - name: "Test CUDA/OpenCL (OpenCL at run-time)"
+            cargo-args: "--release --features cuda,opencl"
+            framework: cuda
+          - name: "Test SupraSeal"
+            cargo-args: "--release --features cuda-supraseal"
+            framework: ""
+    steps:
+      - uses: actions/checkout@v4
+#      - name: Install required packages
+#        run: sudo apt install --no-install-recommends --yes libhwloc-dev nvidia-cuda-toolkit ocl-icd-opencl-dev
+      - name: Test ${{ matrix.framework }} with ${{ matrix.cargo-args }}
+        run: BELLMAN_GPU_FRAMEWORK=${{ matrix.framework }} cargo test ${{ matrix.cargo-args }}