Skip to content

Commit 01e48e4

Browse files
committed
feat: Migrate TWA test-related workflows
Signed-off-by: Yehudit Kerido <[email protected]>
1 parent 290935a commit 01e48e4

File tree

8 files changed

+336
-0
lines changed

8 files changed

+336
-0
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: TWA Frontend Tests
2+
on:
3+
push:
4+
branches:
5+
- feat/migrate_twa_tests # Temp branch for testing
6+
pull_request:
7+
paths:
8+
- components/crud-web-apps/tensorboards/frontend/**
9+
- releasing/version/VERSION
10+
branches:
11+
- main
12+
- v*-branch
13+
- notebooks-v1
14+
15+
jobs:
16+
frontend-format-linting-check:
17+
name: Code format and lint
18+
runs-on: ubuntu-22.04
19+
defaults:
20+
run:
21+
working-directory: components/crud-web-apps/tensorboards/frontend
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 16
31+
cache: 'npm'
32+
cache-dependency-path: 'components/crud-web-apps/tensorboards/frontend/package-lock.json'
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Check code format
38+
run: npm run format:check
39+
40+
- name: Lint code
41+
run: npm run lint-check
42+
43+
build-common-lib:
44+
name: Build Kubeflow common library
45+
runs-on: ubuntu-22.04
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v4
49+
50+
- name: Setup Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 16
54+
cache: 'npm'
55+
cache-dependency-path: 'components/crud-web-apps/common/frontend/kubeflow-common-lib/package-lock.json'
56+
57+
- name: Install and build common library
58+
run: |
59+
cd components/crud-web-apps/common/frontend/kubeflow-common-lib
60+
npm ci
61+
npm run build
62+
63+
- name: Cache built common library
64+
uses: actions/cache@v4
65+
with:
66+
path: components/crud-web-apps/common/frontend/kubeflow-common-lib/dist
67+
key: kubeflow-common-lib-${{ github.sha }}
68+
restore-keys: |
69+
kubeflow-common-lib-
70+
71+
frontend-unit-tests:
72+
name: Unit tests
73+
runs-on: ubuntu-22.04
74+
needs: build-common-lib
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: 16
83+
cache: 'npm'
84+
cache-dependency-path: 'components/crud-web-apps/tensorboards/frontend/package-lock.json'
85+
86+
- name: Restore built common library
87+
uses: actions/cache@v4
88+
with:
89+
path: components/crud-web-apps/common/frontend/kubeflow-common-lib/dist
90+
key: kubeflow-common-lib-${{ github.sha }}
91+
restore-keys: |
92+
kubeflow-common-lib-
93+
94+
- name: Install common library dependencies
95+
run: |
96+
cd components/crud-web-apps/common/frontend/kubeflow-common-lib
97+
npm ci
98+
npm link ./dist/kubeflow
99+
100+
- name: Install TWA dependencies
101+
run: |
102+
cd components/crud-web-apps/tensorboards/frontend
103+
npm ci
104+
npm link kubeflow
105+
106+
- name: Run unit tests
107+
run: |
108+
cd components/crud-web-apps/tensorboards/frontend
109+
npm run test:prod
110+
111+
frontend-ui-tests:
112+
name: UI tests with Cypress
113+
runs-on: ubuntu-22.04
114+
needs: build-common-lib
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v4
118+
119+
- name: Setup Node.js
120+
uses: actions/setup-node@v4
121+
with:
122+
node-version: 16
123+
cache: 'npm'
124+
cache-dependency-path: 'components/crud-web-apps/tensorboards/frontend/package-lock.json'
125+
126+
- name: Restore built common library
127+
uses: actions/cache@v4
128+
with:
129+
path: components/crud-web-apps/common/frontend/kubeflow-common-lib/dist
130+
key: kubeflow-common-lib-${{ github.sha }}
131+
restore-keys: |
132+
kubeflow-common-lib-
133+
134+
- name: Install common library dependencies
135+
run: |
136+
cd components/crud-web-apps/common/frontend/kubeflow-common-lib
137+
npm ci
138+
npm link ./dist/kubeflow
139+
140+
- name: Install TWA dependencies
141+
run: |
142+
cd components/crud-web-apps/tensorboards/frontend
143+
npm ci
144+
npm link kubeflow
145+
146+
- name: Run Cypress tests
147+
run: |
148+
cd components/crud-web-apps/tensorboards/frontend
149+
npm run serve > serve.log 2>&1 & npx wait-on http://localhost:4200
150+
npm run ui-test-ci-all
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: TWA Integration Test
2+
on:
3+
push:
4+
branches:
5+
- feat/migrate_twa_tests # Temp branch for testing
6+
pull_request:
7+
paths:
8+
- components/crud-web-apps/tensorboards/**
9+
- components/crud-web-apps/common/**
10+
- releasing/version/VERSION
11+
branches:
12+
- main
13+
- v*-branch
14+
- notebooks-v1
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
18+
cancel-in-progress: true
19+
20+
env:
21+
IMG: ghcr.io/kubeflow/notebooks/tensorboards-web-app
22+
TAG: integration-test
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Build TWA Image
32+
run: |
33+
cd components/crud-web-apps/tensorboards
34+
make docker-build
35+
36+
- name: Install KinD
37+
run: ./components/testing/gh-actions/install_kind.sh
38+
39+
- name: Create KinD Cluster
40+
run: kind create cluster --config components/testing/gh-actions/kind-1-25.yaml
41+
42+
- name: Load Image into KinD Cluster
43+
run: |
44+
kind load docker-image "${IMG}:${TAG}"
45+
46+
- name: Install kustomize
47+
run: ./components/testing/gh-actions/install_kustomize.sh
48+
49+
- name: Install Istio
50+
run: ./components/testing/gh-actions/install_istio.sh
51+
52+
- name: Build & Apply manifests
53+
run: |
54+
cd components/crud-web-apps/tensorboards/manifests
55+
kubectl create ns kubeflow
56+
57+
export CURRENT_IMAGE="${IMG}"
58+
export PR_IMAGE="${IMG}:${TAG}"
59+
60+
# escape "." in the image names, as it is a special characters in sed
61+
export CURRENT_IMAGE=$(echo "$CURRENT_IMAGE" | sed 's|\.|\\.|g')
62+
export PR_IMAGE=$(echo "$PR_IMAGE" | sed 's|\.|\\.|g')
63+
64+
kustomize build overlays/istio \
65+
| sed "s|${CURRENT_IMAGE}:[a-zA-Z0-9_.-]*|${PR_IMAGE}|g" \
66+
| kubectl apply -f -
67+
68+
kubectl wait pods -n kubeflow -l app=tensorboards-web-app --for=condition=Ready --timeout=300s
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: TWA Multi-Arch Build Test
2+
on:
3+
push:
4+
branches:
5+
- feat/migrate_twa_tests # Temp branch for testing
6+
pull_request:
7+
paths:
8+
- components/crud-web-apps/tensorboards/**
9+
- components/crud-web-apps/common/**
10+
- releasing/version/VERSION
11+
branches:
12+
- main
13+
- v*-branch
14+
- notebooks-v1
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
18+
cancel-in-progress: true
19+
20+
env:
21+
IMG: ghcr.io/kubeflow/notebooks/tensorboards-web-app
22+
PLATFORMS: linux/amd64,linux/ppc64le,linux/arm64/v8
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup QEMU
32+
uses: docker/setup-qemu-action@v3
33+
34+
- name: Setup Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Build multi-arch images
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: components/crud-web-apps
41+
file: components/crud-web-apps/tensorboards/Dockerfile
42+
platforms: ${{ env.PLATFORMS }}
43+
push: false
44+
load: false
45+
tags: |
46+
${{ env.IMG }}:${{ github.sha }}
47+
${{ env.IMG }}:latest
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
ISTIO_VERSION="1.17.8"
6+
ISTIO_URL="https://istio.io/downloadIstio"
7+
8+
echo "Installing Istio ${ISTIO_VERSION} ..."
9+
mkdir istio_tmp
10+
pushd istio_tmp >/dev/null
11+
curl -sL "$ISTIO_URL" | ISTIO_VERSION=${ISTIO_VERSION} sh -
12+
cd istio-${ISTIO_VERSION}
13+
export PATH=$PWD/bin:$PATH
14+
istioctl install -y
15+
popd
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
KIND_VERSION="0.22.0"
6+
KIND_URL="https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-amd64"
7+
8+
echo "Setting up kind environment..."
9+
sudo swapoff -a
10+
sudo rm -f /swapfile
11+
sudo mkdir -p /tmp/etcd
12+
sudo mount -t tmpfs tmpfs /tmp/etcd
13+
14+
echo "Installing kind ${KIND_VERSION} ..."
15+
curl -sL -o kind "$KIND_URL"
16+
chmod +x ./kind
17+
sudo mv kind /usr/local/bin
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
KUSTOMIZE_VERSION="5.4.1"
6+
KUSTOMIZE_URL="https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz"
7+
8+
echo "Installing kustomize ${KUSTOMIZE_VERSION} ..."
9+
curl -sL -o kustomize.tar.gz "$KUSTOMIZE_URL"
10+
tar -xzf kustomize.tar.gz
11+
chmod +x kustomize
12+
sudo mv kustomize /usr/local/bin
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kind.x-k8s.io/v1alpha4
2+
kind: Cluster
3+
# Configure registry for KinD.
4+
containerdConfigPatches:
5+
- |-
6+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."$REGISTRY_NAME:$REGISTRY_PORT"]
7+
endpoint = ["http://$REGISTRY_NAME:$REGISTRY_PORT"]
8+
# This is needed in order to support projected volumes with service account tokens.
9+
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600268272383600
10+
kubeadmConfigPatches:
11+
- |
12+
apiVersion: kubeadm.k8s.io/v1beta2
13+
kind: ClusterConfiguration
14+
metadata:
15+
name: config
16+
apiServer:
17+
extraArgs:
18+
"service-account-issuer": "kubernetes.default.svc"
19+
"service-account-signing-key-file": "/etc/kubernetes/pki/sa.key"
20+
nodes:
21+
- role: control-plane
22+
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
23+
- role: worker
24+
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1

releasing/version/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latest

0 commit comments

Comments
 (0)