Skip to content

Commit

Permalink
Adding support for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepd-nv committed Aug 8, 2024
1 parent cdc47da commit 0aefacd
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ runs:
ls -lahR ${{ env.ARTIFACTS_DIR }}
<% endif %>

- if: github.repository_owner == 'nv-legate'
- if: github.repository_owner == 'nvidia'
name: Get AWS credentials for sccache bucket
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/download-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
name: Cache conda artifacts
uses: actions/cache@v4
with:
key: "nv-legate/${{ inputs.artifact-repo }}@${{ inputs.platform }}-${{ inputs.git_sha }}-${{ inputs.target-device }}"
key: "nvidia/{ inputs.artifact-repo }}@${{ inputs.platform }}-${{ inputs.git_sha }}-${{ inputs.target-device }}"
path: ${{ inputs.dest-dir }}

- if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -45,7 +45,7 @@ runs:
with:
github_token: ${{ inputs.inter-repos-ro-access-token }}
path: ${{ inputs.dest-dir }}
repo: nv-legate/${{ inputs.artifact-repo }}
repo: nvidia/${{ inputs.artifact-repo }}
check_artifacts: true
commit: ${{ inputs.git_sha }}
workflow_conclusion: ""
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ runs:
pwd
ls -lahR $ARTIFACTS_DIR
- name: Make test env
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
"${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint" "${{ env.REPO_DIR }}/continuous_integration/scripts/make-conda-env" test
- name: Run test / analysis
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
. conda-utils
activate_conda_env
"${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint" "${{ env.REPO_DIR }}/continuous_integration/scripts/test" ${{ inputs.test-options }}
90 changes: 90 additions & 0 deletions .github/workflows/gh-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,93 @@ jobs:
build-mode: ${{ inputs.build-mode }}
upload-enabled: ${{ inputs.upload-enabled }}
secrets: inherit

setup-test:
name: Setup test
if: inputs.upload-enabled == false
needs:
- build
runs-on: linux-amd64-cpu4
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
set -xeuo pipefail
MATRIX_JSON='{"include": ['
RUNNERS=('linux-amd64-gpu-v100-latest-1:gpu:linux')
TEST_CONFIGS=('Unit Tests:unit' 'Samples:samples')
for RUNNER in "${RUNNERS[@]}"; do
IFS=':' read -ra RUNNER_INFO <<< "$RUNNER"
RUNNER_NAME=${RUNNER_INFO[0]}
TARGET_DEVICE=${RUNNER_INFO[1]}
RUNNER_PLATFORM=${RUNNER_INFO[2]}
if [[ "$TARGET_DEVICE" == "${{ inputs.target-device }}" && "$RUNNER_PLATFORM" == "${{ inputs.platform }}" ]]; then
for TEST_CONFIG in "${TEST_CONFIGS[@]}"; do
IFS=':' read -ra CONFIG_INFO <<< "$TEST_CONFIG"
CONFIG_NAME=${CONFIG_INFO[0]}
CONFIG_SCOPE=${CONFIG_INFO[1]}
MATRIX_JSON+="{\"runner\": {\"name\": \"$RUNNER_NAME\", \"type\": \"$TARGET_DEVICE\", \"platform\": \"$RUNNER_PLATFORM\"}, \"test-config\": {\"name\": \"$CONFIG_NAME\", \"test-scope\": \"$CONFIG_SCOPE\"}},"
done
fi
done
MATRIX_JSON=$(echo "$MATRIX_JSON" | sed 's/,$//') # Remove the trailing comma
MATRIX_JSON+=']}'
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
test-within-container:
if: github.repository_owner == 'nvidia' && (inputs.platform == 'linux-x64' || inputs.platform == 'linux-aarch64')
needs:
- setup-test

name: ${{ matrix.test-config.name }} (${{ inputs.platform }}, ${{ inputs.target-device }}, ${{ inputs.build-mode }})

strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup-test.outputs.matrix)}}

uses:
./.github/workflows/gh-test-within-container.yml
with:
client-repo: ${{ github.event.repository.name }}
build-type: ${{ inputs.build-type }}
name: ${{ matrix.test-config.name }}
target-device: ${{ inputs.target-device }}
runs-on: ${{ matrix.runner.name }}
has-gpu: ${{ matrix.runner.type == 'gpu' }}
test-options: ${{ matrix.test-config.test-scope }}
platform: ${{ matrix.runner.platform }}
build-mode: ${{ inputs.build-mode }}
upload-enabled: ${{ inputs.upload-enabled }}
secrets: inherit


test-without-container:
if: github.repository_owner == 'nv-legate' && (inputs.platform != 'linux-x64' && inputs.platform != '-aarch64')
needs:
- setup-test

name: ${{ matrix.test-config.name }} (${{ inputs.platform }}, ${{ inputs.target-device }}, ${{ inputs.build-mode }})

strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup-test.outputs.matrix)}}

uses:
./.github/workflows/gh-test-without-container.yml
with:
client-repo: ${{ github.event.repository.name }}
build-type: ${{ inputs.build-type }}
name: ${{ matrix.test-config.name }}
target-device: ${{ inputs.target-device }}
runs-on: ${{ matrix.runner.name }}
has-gpu: ${{ matrix.runner.type == 'gpu' }}
test-options: ${{ matrix.test-config.test-scope }}
platform: ${{ matrix.runner.platform }}
build-mode: ${{ inputs.build-mode }}
upload-enabled: ${{ inputs.upload-enabled }}
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/gh-test-within-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ on:
jobs:
test:
name: ${{ inputs.name }}
if: github.repository_owner == 'nv-legate'
if: github.repository_owner == 'nvidia
runs-on: ${{ inputs.runs-on }}

container:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-test-without-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ on:
jobs:
test:
name: ${{ inputs.name }}
if: github.repository_owner == 'nv-legate'
if: github.repository_owner == 'nvidia'
runs-on: ${{ inputs.runs-on }}

defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ on:
jobs:
upload:
name: ${{ inputs.name }}
if: github.repository_owner == 'nv-legate'
if: github.repository_owner == 'nvidia'
runs-on: linux-amd64-gpu-v100-earliest-1

container:
Expand Down
File renamed without changes.
14 changes: 13 additions & 1 deletion continuous_integration/scripts/make-conda-env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
set -x

make_ci_env() {
mamba env create -n "${CONDA_ENV}" -f "${REPO_DIR}/continuous_integration/environment.yml"
mamba env create -n "${CONDA_ENV}" -f "${REPO_DIR}/continuous_integration/build-environment.yml"
}

make_test_env() {
. conda-utils

mamba env create -n "${CONDA_ENV}" -f "${REPO_DIR}/continuous_integration/test-environment.yml"

activate_conda_env

pip install "${ARTIFACTS_DIR}/*.whl"

}

make_conda_env() {
Expand All @@ -14,6 +25,7 @@ make_conda_env() {

case "$1" in
ci) make_ci_env;;
test) make_test_env;;
*) return 1;;
esac

Expand Down
29 changes: 29 additions & 0 deletions continuous_integration/scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

run_test_or_analysis() {
set -x

conda_info;

set -xeuo pipefail

case "$1" in
"unit")
echo "Executing unit tests..."
python -m pytest
;;
"samples")
echo "Running samples..."
python -m pytest examples
;;

*)
echo "Invalid command: $1"
return 1
;;
esac

return 0
}

(run_test_or_analysis "$@");
2 changes: 1 addition & 1 deletion continuous_integration/scripts/vault-s3-init
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ vault_s3_init() {
echo ""

local vault_token=null;
local user_orgs=nv-legate;
local user_orgs=nvidia;

# Attempt to authenticate with GitHub
eval "$(get_vault_token "${VAULT_HOST}" ${user_orgs} "$GH_TOKEN")";
Expand Down
9 changes: 9 additions & 0 deletions continuous_integration/test-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: cupy
channels:
- defaults
dependencies:
- python=3.11
- pytest>=6.2.4
- pip
- pip:
- pytest-benchmark>=3.4.1

0 comments on commit 0aefacd

Please sign in to comment.