Skip to content

Refactor github workflows to DAG #1940

Refactor github workflows to DAG

Refactor github workflows to DAG #1940

Workflow file for this run

# 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:
workflow_dispatch:
inputs:
tpu-type:
description: 'TPU Type'
required: true
default: 'v4-8'
type: choice
options:
- v4-8
- v5litepod-8
push:
branches: ["main"]
pull_request: # By default this runs for types assigned, opened and synchronize.
jobs:
set-variables:
runs-on: [ubuntu-22.04]
outputs:
cluster-name: ${{ steps.set-cluster-name.outputs.cluster-name }}
group-name: ${{ steps.set-group-name.outputs.group-name }}
zone: ${{ steps.set-zone.outputs.zone }}
tpu-type: ${{ steps.set-tpu-type.outputs.tpu-type }}
location: ${{steps.set-location.outputs.location}}
steps:
- name: set cluster-name
id: set-cluster-name
run: |
echo cluster-name=build-xpk-2-nodepools-${{github.event.number}} >> $GITHUB_OUTPUT
- name: set group-name
id: set-group-name
run: |
echo group-name=xpk-pr-${{github.event.number}} >> $GITHUB_OUTPUT
- name: set zone
id: set-zone
run: |
echo zone=us-central2-b >> $GITHUB_OUTPUT
- name: set tpu-type
id: set-tpu-type
run: |
echo tpu-type=v4-8 >> $GITHUB_OUTPUT
- name: set location
id: set-location
run: |
echo location=us-central2 >> $GITHUB_OUTPUT
install-dependencies:
needs: [set-variables]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install dependencies
run: make install && make install-dev && make install-lint && make install-dev
- name: Cache dependencies
uses: actions/cache/save@v3
with:
path: |
~/.cache/pip
bin/
${{env.pythonLocation}}/lib/python3.10/site-packages/*
key: xpk-deps-3.10-${{github.event.number}}
linter:
needs: [install-dependencies, set-variables]
uses: ./.github/workflows/lint_and_format.yml
run-unit-tests:
uses: ./.github/workflows/unit_tests.yaml
needs: [linter, set-variables]
run-integration-tests:
uses: ./.github/workflows/integration_tests.yaml
secrets: inherit
needs: [run-unit-tests, set-variables]
cluster-private:
needs: [run-integration-tests, set-variables]
uses: ./.github/workflows/cluster_private.yaml
with:
cluster-name: '${{needs.set-variables.outputs.cluster-name}}'
tpu-type: '${{needs.set-variables.outputs.tpu-type || inputs.tpu-type}}'
zone: '${{needs.set-variables.outputs.zone}}'
location: '${{needs.set-variables.outputs.location}}'
secrets: inherit
cluster-create:
needs: [run-integration-tests, set-variables]
uses: ./.github/workflows/cluster_create.yaml
with:
cluster-name: '${{needs.set-variables.outputs.cluster-name}}'
tpu-type: '${{needs.set-variables.outputs.tpu-type || inputs.tpu-type}}'
zone: '${{needs.set-variables.outputs.zone}}'
location: '${{needs.set-variables.outputs.location}}'
secrets: inherit
workloads-tests:
needs: [cluster-create, set-variables]
uses: ./.github/workflows/workload_test.yaml
with:
cluster-name: ${{needs.set-variables.outputs.cluster-name}}
tpu-type: ${{needs.set-variables.outputs.tpu-type}}
zone: ${{needs.set-variables.outputs.zone}}
secrets: inherit
batch-tests:
needs: [cluster-create, set-variables]
uses: ./.github/workflows/batch_test.yaml
with:
cluster-name: ${{needs.set-variables.outputs.cluster-name}}
zone: ${{needs.set-variables.outputs.zone}}
secrets: inherit
cluster-delete:
if: always()
needs: [workloads-tests, batch-tests, set-variables]
uses: ./.github/workflows/cluster_delete.yaml
with:
cluster-name: ${{needs.set-variables.outputs.cluster-name}}
zone: ${{needs.set-variables.outputs.zone}}
secrets: inherit