"detection/git@developer.sourcefind.cn:OpenDAS/dcnv3.git" did not exist on "bdd98bcb7f7b96bb9e8afae7e3fe4a077e5d437c"
Commit ecf53ce2 authored by Pavithra Vijayakrishnan's avatar Pavithra Vijayakrishnan Committed by GitHub
Browse files

ci: skip test redundancy in Gitlab CI (#36)

parent dcecc47d
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# http://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: Main Branch Validation
on:
push:
branches:
- main
jobs:
build-test:
runs-on: ${{ fromJSON(vars.PR_FASTCHECK_RUNNERS) }}
strategy:
matrix:
framework:
- standard
- vllm
name: Build and Test - ${{ matrix.framework }}
env:
CONTAINER_ID: test_${{ github.run_id }}_${{ github.run_attempt }}_${{ github.job }}_${{ matrix.framework }}
IMAGE_TAG: ghcr.io/dynemo-ai/dynemo:latest-${{ matrix.framework }}
PYTEST_XML_FILE: pytest_test_report.xml
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Default cache location
id: which_cache
run: |
echo "cache_from_location=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
echo "cache_to_location=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
- name: Build image
env:
CACHE_FROM: "type=registry,ref=${{ steps.which_cache.outputs.cache_from_location }}"
CACHE_TO: "type=registry,ref=${{ steps.which_cache.outputs.cache_to_location }},image-manifest=true,mode=max"
run: |
./container/build.sh --tag ${{ env.IMAGE_TAG }} --framework ${{ matrix.framework }} --cache-from "${{ env.CACHE_FROM }}" --cache-to "${{ env.CACHE_TO }}"
- name: Run pytest
env:
PYTEST_MARKS: "pre_merge or mypy"
run: |
docker run -w /workspace --name ${{ env.CONTAINER_ID }} ${{ env.IMAGE_TAG }} pytest --basetemp=/tmp --junitxml=${{ env.PYTEST_XML_FILE }} -m "${{ env.PYTEST_MARKS }}"
- name: Copy test report from test Container
if: always()
run: |
docker cp ${{ env.CONTAINER_ID }}:/workspace/${{ env.PYTEST_XML_FILE }} .
- name: Archive test report
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.framework }}-python-test-results
if-no-files-found: error
path: |
${{ env.PYTEST_XML_FILE }}
\ No newline at end of file
......@@ -16,6 +16,9 @@
name: NVIDIA Test Github Validation
on:
push:
branches:
- main
pull_request:
paths-ignore:
- 'deploy/Kubernetes/**'
......@@ -32,7 +35,7 @@ jobs:
name: Build and Test - ${{ matrix.framework }}
env:
CONTAINER_ID: test_${{ github.run_id }}_${{ github.run_attempt }}_${{ github.job }}_${{ matrix.framework }}
IMAGE_TAG: ghcr.io/dynemo-ai/dynemo:pr_${{ github.event.pull_request.number}}_${{ matrix.framework }}
IMAGE_TAG: ghcr.io/dynemo-ai/dynemo:latest-${{ matrix.framework }}
PYTEST_XML_FILE: pytest_test_report.xml
steps:
- name: Checkout repository
......@@ -45,20 +48,26 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set IMAGE_TAG based on Event
id: set_image_tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "IMAGE_TAG=ghcr.io/dynemo-ai/dynemo:pr_${{ github.event.pull_request.number }}_${{ matrix.framework }}" >> $GITHUB_ENV
fi
- name: Decide on cache
id: which_cache
env:
DEFAULT_CACHE_LOCATION: ghcr.io/dynemo-ai/dynemo:latest-${{ matrix.framework }}
CACHE_LOCATION: ghcr.io/dynemo-ai/dynemo:latest-${{ matrix.framework }}
run: |
set +e
docker manifest inspect ${{ env.IMAGE_TAG }}
if [ $? -eq 0 ]; then
echo "USING ${{ env.IMAGE_TAG }}"
echo "cache_from_location=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
else
echo "USING ${{ env.DEFAULT_CACHE_LOCATION }}"
echo "cache_from_location=${{ env.DEFAULT_CACHE_LOCATION }}" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "pull_request" ]; then
docker manifest inspect ${{ env.IMAGE_TAG }}
if [ $? -eq 0 ]; then
echo "USING ${{ env.IMAGE_TAG }}"
echo "CACHE_LOCATION=${{ env.IMAGE_TAG }}" >> $GITHUB_ENV
fi
fi
echo "cache_from_location=${{ env.CACHE_LOCATION }}" >> $GITHUB_OUTPUT
echo "cache_to_location=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT
- name: Build image
env:
......@@ -87,9 +96,10 @@ jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Upload
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: Event File
path: ${{ github.event_path }}
path: ${{ github.event_path }}
\ No newline at end of file
......@@ -52,10 +52,40 @@ jobs:
- 'container/deps/vllm/**'
sdk:
- 'deploy/compoundai/**'
- name: Check if Validation Workflow has run
id: check_workflow
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const eventName = context.eventName;
let commit_sha = context.sha;
const workflow_id = 'pre-merge-python.yml';
if (eventName === 'pull_request') {
commit_sha = context.payload.pull_request.head.sha;
}
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow_id,
head_sha: commit_sha,
event: eventName
});
const inProgressCount = runs.data.workflow_runs.filter(run => run.status === 'in_progress').length;
const queuedCount = runs.data.workflow_runs.filter(run => run.status === 'queued').length;
const skip_ci = inProgressCount > 0 || queuedCount > 0;
console.log(`Validation Workflow is running: ${skip_ci}`);
core.setOutput('skip_ci', skip_ci.toString());
- name: Trigger Pipeline
run: |
#!/bin/bash -e
declare -A ci_variables
if [[ "${{ vars.ALLOW_GITLAB_TEST_SKIP }}" == "1" && "${{ steps.check_workflow.outputs.skip_ci }}" == "true" ]]; then
echo "Github Workflow has run and RUN_PRE_MERGE_TESTS variable value is False"
ci_variables["RUN_PRE_MERGE_TESTS"]="false"
fi
if [ "${{ steps.src_changes.outputs.vllm }}" == "true" ]; then
ci_variables["RUN_VLLM"]="true"
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment