Skip to content

Commit

Permalink
Add conda builds to CI (#1466)
Browse files Browse the repository at this point in the history
* Adds a conda build CI step

Requires PR #1462 to be merged first

## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/nv-morpheus/Morpheus/blob/main/docs/source/developer_guide/contributing.md).
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

Authors:
  - David Gardner (https://github.com/dagardner-nv)
  - Michael Demoret (https://github.com/mdemoret-nv)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)

URL: #1466
  • Loading branch information
dagardner-nv authored Feb 1, 2024
1 parent ff24174 commit 16ca5df
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 5 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci_pipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ on:
run_check:
required: true
type: boolean
conda_run_build:
description: 'Runs the conda-build stage to ensure the conda package builds successfully'
required: true
type: boolean
conda_upload_label:
description: 'The label to use when uploading the conda package. Leave empty to disable uploading'
required: true
type: string
container:
required: true
type: string
Expand Down Expand Up @@ -183,3 +191,40 @@ jobs:
- name: build_docs
shell: bash
run: ./morpheus/ci/scripts/github/docs.sh

package:
name: Package
if: ${{ inputs.conda_run_build }}
needs: [check, documentation, test]
runs-on: linux-amd64-cpu16
timeout-minutes: 60
container:
credentials:
username: '$oauthtoken'
password: ${{ secrets.NGC_API_KEY }}
image: ${{ inputs.container }}
strategy:
fail-fast: true

steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: false
path: 'morpheus'
fetch-depth: 0

- name: Get AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 43200 # 12h

- name: conda
shell: bash
env:
CONDA_TOKEN: "${{ secrets.CONDA_TOKEN }}"
SCRIPT_ARGS: "${{ inputs.conda_upload_label != '' && 'upload' || '' }}"
CONDA_PKG_LABEL: "${{ inputs.conda_upload_label }}"
run: ./morpheus/ci/scripts/github/conda.sh $SCRIPT_ARGS
15 changes: 14 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ jobs:
uses: rapidsai/shared-action-workflows/get-pr-info@branch-23.08
if: ${{ startsWith(github.ref_name, 'pull-request/') }}
outputs:
is_pr: ${{ startsWith(github.ref_name, 'pull-request/') }}
is_main_branch: ${{ github.ref_name == 'main' }}
is_dev_branch: ${{ startsWith(github.ref_name, 'branch-') }}
has_conda_build_label: ${{ steps.get-pr-info.outcome == 'success' && contains(fromJSON(steps.get-pr-info.outputs.pr-info).labels.*.name, 'conda-build') || false }}
has_skip_ci_label: ${{ steps.get-pr-info.outcome == 'success' && contains(fromJSON(steps.get-pr-info.outputs.pr-info).labels.*.name, 'skip-ci') || false }}
pr_info: ${{ steps.get-pr-info.outcome == 'success' && steps.get-pr-info.outputs.pr-info || '' }}

checks:
secrets: inherit
Expand All @@ -81,8 +86,16 @@ jobs:
# Only run the CI pipeline if the PR does not have the skip-ci label
if: ${{ ! fromJSON(needs.prepare.outputs.has_skip_ci_label) }}
with:
run_check: ${{ startsWith(github.ref_name, 'pull-request/') }}
# Run checks for any PR branch
run_check: ${{ fromJSON(needs.prepare.outputs.is_pr) }}
# Run conda-build for main/dev branches and PRs with the conda-build label
conda_run_build: ${{ !fromJSON(needs.prepare.outputs.is_pr) || fromJSON(needs.prepare.outputs.has_conda_build_label) }}
# Update conda package only for non PR branches. Use 'main' for main branch and 'dev' for all other branches
# Disable conda upload for now, once we have morpheus packages in conda forge set the value to
# !fromJSON(needs.prepare.outputs.is_pr) && (fromJSON(needs.prepare.outputs.is_main_branch) && 'main' || 'dev') || ''
conda_upload_label: ""
container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-build-230913
test_container: nvcr.io/ea-nvidia-morpheus/morpheus:morpheus-ci-test-230913
# Info about the PR. Empty for non PR branches. Useful for extracting PR number, title, etc.
secrets:
NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
1 change: 1 addition & 0 deletions ci/conda/recipes/morpheus/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ outputs:
- cuda-cudart-dev {{ cuda_compiler_version }} # Needed by CMake to compile a test application
- libtool # Needed for DOCA build
- ninja
- pkg-config # for mrc cmake
host:
- cuda-toolkit {{ cuda_compiler_version }}
- cudf {{ rapids_version }}
Expand Down
63 changes: 63 additions & 0 deletions ci/scripts/github/conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2024, 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.

set -e

CI_SCRIPT_ARGS="$@"
source ${WORKSPACE}/ci/scripts/github/common.sh

cd ${MORPHEUS_ROOT}

fetch_base_branch

git submodule update --init --recursive

# Its important that we are in the base environment for the build
rapids-logger "Activating Base Conda Environment"

# Deactivate any extra environments (There can be a few on the stack)
while [[ "${CONDA_SHLVL:-0}" -gt 1 ]]; do
echo "Deactivating conda environment ${CONDA_DEFAULT_ENV}"
conda deactivate
done

# Ensure at least base is activated
if [[ "${CONDA_DEFAULT_ENV}" != "base" ]]; then
echo "Activating base conda environment"
conda activate base
fi

# Print the info just to be sure base is active
conda info

rapids-logger "Building Conda Package"

# Run the conda build, and upload to conda forge if requested
export MORPHEUS_PYTHON_BUILD_STUBS=OFF
export CONDA_ARGS="--skip-existing"
${MORPHEUS_ROOT}/ci/conda/recipes/run_conda_build.sh morpheus "${CI_SCRIPT_ARGS}"

# If we didn't receive the upload argument, upload the artifact to S3
if [[ " ${CI_SCRIPT_ARGS} " =~ " upload " ]]; then
rapids-logger "Building Conda Package... Done"
else
# if we didn't receive the upload argument, we can still upload the artifact to S3
tar cfj "${WORKSPACE_TMP}/conda.tar.bz" "${RAPIDS_CONDA_BLD_OUTPUT_DIR}"
ls -lh ${WORKSPACE_TMP}/

rapids-logger "Pushing results to ${DISPLAY_ARTIFACT_URL}/"
upload_artifact "${WORKSPACE_TMP}/conda.tar.bz"
fi
8 changes: 4 additions & 4 deletions ci/scripts/run_ci_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -exo pipefail
set -eo pipefail

case "$1" in
"" )
STAGES=("bash")
;;
"all" )
STAGES=("checks" "build" "docs" "test")
STAGES=("checks" "build" "docs" "test" "conda")
;;
"checks" | "build" | "docs" | "test" | "bash" )
"checks" | "build" | "docs" | "test" | "conda" | "bash" )
STAGES=("$1")
;;
* )
echo "Error: Invalid argument \"$1\" provided. Expected values: \"all\", \"checks\", \"build\", \"docs\", \"test\", or \"bash\""
echo "Error: Invalid argument \"$1\" provided. Expected values: \"all\", \"checks\", \"build\", \"docs\", \"test\", \"conda\", or \"bash\""
exit 1
;;
esac
Expand Down

0 comments on commit 16ca5df

Please sign in to comment.