From 0ee606276210f18710e6c732b0c3b0f4c852ebb2 Mon Sep 17 00:00:00 2001 From: Orfeas Kourkakis Date: Fri, 11 Nov 2022 15:03:51 +0200 Subject: [PATCH] gh-actions: Extend action to run Frontend Unit tests (#1998) * gh-actions: Extend action to run Frontend Unit tests Extend Frontend Test action to run also KWA frontend unit tests. Signed-off-by: Orfeas Kourkakis * gh-actions: Exclude actions when there are only UI changes Prevent the following workflows when a PR contains changes that affect only the frontend: - Charmed Katib - E2E Test with darts-cnn-cifar10 - E2E Test with enas-cnn-cifar10 - E2E Test with mxnet-mnist - E2E Test with pytorch-mnist - E2E Test with simple-pbt - E2E Test with tf-mnist-with-summaries - Go Test - Publish AutoML Algorithm Images - Publish Katib Core Images - Publish Trial Images - Python Test - Shellcheck Signed-off-by: Orfeas Kourkakis * gh-actions: Add action to build Katib UI image. Signed-off-by: Orfeas Kourkakis Signed-off-by: Orfeas Kourkakis --- .github/workflows/darts-cifar10-e2e-test.yaml | 4 ++- .github/workflows/enas-cifar10-e2e-test.yaml | 4 ++- .github/workflows/mxnet-mnist-e2e-test.yaml | 4 ++- .../workflows/publish-algorithm-images.yaml | 8 +++-- .github/workflows/publish-core-images.yaml | 9 +++-- .github/workflows/publish-katib-ui-image.yaml | 17 +++++++++ .github/workflows/publish-trial-images.yaml | 8 +++-- .github/workflows/pytorch-mnist-e2e-test.yaml | 4 ++- .github/workflows/simple-pbt-e2e-test.yaml | 4 ++- .github/workflows/test-charmed-katib.yaml | 8 +++-- .github/workflows/test-go.yaml | 8 +++-- .github/workflows/test-node.yaml | 36 ++++++++++++++++++- .github/workflows/test-python.yaml | 8 +++-- .github/workflows/test-shell-script.yaml | 8 +++-- .../tf-mnist-with-summaries-e2e-test.yaml | 4 ++- pkg/new-ui/v1beta1/frontend/package.json | 1 + 16 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/publish-katib-ui-image.yaml diff --git a/.github/workflows/darts-cifar10-e2e-test.yaml b/.github/workflows/darts-cifar10-e2e-test.yaml index 6a96893a491..629fce4f378 100644 --- a/.github/workflows/darts-cifar10-e2e-test.yaml +++ b/.github/workflows/darts-cifar10-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with darts-cnn-cifar10 on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/enas-cifar10-e2e-test.yaml b/.github/workflows/enas-cifar10-e2e-test.yaml index e5ec915ee88..fd9f243f89b 100644 --- a/.github/workflows/enas-cifar10-e2e-test.yaml +++ b/.github/workflows/enas-cifar10-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with enas-cnn-cifar10 on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/mxnet-mnist-e2e-test.yaml b/.github/workflows/mxnet-mnist-e2e-test.yaml index 149bc7a0e7a..828379bbb3f 100644 --- a/.github/workflows/mxnet-mnist-e2e-test.yaml +++ b/.github/workflows/mxnet-mnist-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with mxnet-mnist on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-algorithm-images.yaml b/.github/workflows/publish-algorithm-images.yaml index b6f13e2035e..580c7ef55d9 100644 --- a/.github/workflows/publish-algorithm-images.yaml +++ b/.github/workflows/publish-algorithm-images.yaml @@ -1,8 +1,12 @@ name: Publish AutoML Algorithm Images on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: algorithm: diff --git a/.github/workflows/publish-core-images.yaml b/.github/workflows/publish-core-images.yaml index 18d892159e8..b6c17109e9e 100644 --- a/.github/workflows/publish-core-images.yaml +++ b/.github/workflows/publish-core-images.yaml @@ -1,8 +1,12 @@ name: Publish Katib Core Images on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: core: @@ -16,7 +20,6 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - strategy: fail-fast: false matrix: diff --git a/.github/workflows/publish-katib-ui-image.yaml b/.github/workflows/publish-katib-ui-image.yaml new file mode 100644 index 00000000000..148761ff69a --- /dev/null +++ b/.github/workflows/publish-katib-ui-image.yaml @@ -0,0 +1,17 @@ +name: Publish Katib UI Image + +on: + - push + - pull_request + +jobs: + ui: + name: Publish Image + uses: ./.github/workflows/build-and-publish-images.yaml + with: + component-name: katib-ui + platforms: linux/amd64,linux/arm64 + dockerfile: cmd/new-ui/v1beta1/Dockerfile + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish-trial-images.yaml b/.github/workflows/publish-trial-images.yaml index 860739a8df1..5e3172555e7 100644 --- a/.github/workflows/publish-trial-images.yaml +++ b/.github/workflows/publish-trial-images.yaml @@ -1,8 +1,12 @@ name: Publish Trial Images on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: trial: diff --git a/.github/workflows/pytorch-mnist-e2e-test.yaml b/.github/workflows/pytorch-mnist-e2e-test.yaml index ac46f655e8c..c0c79962a61 100644 --- a/.github/workflows/pytorch-mnist-e2e-test.yaml +++ b/.github/workflows/pytorch-mnist-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with pytorch-mnist on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/simple-pbt-e2e-test.yaml b/.github/workflows/simple-pbt-e2e-test.yaml index 89fa8b2f9be..40b299c68e5 100644 --- a/.github/workflows/simple-pbt-e2e-test.yaml +++ b/.github/workflows/simple-pbt-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with simple-pbt on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-charmed-katib.yaml b/.github/workflows/test-charmed-katib.yaml index a786301c43a..88ce3488526 100644 --- a/.github/workflows/test-charmed-katib.yaml +++ b/.github/workflows/test-charmed-katib.yaml @@ -1,8 +1,12 @@ name: Charmed Katib on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: lint: diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index 5f3133a667a..aab1e48e249 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -1,8 +1,12 @@ name: Go Test on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: generatetests: diff --git a/.github/workflows/test-node.yaml b/.github/workflows/test-node.yaml index a010d218303..0f8c4b9a33b 100644 --- a/.github/workflows/test-node.yaml +++ b/.github/workflows/test-node.yaml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v3 - name: Setup Node - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: 12.18.1 @@ -22,3 +22,37 @@ jobs: run: | npm install prettier --prefix ./pkg/new-ui/v1beta1/frontend make prettier-check + + frontend-unit-tests: + name: Frontend Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 12.18.1 + + - name: Fetch Kubeflow and install common code dependencies + run: | + cd /tmp && git clone https://github.com/kubeflow/kubeflow.git + cd kubeflow + git checkout c4ca7a9 + cd components/crud-web-apps/common/frontend/kubeflow-common-lib + npm i + npm run build + npm link ./dist/kubeflow + + - name: Install KWA dependencies + run: | + cd pkg/new-ui/v1beta1/frontend + npm i + npm link kubeflow + + - name: Run unit tests + run: | + cd pkg/new-ui/v1beta1/frontend + npm run test:prod diff --git a/.github/workflows/test-python.yaml b/.github/workflows/test-python.yaml index 1f57c98eec6..22e5480e183 100644 --- a/.github/workflows/test-python.yaml +++ b/.github/workflows/test-python.yaml @@ -1,8 +1,12 @@ name: Python Test on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: test: diff --git a/.github/workflows/test-shell-script.yaml b/.github/workflows/test-shell-script.yaml index 6cbd42d6b9a..b456c2da378 100644 --- a/.github/workflows/test-shell-script.yaml +++ b/.github/workflows/test-shell-script.yaml @@ -1,8 +1,12 @@ name: Shellcheck on: - - push - - pull_request + push: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' jobs: test: diff --git a/.github/workflows/tf-mnist-with-summaries-e2e-test.yaml b/.github/workflows/tf-mnist-with-summaries-e2e-test.yaml index c6e43eb7295..da70b0f6690 100644 --- a/.github/workflows/tf-mnist-with-summaries-e2e-test.yaml +++ b/.github/workflows/tf-mnist-with-summaries-e2e-test.yaml @@ -1,6 +1,8 @@ name: E2E Test with tf-mnist-with-summaries on: - - pull_request + pull_request: + paths-ignore: + - 'pkg/new-ui/v1beta1/frontend/**' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/pkg/new-ui/v1beta1/frontend/package.json b/pkg/new-ui/v1beta1/frontend/package.json index 29293ee1853..5c38e393b22 100644 --- a/pkg/new-ui/v1beta1/frontend/package.json +++ b/pkg/new-ui/v1beta1/frontend/package.json @@ -8,6 +8,7 @@ "build:prod": "npm run copyLibAssets && ng build --base-href /katib/ --deploy-url /katib/static/ --outputPath dist/static --configuration production", "copyLibAssets": "cp -r ./node_modules/kubeflow/assets/* ./src/assets/", "test": "ng test", + "test:prod": "ng test --browsers=ChromeHeadless --watch=false", "lint": "ng lint", "format:check": "prettier --check 'src/**/*.{jsx,js,ts,html,scss,css}' || node scripts/check-format-error.js", "format:write": "prettier --write 'src/**/*.{jsx,js,ts,html,scss,css}'",