Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check matrix #5

Open
wants to merge 35 commits into
base: jd_rhel9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
68df395
Add daily check for vulnerability issues using Trivy
caponetto Jul 1, 2024
7bf2fcb
ci: start podman.socket and pass it to trivy to avoid unnecessary pul…
jiridanek Jul 3, 2024
ce8aaa3
ci: implement ghcr.io expiration for images and cache layers (#601)
jiridanek Jul 3, 2024
d7e2c6b
ci: get a list of changed files using git diff instead of GitHub APIv4
jiridanek Jun 28, 2024
6b2ea94
fix tensorflow rocm resolution by installing it from .whl file
atheo89 Jul 8, 2024
1bda822
ci: use a smarter check for uncommitted files
jiridanek Jul 9, 2024
a2beb33
ci: mount Red Hat subscription in GitHub Actions
jiridanek Jul 12, 2024
299d96f
git-crypt init
jiridanek Jul 12, 2024
20a8502
yyy
jiridanek Jul 12, 2024
8ea7c86
remove sub from dockerfile
jiridanek Jul 12, 2024
72e84b7
mount secrets smarter
jiridanek Jul 12, 2024
072bbf8
fixup generated file
jiridanek Jul 12, 2024
823ab6f
fixup actor
jiridanek Jul 12, 2024
db3a8f6
fixup actor
jiridanek Jul 12, 2024
5bd07d2
?
jiridanek Jul 12, 2024
b59d8e7
omg
jiridanek Jul 12, 2024
32d772a
install git-crypt
jiridanek Jul 12, 2024
a277d63
pomg
jiridanek Jul 12, 2024
d14525a
?
jiridanek Jul 12, 2024
34bdaef
!
jiridanek Jul 12, 2024
067bcea
add rhel9 build, and now i can edit pr and it will be in effect
jiridanek Jul 12, 2024
949d5ab
fix filter for rhel
jiridanek Jul 12, 2024
8dca5a2
chnge
jiridanek Jul 12, 2024
0a13412
pull_request_target
jiridanek Jul 12, 2024
59b53c2
check matrix
jiridanek Jul 12, 2024
7254f37
this is what I need to check
jiridanek Jul 12, 2024
7fa76fe
more change
jiridanek Jul 12, 2024
2455c26
this is what I need to check
jiridanek Jul 12, 2024
bc121c7
pull-secret.json
jiridanek Jul 12, 2024
5134977
checkout new pr
jiridanek Jul 12, 2024
16150aa
checkout new pr
jiridanek Jul 12, 2024
1084152
pull-secret.json dont validate as json its encrypted
jiridanek Jul 12, 2024
467978b
move locking into build action
jiridanek Jul 12, 2024
f4c6091
more change
jiridanek Jul 12, 2024
435dc3c
more change
jiridanek Jul 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ci/secrets/** filter=git-crypt diff=git-crypt
83 changes: 80 additions & 3 deletions .github/workflows/build-notebooks-TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ name: Build & Publish Notebook Servers (TEMPLATE)
required: true
description: "top workflow's `github`"
type: string
subscription:
required: false
default: false
description: "add RHEL subscription from github secret"
type: boolean

jobs:
build:
Expand All @@ -26,6 +31,14 @@ jobs:
steps:

- uses: actions/checkout@v4
if: ${{ !fromJson(inputs.github).event_name == 'pull_request_target' }}

# we need to checkout the pr branch, not pr target (the default)
# user access check is done in calling workflow
- uses: actions/checkout@v4
if: ${{ fromJson(inputs.github).event_name == 'pull_request_target' }}
with:
ref: "refs/pull/${{ fromJson(inputs.github).event.number }}/merge"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -43,6 +56,14 @@ jobs:

df -h

sudo apt-get update
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^mongodb-.*'
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf /usr/local/.ghcup &
sudo rm -rf /usr/local/lib/android &
sudo rm -rf /usr/local/share/boost &
sudo rm -rf /usr/local/lib/node_modules &
Expand Down Expand Up @@ -95,15 +116,71 @@ jobs:
podman system reset --force
mkdir -p $HOME/.local/share/containers/storage/tmp

# start systemd user service
# since `brew services start podman` is buggy, let's do our own brew-compatible service
mkdir -p "${HOME}/.config/systemd/user/"
cp ci/cached-builds/homebrew.podman.service "${HOME}/.config/systemd/user/homebrew.podman.service"
systemctl --user daemon-reload
systemctl --user start homebrew.podman.service
echo "PODMAN_SOCK=/run/user/${UID}/podman/podman.sock" >> $GITHUB_ENV

- name: Unlock encrypted secrets with git-crypt
if: ${{ inputs.subscription }}
run: |
sudo apt-get update
sudo apt-get install git-crypt
echo "${GIT_CRYPT_KEY}" | base64 --decode > ./git-crypt-key
git-crypt unlock ./git-crypt-key
rm ./git-crypt-key
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}

- name: Add subscriptions from GitHub secret
if: ${{ inputs.subscription }}
run: |
printf "${PWD}/ci/secrets/pki/consumer:/etc/pki/consumer\n${PWD}/ci/secrets/pki/entitlement:/etc/pki/entitlement" > /usr/share/containers/mounts.conf
cp ${PWD}/ci/secrets/pull-secret.txt $HOME/.config/containers/auth.json

# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
- name: "push: make ${{ inputs.target }}"
- name: "push|schedule: make ${{ inputs.target }}"
run: "make ${{ inputs.target }}"
if: "${{ fromJson(inputs.github).event_name == 'push' }}"
if: ${{ fromJson(inputs.github).event_name == 'push' || fromJson(inputs.github).event_name == 'schedule' }}
env:
IMAGE_TAG: "${{ github.ref_name }}_${{ github.sha }}"
IMAGE_REGISTRY: "ghcr.io/${{ github.repository }}/workbench-images"
CONTAINER_BUILD_CACHE_ARGS: "--cache-from ${{ env.CACHE }} --cache-to ${{ env.CACHE }}"

- name: "schedule: run Trivy vulnerability scanner"
if: "${{ fromJson(inputs.github).event_name == 'schedule' }}"
run: |
TRIVY_VERSION=0.53.0
REPORT_FOLDER=${{ github.workspace }}/report
REPORT_FILE=trivy-report.md
REPORT_TEMPLATE=trivy-markdown.tpl

mkdir -p $REPORT_FOLDER
cp ci/$REPORT_TEMPLATE $REPORT_FOLDER

IMAGE_NAME=ghcr.io/${{ github.repository }}/workbench-images:${{ inputs.target }}-${{ github.ref_name }}_${{ github.sha }}
echo "Scanning $IMAGE_NAME"

# have trivy access podman socket,
# https://github.com/aquasecurity/trivy/issues/580#issuecomment-666423279
podman run --rm \
-v ${PODMAN_SOCK}:/var/run/podman/podman.sock \
-v ${REPORT_FOLDER}:/report \
docker.io/aquasec/trivy:$TRIVY_VERSION \
image \
--image-src podman \
--podman-host /var/run/podman/podman.sock \
--scanners vuln,secret \
--exit-code 0 --timeout 30m \
--severity CRITICAL,HIGH \
--format template --template "@/report/$REPORT_TEMPLATE" -o /report/$REPORT_FILE \
$IMAGE_NAME

cat $REPORT_FOLDER/$REPORT_FILE >> $GITHUB_STEP_SUMMARY

# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
- name: "pull_request: make ${{ inputs.target }}"
run: |
Expand All @@ -113,7 +190,7 @@ jobs:
go run ci/cached-builds/dev_null_container_registry.go &
# build and push the image
make ${{ inputs.target }}
if: "${{ fromJson(inputs.github).event_name == 'pull_request' }}"
if: "${{ fromJson(inputs.github).event_name == 'pull_request' || fromJson(inputs.github).event_name == 'pull_request_target' }}"
env:
IMAGE_TAG: "${{ github.sha }}"
IMAGE_REGISTRY: "localhost:5000/workbench-images"
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/build-notebooks-pr-rhel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
"name": "Build Notebooks (pr, RHEL images)"
"on":
"pull_request_target":
"types": ["opened", "synchronize", "reopened", "edited"]

# BEWARE: This GitHub Actions workflow runs on pull_request_target, meaning it has access to our secrets
# see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-secrets
# and https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

permissions:
contents: read
packages: read

env:
contributors: '["atheo89", "caponetto", "dibryant", "harshad16", "jiridanek", "jstourac", "paulovmr"]'

jobs:
gen:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen.outputs.matrix }}
has_jobs: ${{ steps.gen.outputs.has_jobs }}
steps:
- name: Check permissions (this must be done FIRST, for security, before we checkout)
if: ${{ !contains(fromJSON(env.contributors), github.actor) }}
run: |
echo "GitHub user ${{ github.actor }} is not a registered project contributor, not allowed to run actions on RHEL!"
exit 1

- uses: actions/checkout@v4
with:
ref: "refs/pull/${{ github.event.number }}/merge"

- name: Determine targets to build based on changed files
run: |
set -x
git fetch --no-tags origin 'pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}'
git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}'
python3 ci/cached-builds/gen_gha_matrix_jobs.py \
--from-ref 'origin/${{ github.event.pull_request.base.ref }}' \
--to-ref '${{ github.event.pull_request.head.ref }}' \
--only-rhel
id: gen
shell: bash

build:
needs: ["gen"]
strategy:
fail-fast: false
matrix: "${{ fromJson(needs.gen.outputs.matrix) }}"
uses: ./.github/workflows/build-notebooks-TEMPLATE.yaml
if: ${{ fromJson(needs.gen.outputs.has_jobs) }}
with:
target: "${{ matrix.target }}"
github: "${{ toJSON(github) }}"
subscription: true
secrets: inherit
16 changes: 9 additions & 7 deletions .github/workflows/build-notebooks-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
"name": "Build Notebooks"
"name": "Build Notebooks (pr)"
"on":
"pull_request":

permissions:
contents: read
packages: read
pull-requests: read

jobs:
gen:
Expand All @@ -18,15 +17,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: |
- name: Determine targets to build based on changed files
run: |
set -x
git fetch --no-tags origin 'pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}'
git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}'
python3 ci/cached-builds/gen_gha_matrix_jobs.py \
--owner=${{ github.repository_owner }} \
--repo=${{ github.event.pull_request.base.repo.name }} \
--pr-number=${{ github.event.pull_request.number }} \
--skip-unchanged
--from-ref 'origin/${{ github.event.pull_request.base.ref }}' \
--to-ref '${{ github.event.pull_request.head.ref }}'
id: gen
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash

build:
needs: ["gen"]
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/build-notebooks.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
---
# This file is autogenerated by ci/cached-builds/gen_gha_matrix_jobs.py
{
"name": "Build Notebooks",
"name": "Build Notebooks (push)",
"permissions": {
"packages": "write"
},
"on": {
"push": {},
"workflow_dispatch": {}
"workflow_dispatch": {},
"schedule": [
{
"cron": "0 2 * * *"
}
]
},
"jobs": {
"base-ubi8-python-3_8": {
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ jobs:

- name: Check there aren't any modified files present
run: |
if [[ $(git ls-files . -d -m -o --exclude-standard --full-name -v | tee modified.log | wc -l) -gt 0 ]]; then
echo "There are changed files"
exit 1
clean=$(git status --porcelain)
if [[ -z "$clean" ]]; then
echo "Empty git status --porcelain: $clean"
else
echo "Uncommitted file changes detected: $clean"
git diff
exit 1
fi

- name: Print modified files
if: ${{ failure() }}
run: |
cat modified.log
git diff

code-static-analysis:
runs-on: ubuntu-latest
steps:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/purge-ghcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: "Purge old ghcr.io test images periodically"

"on":
workflow_dispatch:
inputs:
dry_run:
type: boolean
default: true
description: "Do a dry run?"
schedule:
- cron: "0 5 * * *" # at 05:00 every day

permissions:
packages: write

jobs:
clean:
runs-on: ubuntu-latest
name: Delete old test images
steps:
# https://github.com/snok/container-retention-policy?tab=readme-ov-file#parameters
- uses: snok/container-retention-policy@4f22ef80902ad409ed55a99dc5133cc1250a0d03 # v3.0.0
with:
# account must be the gh org name when running for an org, and 'user' when running for a user
account: ${{ (github.repository_owner == github.actor) && 'user' || github.repository_owner }}
token: ${{ secrets.GITHUB_TOKEN }}
image-names: |
${{ github.event.repository.name }}/workbench-images
${{ github.event.repository.name }}/workbench-images/build-cache
image-tags: "*"
cut-off: "3w"
dry-run: ${{ inputs.dry_run || false }}
env:
RUST_BACKTRACE: 1
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,33 @@ base-rhel9-python-3.9:
$(call image,$@,base/rhel9-python-3.9)

####################################### Buildchain for AMD Python 3.9 using C9S #######################################

.PHONY: amd-rhel9-python-3.9
amd-rhel9-python-3.9: base-rhel9-python-3.9
$(call image,$@,amd/rhel9-python-3.9,$<)

# We are only using rhel9 base image here onwards,
# DON'T be confused due to the ubi9 mention, it's just a directory name.
.PHONY: amd-jupyter-minimal-rhel9-python-3.9
amd-jupyter-minimal-rhel9-python-3.9: amd-rhel9-python-3.9
$(call image,$@,jupyter/minimal/ubi9-python-3.9,$<)

# Build and push jupyter-datascience-ubi9-python-3.9 image to the registry
.PHONY: amd-jupyter-datascience-rhel9-python-3.9
amd-jupyter-datascience-rhel9-python-3.9: amd-jupyter-minimal-rhel9-python-3.9
$(call image,$@,jupyter/datascience/ubi9-python-3.9,$<)

# Build and push jupyter-tensorflow-ubi9-python-3.9 image to the registry
.PHONY: amd-jupyter-tensorflow-rhel9-python-3.9
amd-jupyter-tensorflow-rhel9-python-3.9: amd-jupyter-datascience-rhel9-python-3.9
$(call image,$@,jupyter/amd/tensorflow/ubi9-python-3.9,$<)

# Build and push jupyter-pytorch-ubi9-python-3.9 image to the registry
.PHONY: amd-jupyter-pytorch-rhel9-python-3.9
amd-jupyter-pytorch-rhel9-python-3.9: amd-jupyter-datascience-rhel9-python-3.9
$(call image,$@,jupyter/amd/pytorch/ubi9-python-3.9,$<)

####################################### Buildchain for AMD Python 3.9 using RHEL 9 #######################################
.PHONY: amd-c9s-python-3.9
amd-c9s-python-3.9: base-c9s-python-3.9
$(call image,$@,amd/c9s-python-3.9,$<)
Expand Down
17 changes: 3 additions & 14 deletions amd/rhel9-python-3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,9 @@ RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./P

USER 0

# Run the subscription manager command using the provided credentials. Only include --serverurl and --baseurl if they are provided
RUN SERVERURL=$(cat ${SECRET_DIR}/SERVERURL 2>/dev/null || echo ${SERVERURL_DEFAULT}) && \
BASEURL=$(cat ${SECRET_DIR}/BASEURL 2>/dev/null || echo ${BASEURL_DEFAULT}) && \
USERNAME=$(cat ${SECRET_DIR}/USERNAME) && \
PASSWORD=$(cat ${SECRET_DIR}/PASSWORD) && \
subscription-manager register \
${SERVERURL:+--serverurl=$SERVERURL} \
${BASEURL:+--baseurl=$BASEURL} \
--username=$USERNAME \
--password=$PASSWORD \
--force \
--auto-attach

# Install required packages
# change!!!!

# Install required packages
RUN yum -y install git java-1.8.0-openjdk && \
yum clean all && rm -rf /var/cache/yum

Expand Down
Loading
Loading