Skip to content

Commit 076f523

Browse files
authored
Merge pull request #643 from harshad16/sync-2024a
Sync 2024a branch with main branch
2 parents a76ab25 + 3334ba0 commit 076f523

File tree

111 files changed

+9112
-40751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+9112
-40751
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ jobs:
3636

3737
- name: Free up additional disk space
3838
# https://docs.github.com/en/actions/learn-github-actions/expressions
39-
if: "${{ contains(inputs.target, 'amd') || contains(inputs.target, 'cuda') || contains(inputs.target, 'intel') ||
39+
if: "${{ contains(inputs.target, 'rocm') || contains(inputs.target, 'cuda') || contains(inputs.target, 'intel') ||
4040
contains(inputs.target, 'pytorch') || contains(inputs.target, 'tensorflow') }}"
4141
run: |
4242
set -x
4343
4444
df -h
4545
46+
sudo apt-get update
47+
sudo apt-get remove -y '^dotnet-.*'
48+
sudo apt-get remove -y '^llvm-.*'
49+
sudo apt-get remove -y 'php.*'
50+
sudo apt-get remove -y '^mongodb-.*'
51+
sudo apt-get autoremove -y
52+
sudo apt-get clean
53+
sudo rm -rf /usr/local/.ghcup &
4654
sudo rm -rf /usr/local/lib/android &
4755
sudo rm -rf /usr/local/share/boost &
4856
sudo rm -rf /usr/local/lib/node_modules &
@@ -61,7 +69,7 @@ jobs:
6169
df -h
6270
free -h
6371
64-
bash ./ci/cached-builds/gha_lvm_overlay.bash
72+
bash ./ci/cached-builds/gha_lvm_overlay.sh
6573
6674
df -h
6775
free -h
@@ -95,10 +103,18 @@ jobs:
95103
podman system reset --force
96104
mkdir -p $HOME/.local/share/containers/storage/tmp
97105
106+
# start systemd user service
107+
# since `brew services start podman` is buggy, let's do our own brew-compatible service
108+
mkdir -p "${HOME}/.config/systemd/user/"
109+
cp ci/cached-builds/homebrew.podman.service "${HOME}/.config/systemd/user/homebrew.podman.service"
110+
systemctl --user daemon-reload
111+
systemctl --user start homebrew.podman.service
112+
echo "PODMAN_SOCK=/run/user/${UID}/podman/podman.sock" >> $GITHUB_ENV
113+
98114
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
99-
- name: "push: make ${{ inputs.target }}"
115+
- name: "push|schedule: make ${{ inputs.target }}"
100116
run: "make ${{ inputs.target }}"
101-
if: "${{ fromJson(inputs.github).event_name == 'push' }}"
117+
if: ${{ fromJson(inputs.github).event_name == 'push' || fromJson(inputs.github).event_name == 'schedule' }}
102118
env:
103119
IMAGE_TAG: "${{ github.ref_name }}_${{ github.sha }}"
104120
IMAGE_REGISTRY: "ghcr.io/${{ github.repository }}/workbench-images"
@@ -119,5 +135,57 @@ jobs:
119135
IMAGE_REGISTRY: "localhost:5000/workbench-images"
120136
CONTAINER_BUILD_CACHE_ARGS: "--cache-from ${{ env.CACHE }}"
121137

138+
- name: "Show podman images information"
139+
run: podman images
140+
141+
- name: "pull_request|schedule: resolve image name if Trivy scan should run"
142+
id: resolve-image
143+
if: ${{ fromJson(inputs.github).event_name == 'pull_request' || fromJson(inputs.github).event_name == 'schedule' }}
144+
env:
145+
EVENT_NAME: ${{ fromJson(inputs.github).event_name }}
146+
HAS_TRIVY_LABEL: ${{ contains(fromJson(inputs.github).event.pull_request.labels.*.name, 'trivy-scan') }}
147+
run: |
148+
if [[ "$EVENT_NAME" == "pull_request" && "$HAS_TRIVY_LABEL" == "true" ]]; then
149+
IMAGE_NAME="localhost:5000/workbench-images:${{ inputs.target }}-${{ github.sha }}"
150+
echo "image=$IMAGE_NAME" >> $GITHUB_OUTPUT
151+
elif [[ "$EVENT_NAME" == "schedule" ]]; then
152+
IMAGE_NAME="ghcr.io/${{ github.repository }}/workbench-images:${{ inputs.target }}-${{ github.ref_name }}_${{ github.sha }}"
153+
echo "image=$IMAGE_NAME" >> $GITHUB_OUTPUT
154+
fi
155+
156+
if [[ -z "$IMAGE_NAME" ]]; then
157+
echo "Trivy scan won't run"
158+
fi
159+
160+
- name: Run Trivy vulnerability scanner
161+
if: ${{ steps.resolve-image.outputs.image }}
162+
run: |
163+
TRIVY_VERSION=0.53.0
164+
REPORT_FOLDER=${{ github.workspace }}/report
165+
REPORT_FILE=trivy-report.md
166+
REPORT_TEMPLATE=trivy-markdown.tpl
167+
168+
mkdir -p $REPORT_FOLDER
169+
cp ci/$REPORT_TEMPLATE $REPORT_FOLDER
170+
171+
IMAGE_NAME=${{ steps.resolve-image.outputs.image }}
172+
echo "Scanning $IMAGE_NAME"
173+
174+
# have trivy access podman socket,
175+
# https://github.com/aquasecurity/trivy/issues/580#issuecomment-666423279
176+
podman run --rm \
177+
-v ${PODMAN_SOCK}:/var/run/podman/podman.sock \
178+
-v ${REPORT_FOLDER}:/report \
179+
docker.io/aquasec/trivy:$TRIVY_VERSION \
180+
image \
181+
--image-src podman \
182+
--podman-host /var/run/podman/podman.sock \
183+
--scanners vuln --ignore-unfixed \
184+
--exit-code 0 --timeout 30m \
185+
--format template --template "@/report/$REPORT_TEMPLATE" -o /report/$REPORT_FILE \
186+
$IMAGE_NAME
187+
188+
cat $REPORT_FOLDER/$REPORT_FILE >> $GITHUB_STEP_SUMMARY
189+
122190
- run: df -h
123191
if: "${{ !cancelled() }}"

.github/workflows/build-notebooks-pr.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"name": "Build Notebooks"
2+
"name": "Build Notebooks (pr)"
33
"on":
44
"pull_request":
55

@@ -8,6 +8,10 @@ permissions:
88
packages: read
99
pull-requests: read
1010

11+
concurrency:
12+
group: ${{ format('build-notebooks-pr-{0}', github.event.pull_request.number) }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
gen:
1317
name: Generate job matrix
@@ -18,15 +22,18 @@ jobs:
1822
steps:
1923
- uses: actions/checkout@v4
2024

21-
- run: |
25+
- name: Determine targets to build based on changed files
26+
run: |
27+
set -x
28+
git fetch --no-tags origin 'pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}'
29+
git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}'
2230
python3 ci/cached-builds/gen_gha_matrix_jobs.py \
23-
--owner=${{ github.repository_owner }} \
24-
--repo=${{ github.event.pull_request.base.repo.name }} \
25-
--pr-number=${{ github.event.pull_request.number }} \
26-
--skip-unchanged
31+
--from-ref 'origin/${{ github.event.pull_request.base.ref }}' \
32+
--to-ref '${{ github.event.pull_request.head.ref }}'
2733
id: gen
2834
env:
2935
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
shell: bash
3037

3138
build:
3239
needs: ["gen"]

.github/workflows/build-notebooks.yaml

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
---
22
# This file is autogenerated by ci/cached-builds/gen_gha_matrix_jobs.py
33
{
4-
"name": "Build Notebooks",
4+
"name": "Build Notebooks (push)",
55
"permissions": {
66
"packages": "write"
77
},
88
"on": {
99
"push": {},
10-
"workflow_dispatch": {}
10+
"workflow_dispatch": {},
11+
"schedule": [
12+
{
13+
"cron": "0 2 * * *"
14+
}
15+
]
1116
},
1217
"jobs": {
1318
"base-ubi8-python-3_8": {
@@ -74,28 +79,6 @@
7479
},
7580
"secrets": "inherit"
7681
},
77-
"jupyter-trustyai-ubi8-python-3_8": {
78-
"needs": [
79-
"jupyter-datascience-ubi8-python-3_8"
80-
],
81-
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
82-
"with": {
83-
"target": "jupyter-trustyai-ubi8-python-3.8",
84-
"github": "${{ toJSON(github) }}"
85-
},
86-
"secrets": "inherit"
87-
},
88-
"habana-jupyter-1_9_0-ubi8-python-3_8": {
89-
"needs": [
90-
"jupyter-datascience-ubi8-python-3_8"
91-
],
92-
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
93-
"with": {
94-
"target": "habana-jupyter-1.9.0-ubi8-python-3.8",
95-
"github": "${{ toJSON(github) }}"
96-
},
97-
"secrets": "inherit"
98-
},
9982
"habana-jupyter-1_10_0-ubi8-python-3_8": {
10083
"needs": [
10184
"jupyter-datascience-ubi8-python-3_8"
@@ -107,17 +90,6 @@
10790
},
10891
"secrets": "inherit"
10992
},
110-
"habana-jupyter-1_11_0-ubi8-python-3_8": {
111-
"needs": [
112-
"jupyter-datascience-ubi8-python-3_8"
113-
],
114-
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
115-
"with": {
116-
"target": "habana-jupyter-1.11.0-ubi8-python-3.8",
117-
"github": "${{ toJSON(github) }}"
118-
},
119-
"secrets": "inherit"
120-
},
12193
"habana-jupyter-1_13_0-ubi8-python-3_8": {
12294
"needs": [
12395
"jupyter-datascience-ubi8-python-3_8"
@@ -444,57 +416,57 @@
444416
},
445417
"secrets": "inherit"
446418
},
447-
"amd-c9s-python-3_9": {
419+
"rocm-ubi9-python-3_9": {
448420
"needs": [
449-
"base-c9s-python-3_9"
421+
"base-ubi9-python-3_9"
450422
],
451423
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
452424
"with": {
453-
"target": "amd-c9s-python-3.9",
425+
"target": "rocm-ubi9-python-3.9",
454426
"github": "${{ toJSON(github) }}"
455427
},
456428
"secrets": "inherit"
457429
},
458-
"amd-jupyter-minimal-c9s-python-3_9": {
430+
"rocm-jupyter-minimal-ubi9-python-3_9": {
459431
"needs": [
460-
"amd-c9s-python-3_9"
432+
"rocm-ubi9-python-3_9"
461433
],
462434
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
463435
"with": {
464-
"target": "amd-jupyter-minimal-c9s-python-3.9",
436+
"target": "rocm-jupyter-minimal-ubi9-python-3.9",
465437
"github": "${{ toJSON(github) }}"
466438
},
467439
"secrets": "inherit"
468440
},
469-
"amd-jupyter-datascience-c9s-python-3_9": {
441+
"rocm-jupyter-datascience-ubi9-python-3_9": {
470442
"needs": [
471-
"amd-jupyter-minimal-c9s-python-3_9"
443+
"rocm-jupyter-minimal-ubi9-python-3_9"
472444
],
473445
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
474446
"with": {
475-
"target": "amd-jupyter-datascience-c9s-python-3.9",
447+
"target": "rocm-jupyter-datascience-ubi9-python-3.9",
476448
"github": "${{ toJSON(github) }}"
477449
},
478450
"secrets": "inherit"
479451
},
480-
"amd-jupyter-tensorflow-c9s-python-3_9": {
452+
"rocm-jupyter-tensorflow-ubi9-python-3_9": {
481453
"needs": [
482-
"amd-jupyter-datascience-c9s-python-3_9"
454+
"rocm-jupyter-datascience-ubi9-python-3_9"
483455
],
484456
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
485457
"with": {
486-
"target": "amd-jupyter-tensorflow-c9s-python-3.9",
458+
"target": "rocm-jupyter-tensorflow-ubi9-python-3.9",
487459
"github": "${{ toJSON(github) }}"
488460
},
489461
"secrets": "inherit"
490462
},
491-
"amd-jupyter-pytorch-c9s-python-3_9": {
463+
"rocm-jupyter-pytorch-ubi9-python-3_9": {
492464
"needs": [
493-
"amd-jupyter-datascience-c9s-python-3_9"
465+
"rocm-jupyter-datascience-ubi9-python-3_9"
494466
],
495467
"uses": "./.github/workflows/build-notebooks-TEMPLATE.yaml",
496468
"with": {
497-
"target": "amd-jupyter-pytorch-c9s-python-3.9",
469+
"target": "rocm-jupyter-pytorch-ubi9-python-3.9",
498470
"github": "${{ toJSON(github) }}"
499471
},
500472
"secrets": "inherit"

.github/workflows/code-quality.yaml

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,59 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
- name: Rerun all code generators we have
18-
run: python3 ci/cached-builds/gen_gha_matrix_jobs.py
18+
run: bash ci/generate_code.sh
1919

2020
- name: Check there aren't any modified files present
2121
run: |
22-
if [[ $(git ls-files . -d -m -o --exclude-standard --full-name -v | tee modified.log | wc -l) -gt 0 ]]; then
23-
echo "There are changed files"
24-
exit 1
22+
clean=$(git status --porcelain)
23+
if [[ -z "$clean" ]]; then
24+
echo "Empty git status --porcelain: $clean"
25+
else
26+
echo "::error::Please run 'bash ci/generate_code.sh' (the command from the previous step), commit the changed files locally, and push again."
27+
echo "Uncommitted file changes detected: $clean"
28+
git diff
29+
exit 1
2530
fi
2631
27-
- name: Print modified files
28-
if: ${{ failure() }}
29-
run: |
30-
cat modified.log
31-
git diff
32+
pytest-tests:
33+
runs-on: ubuntu-latest
34+
env:
35+
poetry_version: '1.8.3'
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Cache poetry in ~/.local
40+
uses: actions/cache/restore@v4
41+
id: cache-poetry-restore
42+
with:
43+
path: ~/.local
44+
key: "${{ runner.os }}-local-${{ env.poetry_version }}"
45+
46+
- name: Install poetry
47+
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
48+
run: pip install poetry==${{ env.poetry_version }}
49+
50+
- name: Save cache
51+
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
52+
uses: actions/cache/save@v4
53+
with:
54+
path: ~/.local
55+
key: ${{ steps.cache-poetry-restore.outputs.cache-primary-key }}
56+
57+
- name: Set up Python
58+
id: setup-python
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: '3.12'
62+
cache: 'poetry'
63+
64+
- name: Configure poetry
65+
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
66+
67+
- name: Install deps
68+
run: poetry install --sync
69+
70+
- run: poetry run pytest
3271

3372
code-static-analysis:
3473
runs-on: ubuntu-latest

.github/workflows/purge-ghcr.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: "Purge old ghcr.io test images periodically"
3+
4+
"on":
5+
workflow_dispatch:
6+
inputs:
7+
dry_run:
8+
type: boolean
9+
default: true
10+
description: "Do a dry run?"
11+
schedule:
12+
- cron: "0 5 * * *" # at 05:00 every day
13+
14+
permissions:
15+
packages: write
16+
17+
jobs:
18+
clean:
19+
runs-on: ubuntu-latest
20+
name: Delete old test images
21+
steps:
22+
# https://github.com/snok/container-retention-policy?tab=readme-ov-file#parameters
23+
- uses: snok/container-retention-policy@4f22ef80902ad409ed55a99dc5133cc1250a0d03 # v3.0.0
24+
with:
25+
# account must be the gh org name when running for an org, and 'user' when running for a user
26+
account: ${{ (github.repository_owner == github.actor) && 'user' || github.repository_owner }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
image-names: |
29+
${{ github.event.repository.name }}/workbench-images
30+
${{ github.event.repository.name }}/workbench-images/build-cache
31+
image-tags: "*"
32+
cut-off: "3w"
33+
dry-run: ${{ inputs.dry_run || false }}
34+
env:
35+
RUST_BACKTRACE: 1

0 commit comments

Comments
 (0)