ci: optimize dependency management by using module cache instead of vendor directory #2481
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2025 NVIDIA CORPORATION | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: KAI Scheduler - Pull Request | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| concurrency: | |
| group: ${{ github.head_ref || github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate-and-test: | |
| name: Validate & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.4' | |
| - name: Run validation | |
| run: make validate | |
| - name: Run tests | |
| run: make test | |
| - name: Archive code coverage results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: code-coverage | |
| path: coverage/coverage.out | |
| code-coverage-report: | |
| name: Code Coverage Report | |
| runs-on: ubuntu-latest | |
| needs: validate-and-test | |
| steps: | |
| - uses: fgrosse/go-coverage-report@8c1d1a09864211d258937b1b1a5b849f7e4f2682 | |
| id: coverage_reporter | |
| with: | |
| coverage-artifact-name: "code-coverage" | |
| coverage-file-name: "coverage.out" | |
| root-package: "github.com/NVIDIA/KAI-scheduler" | |
| github-baseline-workflow-ref: update-coverage-badge.yaml | |
| skip-comment: true | |
| - name: Save coverage report to file | |
| env: | |
| REPORT_BODY: ${{ steps.coverage_reporter.outputs.coverage_report }} | |
| run: echo "$REPORT_BODY" > coverage-report.txt | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-for-comment | |
| path: coverage-report.txt | |
| - name: Save PR number | |
| run: echo "${{ github.event.number }}" > pr_number.txt | |
| - name: Upload PR number | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-number-for-comment | |
| path: pr_number.txt | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| package_version: ${{ steps.package_version.outputs.PACKAGE_VERSION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract package version | |
| id: package_version | |
| run: | | |
| GIT_REV=$(git rev-parse --short HEAD | sed 's/^0*//') | |
| PACKAGE_VERSION=0.0.0-$GIT_REV | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT | |
| echo $PACKAGE_VERSION | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.4' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create image cache directory | |
| run: mkdir images | |
| - name: Cache for docker images and helm chart | |
| uses: actions/cache@v4 | |
| with: | |
| path: images | |
| key: images-${{ github.sha }} | |
| - name: Build docker images | |
| run: | | |
| make build DOCKER_BUILDX_ADDITIONAL_ARGS=--load VERSION=$PACKAGE_VERSION | |
| docker save $(docker images --format '{{.Repository}}:{{.Tag}}' | grep $PACKAGE_VERSION) | gzip > images/docker_images.tgz | |
| - name: Build helm chart | |
| run: | | |
| helm package ./deployments/kai-scheduler -d ./charts --app-version $PACKAGE_VERSION --version $PACKAGE_VERSION | |
| cp charts/kai-scheduler-$PACKAGE_VERSION.tgz images/ | |
| e2e-tests: | |
| name: Run E2E Tests | |
| needs: [ build ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: images | |
| key: images-${{ github.sha }} | |
| - name: Create k8s Kind Cluster | |
| uses: helm/[email protected] | |
| with: | |
| cluster_name: kind | |
| version: v0.30.0 | |
| config: ./hack/e2e-kind-config.yaml | |
| - name: Deploy image registry | |
| run: | | |
| kubectl apply -f ./hack/local_registry.yaml | |
| kubectl wait --for=condition=available --timeout=60s deployment/registry -n kube-registry | |
| - name: Load docker images to registry | |
| working-directory: images | |
| env: | |
| PACKAGE_VERSION: ${{ needs.build.outputs.package_version }} | |
| run: | | |
| kubectl port-forward -n kube-registry deploy/registry 5000:5000 & | |
| docker load < docker_images.tgz | |
| for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep $PACKAGE_VERSION); do | |
| new_image=$(echo "$image" | sed -E 's|.*/([^/]+:[^/]+)$|localhost:5000/\1|') | |
| docker tag $image $new_image | |
| docker push $new_image | |
| done | |
| - name: Deploy fake gpu operator | |
| run: | | |
| helm upgrade -i gpu-operator oci://ghcr.io/run-ai/fake-gpu-operator/fake-gpu-operator --namespace gpu-operator --create-namespace \ | |
| --version 0.0.62 --values ./hack/fake-gpu-operator-values.yaml --wait | |
| - name: install KAI-scheduler | |
| env: | |
| PACKAGE_VERSION: ${{ needs.build.outputs.package_version }} | |
| run: | | |
| helm upgrade -i kai-scheduler ./images/kai-scheduler-$PACKAGE_VERSION.tgz -n kai-scheduler --create-namespace \ | |
| --set "global.gpuSharing=true" --set "global.registry=localhost:30100" --debug --wait | |
| - name: Set up Go | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: 1.22 | |
| - name: Install ginkgo | |
| run: | | |
| go install github.com/onsi/ginkgo/v2/[email protected] | |
| - name: Delete images from disk | |
| env: | |
| PACKAGE_VERSION: ${{ needs.build.outputs.package_version }} | |
| run: | | |
| docker images --format '{{.Repository}}:{{.Tag}}' | grep $PACKAGE_VERSION | xargs docker rmi -f | |
| rm -rf images | |
| - name: Run e2e tests | |
| run: | | |
| ginkgo -r --keep-going --randomize-all --randomize-suites --trace -vv --label-filter '!autoscale && !scale' ./test/e2e/suites |