Merge pull request #1541 from chipsalliance/custom-runners-ci

Custom runners ci
diff --git a/.github/bin/build-and-test.sh b/.github/bin/build-and-test.sh
index f059ac7..f0910c7 100755
--- a/.github/bin/build-and-test.sh
+++ b/.github/bin/build-and-test.sh
@@ -94,6 +94,7 @@
     bazel coverage \
           --combined_report=lcov \
           --coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main \
+          --java_runtime_version=remotejdk_11 \
           ${CHOSEN_TARGETS}
     # output will be in bazel-out/_coverage/_coverage_report.dat
     ;;
diff --git a/.github/bin/install-bazel.sh b/.github/bin/install-bazel.sh
index 612456d..af67ec3 100755
--- a/.github/bin/install-bazel.sh
+++ b/.github/bin/install-bazel.sh
@@ -18,6 +18,6 @@
         exit 1
 fi
 wget --no-verbose "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel_${BAZEL_VERSION}-linux-x86_64.deb" -O /tmp/bazel.deb
-sudo dpkg -i /tmp/bazel.deb || true
-sudo apt-get -f install
+dpkg -i /tmp/bazel.deb || true
+apt-get -f install
 bazel --version
diff --git a/.github/bin/set-compiler.sh b/.github/bin/set-compiler.sh
index b2c535a..99d007f 100755
--- a/.github/bin/set-compiler.sh
+++ b/.github/bin/set-compiler.sh
@@ -15,12 +15,12 @@
 
 VERSION=$1
 
-sudo dpkg --list | grep gcc
-sudo dpkg --list | grep libstdc++
+dpkg --list | grep gcc
+dpkg --list | grep libstdc++
 
-sudo ln -sf /usr/bin/gcc-$VERSION /usr/bin/gcc
-sudo ln -sf /usr/bin/g++-$VERSION /usr/bin/g++
-sudo ln -sf /usr/bin/gcov-$VERSION /usr/bin/gcov
+ln -sf /usr/bin/gcc-$VERSION /usr/bin/gcc
+ln -sf /usr/bin/g++-$VERSION /usr/bin/g++
+ln -sf /usr/bin/gcov-$VERSION /usr/bin/gcov
 
 gcc --version || true
 gcov --version
diff --git a/.github/settings.sh b/.github/settings.sh
index 91028b0..66b92a4 100644
--- a/.github/settings.sh
+++ b/.github/settings.sh
@@ -32,7 +32,7 @@
 export BAZEL_OPTS="-c opt --show_progress_rate_limit=10.0"
 
 # Used to fetch the BAZEL version where needed.
-export BAZEL_VERSION=4.0.0
+export BAZEL_VERSION=5.3.2
 
 # TODO(b/171989992): revert to using release version after upgrading system
 #   libraries/image (need: GLIBCXX_3.4.26, CXXABI_1.3.11, GLIBC_2.29).
diff --git a/.github/workflows/verible-ci.yml b/.github/workflows/verible-ci.yml
index fadddd6..7fdffdb 100644
--- a/.github/workflows/verible-ci.yml
+++ b/.github/workflows/verible-ci.yml
@@ -12,15 +12,16 @@
   workflow_dispatch:
 
 env:
-  DOCKER_BUILDKIT: 1
   BOT_USER: "Deployment Bot"
   BOT_EMAIL: "verible-dev@googlegroups.com"
+  GHA_MACHINE_TYPE: "n2-standard-8"
 
 jobs:
 
 
   VerifyFormatting:
-    runs-on: ubuntu-20.04
+    container: ubuntu:20.04
+    runs-on: [self-hosted, Linux, X64]
 
     steps:
 
@@ -36,14 +37,26 @@
 
     - name: Install Dependencies
       run: |
-        sudo apt -qq -y install clang-format
+        apt -qqy update
+        apt -qq -y install clang-format git
         clang-format --version
 
     - name: Run formatting style check
       run: ./.github/bin/run-clang-format.sh
 
+    - name: 📤 Upload performance graphs
+      uses: actions/upload-artifact@v2
+      if: success() || failure() 
+      with:
+        name: "diag"
+        path: "**/plot_*.svg"
+
   ClangTidy:
-    runs-on: ubuntu-20.04
+    container: ubuntu:20.04
+    runs-on: [self-hosted, Linux, X64]
+
+    env:
+      GHA_MACHINE_TYPE: "n2-standard-4"
 
     steps:
 
@@ -59,7 +72,10 @@
 
     - name: Install Dependencies
       run: |
-        sudo apt -qq -y install clang-tidy-11
+        apt -qqy update
+        apt -qq -y install clang-tidy-11 build-essential git wget
+        source ./.github/settings.sh
+        ./.github/bin/install-bazel.sh
         echo "TMPDIR=/tmp" >> $GITHUB_ENV
 
     - name: Create Cache Timestamp
@@ -69,20 +85,28 @@
         format: 'YYYY-MM-DD-HH-mm-ss'
 
     - name: Retrieve cached results
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       with:
         path: |
           /tmp/clang-tidy-hashes.cache
-          /home/runner/.cache/bazel
+          /root/.cache/bazel
         key: clang-tidy-${{ steps.cache_timestamp.outputs.time }}
         restore-keys: clang-tidy-
 
     - name: Run clang tidy
       run: ./.github/bin/run-clang-tidy.sh
 
+    - name: 📤 Upload performance graphs
+      uses: actions/upload-artifact@v2
+      if: success() || failure() 
+      with:
+        name: "diag"
+        path: "**/plot_*.svg"
+
 
   Check:
-    runs-on: ubuntu-20.04
+    container: ubuntu:20.04
+    runs-on: [self-hosted, Linux, X64]
     strategy:
       fail-fast: false
       matrix:
@@ -119,19 +143,20 @@
         format: 'YYYY-MM-DD-HH-mm-ss'
 
     - name: Mount bazel cache
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       if: matrix.mode != 'clean' && matrix.mode != 'coverage'
       with:
-        path: "/home/runner/.cache/bazel"
+        path: "/root/.cache/bazel"
         key: bazelcache_${{ matrix.mode }}_${{ steps.cache_timestamp.outputs.time }}
         restore-keys: bazelcache_${{ matrix.mode }}_
 
     - name: Install Dependencies
       run: |
         set -x
+        apt -qqy update
+        apt -qq -y install clang-10 build-essential wget git python3 python-is-python3 gcc-10 g++-10
         source ./.github/settings.sh
-        sudo apt -qq -y install clang-10
-        ./.github/bin/set-compiler.sh 9
+        ./.github/bin/set-compiler.sh 10
         ./.github/bin/install-bazel.sh
 
     - name: ${{ matrix.mode }} Verible
@@ -147,8 +172,8 @@
       uses: codecov/codecov-action@v2
       with:
         files: bazel-out/_coverage/_coverage_report.dat
-        fail_ci_if_error: true
         verbose: true
+      continue-on-error: true
 
     - name: Deployment
       if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && matrix.mode == 'compile'
@@ -159,6 +184,13 @@
         FOLDER: /tmp/pages
         CLEAN: true
 
+    - name: 📤 Upload performance graphs
+      uses: actions/upload-artifact@v2
+      if: success() || failure() 
+      with:
+        name: "diag"
+        path: "**/plot_*.svg"
+
 
   Kythe:
     runs-on: ubuntu-20.04
@@ -207,7 +239,8 @@
 
   Build:
     needs: Matrix
-    runs-on: ubuntu-20.04
+    container: debian:bullseye
+    runs-on: [self-hosted, Linux, X64]
     # Github actions resources are limited; don't build artifacts for all
     # platforms on every pull request, only on push.
     if: ${{github.event_name == 'push'}}
@@ -217,6 +250,8 @@
         include: ${{ fromJson(needs.Matrix.outputs.matrix) }}
     env:
       MATRIX_OS: '${{ matrix.os }}:${{ matrix.ver }}'
+      DOCKER_DATA_ROOT: "/root/.docker"
+      GHA_MACHINE_TYPE: "n2-highcpu-8"
     name: 'Build · ${{ matrix.os }}:${{ matrix.ver }}'
 
     steps:
@@ -226,11 +261,24 @@
        # Download complete repository + tags
        fetch-depth: 0
 
-    - run: docker pull $MATRIX_OS
+    - name: Install and setup Docker
+      run: "apt -qqy update && apt -qqy --no-install-recommends install docker.io cgroupfs-mount crun fuse-overlayfs pigz ca-certificates git && cgroupfs-mount"
 
     - name: Main script
       run: |
         set -x
+
+        mkdir -p "$DOCKER_DATA_ROOT"
+        dockerd \
+          -s fuse-overlayfs \
+          --add-runtime=crun=/usr/bin/crun \
+          --default-runtime=crun \
+          --config-file="" \
+          --data-root=$DOCKER_DATA_ROOT > /dev/null 2>&1 &
+        while ! test -S /var/run/docker.sock; do echo "Waiting for Docker..." && sleep 1; done; docker info
+        trap "kill $(cat /var/run/docker.pid)" EXIT
+
+        docker pull $MATRIX_OS
         source ./.github/settings.sh
         ./releasing/docker-run.sh $MATRIX_OS
 
@@ -239,6 +287,13 @@
       with:
         path: releasing/out/verible-*.tar.gz
 
+    - name: 📤 Upload performance graphs
+      uses: actions/upload-artifact@v2
+      if: success() || failure() 
+      with:
+        name: "diag"
+        path: "**/plot_*.svg"
+
   MacOsBuild:
     runs-on: macos-latest
     steps: