-
Notifications
You must be signed in to change notification settings - Fork 79
122 lines (104 loc) · 4.09 KB
/
test-deploy-cve-notebook.yml
File metadata and controls
122 lines (104 loc) · 4.09 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Test Deploy CVE Notebook
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run-notebook:
runs-on: arc-runners-org-nvidia-ai-bp-1-gpu
env:
NOTEBOOK_PATH: ./deploy/1_Deploy_CVE.ipynb
PYTHON_VERSION: 3.12
steps:
- name: Checkout BP repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: |
requirements.txt
**/*.ipynb
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-dotenv
pip install --upgrade pip ipython ipykernel
ipython kernel install --name "python3" --user
# Get System Info
echo "===================== System Info ====================="
more /etc/os-release
docker version
docker compose version
- name: Run Jupyter Notebook
env:
GHSA_API_KEY: ${{ secrets.GHSA_API_KEY }}
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
SERPAPI_API_KEY: ${{ secrets.SERPAPI_API_KEY }}
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
run: |
OUTPUT_NOTEBOOK="result.ipynb"
echo "Executing notebook: $NOTEBOOK_PATH"
papermill "$NOTEBOOK_PATH" "$OUTPUT_NOTEBOOK" --log-output --log-level DEBUG
- name: Convert result to html format
if: always()
run: |
OUTPUT_NOTEBOOK="result.ipynb"
jupyter nbconvert --to html "$OUTPUT_NOTEBOOK"
- name: Run Test Code
if: always()
env:
TEST_DOCKER_PULL_KEY: ${{ secrets.TEST_DOCKER_PULL_KEY }}
run: |
# Check if the HTML files exist before running tests
if [ ! -f "./result.html" ]; then
echo "Warning: result.html not found"
fi
# Run the test and capture the exit code
echo "$TEST_DOCKER_PULL_KEY" |docker login nvcr.io --username '$oauthtoken' --password-stdin
docker run --rm \
-v ./result.html:/app/input/vulnerability_analysis/Launchable-VACS-2.1.0-result.html \
-v "$(pwd):/workspace" \
nvcr.io/rw983xdqtcdp/auto_test_team/blueprint-github-test-image:latest \
pytest -m vacs --disable-warnings --html=/workspace/vacs.html --self-contained-html
- name: Upload the result notebook as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: result notebook and pytest
path: |
result.html
vacs.html
retention-days: 30
- name: Set result output
id: set_result
if: always()
run: |
echo "RESULT=$(if [ ${{ job.status }} == 'success' ]; then echo 'PASS'; else echo 'FAIL'; fi)" >> $GITHUB_OUTPUT
- name: Send mail
uses: dawidd6/action-send-mail@6e71c855c9a091d80a519621b9fd3e8d252ca40c
if: always()
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
# Email details
subject: "QA Test Workflow Result for ${{ github.repository }}"
to: Github-Action-Blueprint-QA@nvidia.com
from: github-workflow-notification@gmail.com
html_body: |
<p>Hello,</p>
<p>The workflow for repository: <strong>${{ github.repository }}</strong> has completed.<br>
<strong>Result:</strong> ${{ steps.set_result.outputs.RESULT }}</p>
<p>You can review the details on GitHub:<br>
<a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}</a></p>
<p>Thanks!</p>