diff --git a/.github/workflows/cicd-main.yml b/.github/workflows/cicd-main.yml index b43cc0fa..f0d9babc 100644 --- a/.github/workflows/cicd-main.yml +++ b/.github/workflows/cicd-main.yml @@ -29,10 +29,16 @@ permissions: contents: read jobs: + pre-flight: + uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@main cicd-wait-in-queue: + needs: [pre-flight] runs-on: ubuntu-latest environment: test + if: | + needs.pre-flight.outputs.is_ci_workload == 'false' + && needs.pre-flight.outputs.docs_only == 'false' steps: - name: Running CI tests run: | @@ -62,10 +68,17 @@ jobs: runner: linux-amd64-cpu16 timeout: 30 cpu-only: true - needs: [cicd-container-build] + needs: [pre-flight, cicd-container-build] runs-on: ${{ matrix.runner }} name: ${{ matrix.script }} environment: nemo-ci + if: | + ( + success() + || needs.pre-flight.outputs.is_ci_workload == 'true' + || needs.pre-flight.outputs.force_run_all == 'true' + ) + && !cancelled() steps: - name: Checkout uses: actions/checkout@v4 @@ -85,9 +98,17 @@ jobs: Nemo_CICD_Test: needs: + - pre-flight - cicd-container-build - cicd-unit-tests - if: always() + if: | + ( + needs.pre-flight.outputs.docs_only == 'true' + || needs.pre-flight.outputs.is_deployment_workflow == 'true' + || needs.pre-flight.outputs.is_ci_workload == 'true' + || always() + ) + && !cancelled() runs-on: ubuntu-latest permissions: write-all steps: @@ -99,13 +120,15 @@ jobs: env: GH_TOKEN: ${{ github.token }} RUN_ID: ${{ github.run_id }} + DOCS_ONLY: ${{ needs.pre-flight.outputs.docs_only }} + IS_DEPLOYMENT: ${{ needs.pre-flight.outputs.is_deployment_workflow }} + IS_CI_WORKLOAD: ${{ needs.pre-flight.outputs.is_ci_workload }} run: | # Get workflow run details and check job conclusions - LATEST_ATTEMPT=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion != null) | .conclusion] | last') NUM_FAILED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "failure") | .name] | length') NUM_CANCELLED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "cancelled") | .name] | length') - if [[ $NUM_FAILED -eq 0 && $NUM_CANCELLED -eq 0 ]]; then + if [[ ($NUM_FAILED -eq 0 && $NUM_CANCELLED -eq 0) || $DOCS_ONLY == 'true' || $IS_DEPLOYMENT == 'true' || $IS_CI_WORKLOAD == 'true' ]]; then RESULT="success" elif [[ $NUM_CANCELLED -gt 0 ]]; then RESULT="cancelled" @@ -180,9 +203,41 @@ jobs: exit 1 fi + Coverage_Fake: + runs-on: ubuntu-latest + needs: [Nemo_CICD_Test, pre-flight] + if: | + ( + needs.pre-flight.outputs.docs_only == 'true' + || needs.pre-flight.outputs.is_deployment_workflow == 'true' + ) + && needs.pre-flight.outputs.is_ci_workload == 'false' + && !cancelled() + environment: nemo-ci + steps: + - name: Generate fake coverage report + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.PAT }} + script: | + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: context.sha, + state: 'success', + description: 'No code changes - coverage check skipped', + context: 'codecov/patch' + }); + Coverage: runs-on: ubuntu-latest - needs: [Nemo_CICD_Test] + needs: [pre-flight, Nemo_CICD_Test] + if: | + ( + (needs.pre-flight.outputs.is_ci_workload == 'true' && !failure()) + || success() + ) + && !cancelled() strategy: matrix: flag: [unit-test]