forked from NVIDIA/NeMo
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (67 loc) · 2.52 KB
/
_test_template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: ~test template
on:
workflow_call:
inputs:
RUNNER:
type: string
description: Runner to use for test
required: true
TIMEOUT:
type: number
description: Max runtime of test in minutes
required: false
default: 10
SCRIPT:
type: string
description: Test script to execute
required: true
AFTER_SCRIPT:
type: string
description: Script to run after main test
required: false
default: ":"
IS_OPTIONAL:
type: boolean
description: Failure will cancel all other tests if set to true
required: false
default: false
outputs:
conclusion:
description: Conclusion of main test step
value: ${{ jobs.main.outputs.conclusion }}
log:
description: Last 2000 characters of the test step's log
value: ${{ jobs.main.outputs.log }}
jobs:
main:
runs-on: ${{ inputs.RUNNER }}
outputs:
conclusion: ${{ steps.main.conclusion }}
log: ${{ steps.main.outputs.log }}
steps:
- name: Docker system cleanup
run: |
docker system prune -a --filter "until=48h" --force || true
- name: Docker pull image
run: |
docker pull nemoci.azurecr.io/nemo_container_${{ github.run_id }}
- id: main
name: Run main script
timeout-minutes: ${{ inputs.TIMEOUT }}
run: |
mkdir -p ${{ github.run_id }}
cd ${{ github.run_id }}/
set +e
(
set -e
docker run --rm --device=/dev/nvidia0 --gpus all --shm-size=8g --env TRANSFORMERS_OFFLINE=0 --env HYDRA_FULL_ERROR=1 --volume /mnt/datadrive/TestData:/home/TestData nemoci.azurecr.io/nemo_container_${{ github.run_id }} bash -c '${{ inputs.SCRIPT }}'
) 2> >(tee err.log)
EXIT_CODE=$?
echo "log=$(tail -c 2000 err.log | base64 -w 0)" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE
- uses: "NVIDIA/NeMo/.github/actions/cancel-workflow@main"
if: failure() && inputs.IS_OPTIONAL == false
- name: after_script
if: always() && inputs.AFTER_SCRIPT != ':'
run: |
docker run --rm --device=/dev/nvidia0 --gpus all --shm-size=8g --env TRANSFORMERS_OFFLINE=0 --env HYDRA_FULL_ERROR=1 --volume /mnt/datadrive/TestData:/home/TestData nemoci.azurecr.io/nemo_container_${{ github.run_id }} bash -c '${{ inputs.AFTER_SCRIPT }}'