Repository: AI-Hypercomputer/xpk (language: python)

Issue:
Create Github runner to execute xpk on vm.
This is a great integration test to verify that xpk can be setup on a vm. We want to run this on the newest available vm that we expect customers to use and then potentially support previous versions as well.


Discussion / hints:
Doesn't need to be TPU 

Fix patch:
diff --git a/.github/workflows/README.md b/.github/workflows/README.md
new file mode 100644
index 00000000..c20553d1
--- /dev/null
+++ b/.github/workflows/README.md
@@ -0,0 +1,28 @@
+<!--
+ Copyright 2024 Google LLC
+
+ 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
+
+      https://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.
+ -->
+
+# Integration Test Workflows
+The following tests are currently implemented through Github Actions:
+* Create an XPK Cluster with zero node pools
+* Delete the cluster created
+* Create an XPK Cluster with 2x v4-8 nodepools
+* Delete the cluster created
+
+## Nightly Tests:
+A cron job is scheduled to run at 12AM PST daily. The details of the jobs run are in `xpk/.github/workflows/nightly_tests.yaml`
+
+## Integration Tests:
+Integration tests are run on a push to the `main` branch and on an approved PR. The details of the jobs run are in `xpk/.github/workflows/build_tests.yaml`
diff --git a/README.md b/README.md
index b3bb7001..9fa72cd6 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,8 @@
  limitations under the License.
  -->
 
+[![Builds](https://github.com/google/xpk/actions/workflows/build_tests.yaml/badge.svg)](https://github.com/google/xpk/actions/workflows/build_tests.yml)
+
 # Overview
 
 xpk (Accelerated Processing Kit, pronounced x-p-k,) is a software tool to help
@@ -495,6 +497,13 @@ environment from a file. Usage is the same as Docker's
 Passing this flag sets the XLA_FLAGS='--xla_dump_to=/tmp/xla_dump/' and uploads
 hlo dumps to the specified GCS bucket for each worker.
 
+# Integration Test Workflows
+The repository code is tested through Github Workflows and Actions. Currently three kinds of tests are performed:
+* A nightly build that runs every 24 hours
+* A build that runs on push to `main` branch
+* A build that runs for every PR approval
+
+More information is documented [here](https://github.com/google/xpk/tree/main/.github/workflows)
 
 # Troubleshooting
 


Test patch:
diff --git a/.github/workflows/build_tests.yaml b/.github/workflows/build_tests.yaml
new file mode 100644
index 00000000..f6c6c3c0
--- /dev/null
+++ b/.github/workflows/build_tests.yaml
@@ -0,0 +1,50 @@
+# Copyright 2024 Google LLC
+#
+# 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
+#
+#      https://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: Build Tests
+
+on:
+  push:
+    branches: ["main"]
+  pull_request_review:
+    types: [submitted]
+
+jobs:
+  cluster-create-and-delete:   
+    if: ${{ (github.event.review.state == 'approved') || (github.event_name == 'push')}} 
+    runs-on: [ubuntu-20.04]
+    steps:
+    - uses: actions/checkout@v4
+    - uses: actions/setup-python@v5
+      with:
+        python-version: '3.10'
+    - uses: 'google-github-actions/auth@v2'
+      with:
+        credentials_json: '${{ secrets.GCP_SA_KEY }}'
+    - uses: google-github-actions/setup-gcloud@v2
+      with:
+        version: '>= 363.0.0'
+        install_components: 'beta,gke-gcloud-auth-plugin'
+    - name: Verify gcp setup 
+      run: gcloud info
+    - name: Create an XPK Cluster with 2x v4-8 nodepools
+      run: python xpk.py cluster create --cluster test-2-v4-8-nodepool --device-type=v4-8  --num-slices=2 --zone=us-central2-b --default-pool-cpu-machine-type=n1-standard-8 --spot --custom-cluster-arguments='${{ secrets.CLUSTER_ARGUMENTS }}'
+    - name: Delete the cluster created
+      run: python xpk.py cluster delete --cluster test-2-v4-8-nodepool --zone=us-central2-b
+
+
+
+
+
+
diff --git a/.github/workflows/nightly_tests.yaml b/.github/workflows/nightly_tests.yaml
new file mode 100644
index 00000000..0db7d0b1
--- /dev/null
+++ b/.github/workflows/nightly_tests.yaml
@@ -0,0 +1,53 @@
+# Copyright 2024 Google LLC
+#
+# 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
+#
+#      https://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: Nightly Tests
+
+on:
+  workflow_dispatch:
+  schedule: #schedule the job run at 12AM PST daily
+    - cron: '0 8 * * *' 
+
+jobs:
+  cluster-create-and-delete:   
+    runs-on: [ubuntu-20.04]
+    steps:
+    - uses: actions/checkout@v4
+    - uses: actions/setup-python@v5
+      with:
+        python-version: '3.10'
+    - uses: 'google-github-actions/auth@v2'
+      with:
+        credentials_json: '${{ secrets.GCP_SA_KEY }}'
+    - uses: google-github-actions/setup-gcloud@v2
+      with:
+        version: '>= 363.0.0'
+        install_components: 'beta,gke-gcloud-auth-plugin'
+    - name: Verify gcp setup 
+      run: gcloud info
+    - name: Create an XPK Cluster with zero node pools
+      run: python xpk.py cluster create --cluster test-zero-nodepool --device-type=v4-8  --num-slices=0 --zone=us-central2-b --default-pool-cpu-machine-type=n1-standard-8 --spot --custom-cluster-arguments='${{ secrets.CLUSTER_ARGUMENTS }}'
+    - name: Delete the cluster created
+      run: python xpk.py cluster delete --cluster test-zero-nodepool --zone=us-central2-b 
+    - name: Create an XPK Cluster with 2x v4-8 nodepools  
+      run: python xpk.py cluster create --cluster test-2-v4-8-nodepool --device-type=v4-8  --num-slices=2 --zone=us-central2-b --default-pool-cpu-machine-type=n1-standard-8 --spot --custom-cluster-arguments='${{ secrets.CLUSTER_ARGUMENTS }}'
+    - name: Delete the cluster created
+      run: python xpk.py cluster delete --cluster test-2-v4-8-nodepool --zone=us-central2-b
+
+
+
+
+
+
+