Skip to content

Commit 5ffa6b7

Browse files
committed
Adding support for CI testing.
1 parent 750d541 commit 5ffa6b7

File tree

6 files changed

+195
-3
lines changed

6 files changed

+195
-3
lines changed

.github/actions/build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ runs:
5454
--rm "${{ inputs.docker-image }}" \
5555
/bin/bash -c "${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint ${{ env.REPO_DIR }}/continuous_integration/scripts/build ${{ inputs.build-type}} ${{ inputs.target-device }}"
5656
57-
- if: ${{ !inputs.use-container }}
57+
- if: ${{ !inputs.use-container && steps.cache-build.outputs.cache-hit != 'true'}}
5858
name: Build (without container)
5959
shell: bash --noprofile --norc -xeuo pipefail {0}
6060
run: |

.github/actions/test/action.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: test
2+
3+
description: Run tests in specified project
4+
5+
inputs:
6+
test-options:
7+
required: true
8+
type: string
9+
runner-has-gpu:
10+
required: true
11+
type: boolean
12+
description: "The runner has GPU(s)."
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- if: ${{ inputs.runner-has-gpu == true }}
18+
name: Run nvidia-smi to make sure GPU is working
19+
shell: bash --noprofile --norc -xeuo pipefail {0}
20+
run: nvidia-smi
21+
22+
- name: Download build artifacts
23+
uses: actions/download-artifact@v4
24+
with:
25+
name: ${{ env.ARTIFACT_NAME }}
26+
path: ${{ env.ARTIFACTS_DIR }}
27+
28+
- name: Display structure of downloaded artifacts
29+
shell: bash --noprofile --norc -xeuo pipefail {0}
30+
run: |
31+
pwd
32+
ls -lahR $ARTIFACTS_DIR
33+
34+
- name: Run test / analysis
35+
shell: bash --noprofile --norc -xeuo pipefail {0}
36+
run: |
37+
"${{ env.REPO_DIR }}/continuous_integration/scripts/entrypoint" "${{ env.REPO_DIR }}/continuous_integration/scripts/test" ${{ inputs.test-options }}

.github/workflows/gh-build-and-test.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,28 @@ jobs:
2727
with:
2828
client-repo: ${{ github.event.repository.name }}
2929
target-device: ${{ inputs.target-device }}
30-
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu16') || (inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu16') || (inputs.host-platform == 'mac' && 'macos-latest') }}
30+
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu8') || (inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu16') || (inputs.host-platform == 'mac' && 'macos-latest') }}
31+
build-type: ${{ inputs.build-type }}
32+
use-container: false
33+
host-platform: ${{ inputs.host-platform }}
34+
dependencies-file: ""
35+
build-mode: ${{ inputs.build-mode }}
36+
upload-enabled: ${{ inputs.upload-enabled }}
37+
secrets: inherit
38+
39+
test:
40+
if: ${{ github.repository_owner == 'nvidia' }}
41+
needs:
42+
- build
43+
uses:
44+
./.github/workflows/gh-test.yml
45+
with:
46+
client-repo: ${{ github.event.repository.name }}
47+
target-device: ${{ inputs.target-device }}
48+
test-options: ${{ inputs.build-type }}
49+
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-gpu-v100-latest-1') || (inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu16') || (inputs.host-platform == 'mac' && 'macos-latest') }}
50+
runner-has-gpu: ${{ inputs.host-platform == 'linux-x64' }}
3151
build-type: ${{ inputs.build-type }}
32-
use-container: ${{ inputs.host-platform == 'linux-x64' || inputs.host-platform == 'linux-aarch64'}}
3352
host-platform: ${{ inputs.host-platform }}
3453
dependencies-file: ""
3554
build-mode: ${{ inputs.build-mode }}

.github/workflows/gh-test.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
client-repo:
7+
required: true
8+
type: string
9+
target-device:
10+
required: true
11+
type: string
12+
test-options:
13+
required: true
14+
type: string
15+
runs-on:
16+
required: true
17+
type: string
18+
runner-has-gpu:
19+
required: true
20+
type: boolean
21+
description: "The runner has GPU(s)."
22+
build-type:
23+
required: true
24+
type: string
25+
description: One of ci / release
26+
host-platform:
27+
required: true
28+
type: string
29+
dependencies-file:
30+
required: true
31+
type: string
32+
description: path to versions.json relative to the target repo dir
33+
build-mode:
34+
required: true
35+
type: string
36+
upload-enabled:
37+
required: true
38+
type: boolean
39+
python-version:
40+
required: false
41+
type: string
42+
43+
jobs:
44+
build:
45+
name: Test (${{ inputs.host-platform }}, ${{ inputs.target-device }}, ${{ inputs.build-type }}, CMake build-mode=${{ inputs.build-mode }}, Python "${{ inputs.python-version }}", Use container=${{ inputs.use-container }} )
46+
47+
permissions:
48+
id-token: write # This is required for configure-aws-credentials
49+
contents: read # This is required for actions/checkout
50+
51+
runs-on: ${{ inputs.runs-on }}
52+
53+
container:
54+
options: -u root --security-opt seccomp=unconfined --privileged --shm-size 16g
55+
image: condaforge/miniforge3:latest
56+
env:
57+
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
58+
59+
steps:
60+
- name: Checkout ${{ inputs.client-repo }}
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 0
64+
65+
- name: Setup
66+
uses: ./.github/actions/setup
67+
with:
68+
client-repo: ${{ inputs.client-repo }}
69+
build-type: ${{ inputs.build-type }}
70+
target-device: "${{ inputs.target-device }}"
71+
host-platform: ${{ inputs.host-platform }}
72+
build-mode: ${{ inputs.build-mode }}
73+
upload-enabled: ${{ inputs.upload-enabled }}
74+
python-version: ${{ inputs.python-version }}
75+
76+
- name: Call test action
77+
uses: ./.github/actions/test
78+
with:
79+
test-options: ${{ inputs.test-options }}
80+
runner-has-gpu: ${{ inputs.runner-has-gpu }}

continuous_integration/scripts/setup-utils

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,29 @@ init_build_env() {
151151

152152
make-conda-env "$BUILD_TYPE";
153153

154+
activate_conda_env;
155+
conda_info;
156+
}
157+
158+
init_test_env() {
159+
set -x;
160+
161+
. conda-utils;
162+
163+
export TEST_TYPE=$1
164+
165+
set -xeuo pipefail;
166+
167+
set_base_defs;
168+
169+
cd "$PREBUILD_DIR"
170+
171+
# setup_test_env;
172+
173+
cd "$REPO_DIR";
174+
175+
make-conda-env "$TEST_TYPE";
176+
154177
activate_conda_env;
155178
conda_info;
156179
}

continuous_integration/scripts/test

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
test_ci() {
4+
set -xeou pipefail
5+
6+
cd "${ARTIFACTS_DIR}"
7+
8+
activate_conda_env;
9+
10+
pip install *.whl
11+
12+
cd "${REPO_DIR}"
13+
14+
python -m pytest
15+
}
16+
17+
test_project() {
18+
set -xeou pipefail
19+
20+
export PYTHONUNBUFFERED=1
21+
22+
. setup-utils;
23+
init_test_env "$@";
24+
25+
git config --global --add safe.directory "$REPO_DIR/.git"
26+
27+
case "${TEST_TYPE}" in
28+
ci) test_ci;;
29+
*) return 1;;
30+
esac
31+
}
32+
33+
(test_project "$@");

0 commit comments

Comments
 (0)