chore (Litmus-Portal) : Updated E2E GitHub Action Worflow (#2880)
* Updated E2E workflow Signed-off-by: Jonsy13 <vedant.shrotria@chaosnative.com> * Added BUILD_IMAGE.md inside .github. Signed-off-by: Jonsy13 <vedant.shrotria@chaosnative.com> * Fixed the pipeline. Signed-off-by: Jonsy13 <vedant.shrotria@chaosnative.com> * Fixed KIND Cluster. Signed-off-by: Jonsy13 <vedant.shrotria@chaosnative.com>
This commit is contained in:
parent
445ef30c69
commit
339150646c
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
The litmusportal runs on top of Kubernetes and is built on a set of docker containers it provides you the flexibility to build a custom image to visualize/check
|
The litmusportal runs on top of Kubernetes and is built on a set of docker containers it provides you the flexibility to build a custom image to visualize/check
|
||||||
your changes. Here are the components for which you can create your custom Docker images from this repository:
|
your changes. Here are the components for which you can create your custom Docker images from this repository:
|
||||||
|
|
||||||
- GraphQL Server
|
- GraphQL Server
|
||||||
- Cluster Agents: Subscriber, Event Tracker
|
- Cluster Agents: Subscriber, Event Tracker
|
||||||
- Web UI (Frontend)
|
- Web UI (Frontend)
|
||||||
|
@ -59,8 +60,6 @@ cd litmus/litmus-portal
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### For AMD64 Build
|
### For AMD64 Build
|
||||||
|
|
||||||
- To build only amd64 image export the variables from the above table.
|
- To build only amd64 image export the variables from the above table.
|
||||||
|
@ -71,12 +70,15 @@ cd litmus/litmus-portal
|
||||||
OR
|
OR
|
||||||
|
|
||||||
- Fill the ENVs from the above table in the given command and execute it.
|
- Fill the ENVs from the above table in the given command and execute it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ${DIRECTORY}
|
cd ${DIRECTORY}
|
||||||
docker build . -f Dockerfile -t ${REPONAME}/${IMAGE_NAME}:${IMG_TAG} --build-arg TARGETARCH=amd64
|
docker build . -f Dockerfile -t ${REPONAME}/${IMAGE_NAME}:${IMG_TAG} --build-arg TARGETARCH=amd64
|
||||||
docker push ${REPONAME}/${IMAGE_NAME}:${IMG_TAG}
|
docker push ${REPONAME}/${IMAGE_NAME}:${IMG_TAG}
|
||||||
```
|
```
|
||||||
|
|
||||||
For frontend image:
|
For frontend image:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend
|
cd frontend
|
||||||
docker build . -f Dockerfile -t $(REPONAME)/$(IMAGE_NAME):${IMG_TAG} --build-arg TARGETARCH=amd64 --build-arg REACT_APP_KB_CHAOS_VERSION=${IMG_TAG} \
|
docker build . -f Dockerfile -t $(REPONAME)/$(IMAGE_NAME):${IMG_TAG} --build-arg TARGETARCH=amd64 --build-arg REACT_APP_KB_CHAOS_VERSION=${IMG_TAG} \
|
||||||
|
@ -92,6 +94,7 @@ docker push $(REPONAME)/$(IMAGE_NAME):$(IMG_TAG)
|
||||||
- Once the docker buildx is setup export all the target platforms on which you want to deploy your images as a CSV Like `export PLATFORMS=linux/amd4,linux/arm64` along with the ENVs mentioned
|
- Once the docker buildx is setup export all the target platforms on which you want to deploy your images as a CSV Like `export PLATFORMS=linux/amd4,linux/arm64` along with the ENVs mentioned
|
||||||
in the above table.
|
in the above table.
|
||||||
- Build and push the multi-arch image using:
|
- Build and push the multi-arch image using:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make push-portal-component
|
make push-portal-component
|
||||||
```
|
```
|
||||||
|
@ -101,12 +104,14 @@ make push-portal-component
|
||||||
OR
|
OR
|
||||||
|
|
||||||
- Fill the ENVs from the above table in the given command and execute it.
|
- Fill the ENVs from the above table in the given command and execute it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ${DIRECTORY}
|
cd ${DIRECTORY}
|
||||||
docker buildx build -f Dockerfile --progress plane --push --no-cache --platform ${PLATFORMS} -t ${REPONAME}/$(IMAGE_NAME):$(IMG_TAG} .
|
docker buildx build -f Dockerfile --progress plane --push --no-cache --platform ${PLATFORMS} -t ${REPONAME}/$(IMAGE_NAME):$(IMG_TAG} .
|
||||||
```
|
```
|
||||||
|
|
||||||
For frontend image:
|
For frontend image:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ${DIRECTORY}
|
cd ${DIRECTORY}
|
||||||
docker buildx build . -f Dockerfile --progress plane --push --no-cache --platform ${PLATFORMS} -t ${REPONAME}/${IMAGE_NAME}:${IMG_TAG} \
|
docker buildx build . -f Dockerfile --progress plane --push --no-cache --platform ${PLATFORMS} -t ${REPONAME}/${IMAGE_NAME}:${IMG_TAG} \
|
|
@ -3,23 +3,9 @@ set -e
|
||||||
|
|
||||||
working_dir="litmus-portal"
|
working_dir="litmus-portal"
|
||||||
|
|
||||||
# Array of Image Names
|
declare -A MYMAP=( [frontend]="litmusportal-frontend:ci" [graphql-server]="litmusportal-server:ci" [authentication]="litmusportal-auth-server:ci" )
|
||||||
image_names=("litmusportal-frontend:ci" "litmusportal-server:ci" "litmusportal-auth-server:ci")
|
|
||||||
|
|
||||||
# Array of DockerFile Paths
|
|
||||||
dockerfile_paths=("frontend" "graphql-server/build" "authentication")
|
|
||||||
|
|
||||||
# Array of directories, for which images have to be build if changed
|
|
||||||
directory_array=("frontend" "graphql-server" "authentication")
|
|
||||||
|
|
||||||
# Building the images on the basic of changes in paths
|
# Building the images on the basic of changes in paths
|
||||||
for i in "${!directory_array[@]}"
|
current_dir=$(echo "$working_dir/$directory")
|
||||||
do
|
mkdir Images
|
||||||
current_dir=$(echo "$working_dir/${directory_array[$i]}")
|
docker build $current_dir -t litmuschaos/${MYMAP[$directory]} -f $working_dir/${directory}/Dockerfile
|
||||||
nofchanges=$(echo $changed_data | jq -r '[.[]."filename"] | join("\n")' | tr -d '"' | grep ^$current_dir | wc -l)
|
docker save "litmuschaos/${MYMAP[$directory]}" > Images/${directory}.tar
|
||||||
if [ $nofchanges != 0 ]
|
|
||||||
then
|
|
||||||
docker build $current_dir -t litmuschaos/${image_names[$i]} -f $working_dir/${dockerfile_paths[$i]}/Dockerfile
|
|
||||||
kind load docker-image litmuschaos/${image_names[$i]} --name kind
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -6,19 +6,13 @@ on:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
# Job for finding last commit sha of pull-request
|
||||||
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run')
|
find-latest-commit-sha:
|
||||||
runs-on: ubuntu-20.04
|
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run-e2e')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
commit-sha: ${{ steps.getcommit.outputs.sha }}
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Notification for Starting Testing.
|
|
||||||
uses: peter-evans/create-or-update-comment@v1
|
|
||||||
with:
|
|
||||||
comment-id: "${{ github.event.comment.id }}"
|
|
||||||
body: |
|
|
||||||
****
|
|
||||||
**Test Status:** The testing has been started please wait for the results ...
|
|
||||||
#Using the last commit id of pull request
|
|
||||||
- uses: octokit/request-action@v2.x
|
- uses: octokit/request-action@v2.x
|
||||||
id: get_PR_commits
|
id: get_PR_commits
|
||||||
with:
|
with:
|
||||||
|
@ -36,119 +30,151 @@ jobs:
|
||||||
env:
|
env:
|
||||||
response: ${{ steps.get_PR_commits.outputs.data }}
|
response: ${{ steps.get_PR_commits.outputs.data }}
|
||||||
|
|
||||||
|
find-changes:
|
||||||
|
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run-e2e')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: find-latest-commit-sha
|
||||||
|
# Set job outputs to values from filter step
|
||||||
|
outputs:
|
||||||
|
changed-paths: ${{ steps.filter.outputs.changes }}
|
||||||
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: ${{steps.getcommit.outputs.sha}}
|
ref: ${{ needs.find-latest-commit-sha.outputs.commit-sha }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: octokit/request-action@v2.x
|
- uses: dorny/paths-filter@v2
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
id: filter
|
||||||
name: Getting the files changed in current Pull-Request
|
|
||||||
id: get_files
|
|
||||||
with:
|
with:
|
||||||
route: GET /repos/:repo/pulls/:pull_number/files
|
ref: ${{ needs.find-latest-commit-sha.outputs.commit-sha }}
|
||||||
repo: ${{ github.repository }}
|
filters: |
|
||||||
pull_number: ${{ github.event.issue.number }}
|
frontend:
|
||||||
env:
|
- 'litmus-portal/frontend/**'
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
graphql-server:
|
||||||
|
- 'litmus-portal/graphql-server/**'
|
||||||
|
authentication:
|
||||||
|
- 'litmus-portal/authentication/**'
|
||||||
|
|
||||||
- name: Setting up KinD Cluster
|
docker-build-image:
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run-e2e')
|
||||||
uses: engineerd/setup-kind@v0.5.0
|
runs-on: ubuntu-latest
|
||||||
|
needs: [find-latest-commit-sha, find-changes]
|
||||||
|
strategy:
|
||||||
|
# Matrix of changed directories for building images in parallel
|
||||||
|
matrix:
|
||||||
|
path: ${{ fromJSON(needs.find-changes.outputs.changed-paths) }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
version: "v0.7.0"
|
ref: ${{ needs.find-latest-commit-sha.outputs.commit-sha }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Configuring and Testing the Cluster Installation
|
- name: Building Docker-Image for ${{ matrix.path }}
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
run: |
|
|
||||||
kubectl cluster-info --context kind-kind
|
|
||||||
kind get kubeconfig --internal >$HOME/.kube/config
|
|
||||||
kubectl get nodes
|
|
||||||
kubectl get pods -n kube-system
|
|
||||||
|
|
||||||
- name: Filtering the file paths and building images on the basic of changed files
|
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
run: |
|
run: |
|
||||||
chmod 755 ./.github/filter_and_build.sh
|
chmod 755 ./.github/filter_and_build.sh
|
||||||
./.github/filter_and_build.sh
|
./.github/filter_and_build.sh
|
||||||
env:
|
env:
|
||||||
changed_data: ${{steps.get_files.outputs.data}}
|
directory: ${{ matrix.path }}
|
||||||
|
|
||||||
|
- name: upload docker artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Docker-Images
|
||||||
|
path: Images
|
||||||
|
|
||||||
|
tests:
|
||||||
|
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/run-e2e')
|
||||||
|
needs: [docker-build-image]
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout litmus-E2E Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: litmuschaos/litmus-e2e
|
||||||
|
path: litmus-e2e
|
||||||
|
|
||||||
|
- name: Notification for Starting Testing.
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
comment-id: "${{ github.event.comment.id }}"
|
||||||
|
body: |
|
||||||
|
****
|
||||||
|
**Test Status:** The testing has been started please wait for the results ...
|
||||||
|
|
||||||
|
- name: Setting up KinD Cluster
|
||||||
|
uses: engineerd/setup-kind@v0.5.0
|
||||||
|
|
||||||
|
- name: Configuring and Testing the Cluster Installation
|
||||||
|
run: |
|
||||||
|
kubectl cluster-info --context kind-kind
|
||||||
|
kubectl get nodes
|
||||||
|
kubectl get pods -n kube-system
|
||||||
|
|
||||||
|
- name: download docker artifacts
|
||||||
|
uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Docker-Images
|
||||||
|
path: Images
|
||||||
|
|
||||||
|
# Loading all build images of changed components in KIND Cluster
|
||||||
|
- name: loading the docker build artifacts into KIND Cluster
|
||||||
|
run: |
|
||||||
|
ls -1 Images/*.tar | xargs --no-run-if-empty -L 1 kind load image-archive
|
||||||
|
|
||||||
- name: Deploying the litmus-portal for E2E testing
|
- name: Deploying the litmus-portal for E2E testing
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
run: |
|
run: |
|
||||||
wget https://raw.githubusercontent.com/litmuschaos/litmus/master/litmus-portal/cluster-k8s-manifest.yml
|
wget https://raw.githubusercontent.com/litmuschaos/litmus/master/litmus-portal/cluster-k8s-manifest.yml
|
||||||
sed -i 's/Always/IfNotPresent/g' cluster-k8s-manifest.yml
|
sed -i 's/Always/IfNotPresent/g' cluster-k8s-manifest.yml
|
||||||
kubectl apply -f cluster-k8s-manifest.yml
|
kubectl apply -f cluster-k8s-manifest.yml
|
||||||
kubectl get pods -n litmus
|
kubectl get pods -n litmus
|
||||||
kubectl get deployments -o wide -n litmus
|
kubectl get deployments -o wide -n litmus
|
||||||
kubectl wait --for=condition=Ready pods --all --namespace litmus --timeout=120s
|
source ./litmus-e2e/litmus/utils.sh
|
||||||
|
verify_all_components frontend,server litmus
|
||||||
|
wait_for_pods litmus 720
|
||||||
|
|
||||||
- name: Getting the ENV variables for using while testing
|
- name: Getting the ENV variables for using while testing
|
||||||
|
run: |
|
||||||
|
export NODE_NAME=$(kubectl -n litmus get pod -l "component=litmusportal-frontend" -o=jsonpath='{.items[*].spec.nodeName}')
|
||||||
|
export NODE_IP=$(kubectl -n litmus get nodes $NODE_NAME -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
|
||||||
|
export NODE_PORT=$(kubectl -n litmus get -o jsonpath="{.spec.ports[0].nodePort}" services litmusportal-frontend-service)
|
||||||
|
export AccessURL="http://$NODE_IP:$NODE_PORT"
|
||||||
|
echo "URL=$AccessURL" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Portal Authentication Tests
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
if: startsWith(github.event.comment.body, '/run-e2e')
|
||||||
run: |
|
|
||||||
export frontendPodName=$(kubectl get pods -l component=litmusportal-frontend --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' -n litmus)
|
|
||||||
export frontendPodPort=$(kubectl get pod $frontendPodName --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}' --namespace litmus)
|
|
||||||
kubectl port-forward $frontendPodName -n litmus 3001:$frontendPodPort &
|
|
||||||
|
|
||||||
- name: Setting Dependencies
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
if: startsWith(github.event.comment.body, '/run-unit')
|
|
||||||
with:
|
|
||||||
working-directory: litmus-portal/frontend
|
|
||||||
|
|
||||||
- name: Installing Dependencies for frontend.
|
|
||||||
if: startsWith(github.event.comment.body, '/run-unit')
|
|
||||||
run: |
|
|
||||||
HUSKY_SKIP_INSTALL=1 npm i
|
|
||||||
working-directory: litmus-portal/frontend
|
|
||||||
|
|
||||||
# Step for running all frontend Cypress unit tests.
|
|
||||||
- name: Starting cypress unit tests
|
|
||||||
if: startsWith(github.event.comment.body, '/run-unit')
|
|
||||||
uses: cypress-io/github-action@v2
|
|
||||||
continue-on-error: false
|
|
||||||
with:
|
|
||||||
command: npm run unit:ci
|
|
||||||
install: false
|
|
||||||
working-directory: litmus-portal/frontend
|
|
||||||
|
|
||||||
# Cloning the litmus-e2e repo for E2E tests.
|
|
||||||
- name: Cloning the litmus-e2e Repo
|
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
run: |
|
|
||||||
git clone https://github.com/litmuschaos/litmus-e2e.git -b litmus-portal
|
|
||||||
|
|
||||||
- name: Running basic tests (Login and Welcome Modal Tests)
|
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e-AuthTests') || startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
uses: cypress-io/github-action@v2
|
uses: cypress-io/github-action@v2
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
with:
|
with:
|
||||||
spec: cypress/integration/Basic_Setup/**/*.spec.js
|
spec: cypress/integration/Basic_Setup/**/*.spec.js
|
||||||
working-directory: litmus-e2e/CypressE2E/
|
working-directory: litmus-e2e/Cypress/
|
||||||
config-file: cypress.prod.json
|
config-file: cypress.prod.json
|
||||||
|
env: true
|
||||||
|
env:
|
||||||
|
CYPRESS_BASE_URL: ${{ env.URL }}
|
||||||
|
|
||||||
- name: Teaming and Account Settings Tests
|
- name: Verifying Execution Plane components
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e-Settings')
|
if: always()
|
||||||
uses: cypress-io/github-action@v2
|
run: |
|
||||||
continue-on-error: false
|
source ./litmus-e2e/litmus/utils.sh
|
||||||
with:
|
verify_all_components ${COMPONENTS} litmus
|
||||||
spec: cypress/integration/Parallel_Tests/Account_Settings/*.spec.js
|
wait_for_pods litmus 720
|
||||||
working-directory: litmus-e2e/CypressE2E/
|
env:
|
||||||
config-file: cypress.prod.json
|
COMPONENTS: subscriber,chaos-exporter,chaos-operator-ce,event-tracker,workflow-controller
|
||||||
|
|
||||||
- name: Run all E2E tests
|
- name: Post Authentication Tests
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e-all')
|
if: startsWith(github.event.comment.body, '/run-e2e')
|
||||||
uses: cypress-io/github-action@v2
|
uses: cypress-io/github-action@v2
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
with:
|
with:
|
||||||
spec: cypress/integration/Parallel_Tests/**/*.spec.js
|
spec: cypress/integration/Parallel_Tests/**/*.spec.js
|
||||||
working-directory: litmus-e2e/CypressE2E
|
working-directory: litmus-e2e/Cypress/
|
||||||
config-file: cypress.prod.json
|
config-file: cypress.prod.json
|
||||||
|
env: true
|
||||||
|
env:
|
||||||
|
CYPRESS_BASE_URL: ${{ env.URL }}
|
||||||
|
|
||||||
- name: Check the test run
|
- name: Check the test run
|
||||||
if: |
|
if: startsWith(github.event.comment.body, '/run-e2e')
|
||||||
startsWith(github.event.comment.body, '/run-unit') || startsWith(github.event.comment.body, '/run-e2e')
|
|
||||||
run: |
|
run: |
|
||||||
echo "TEST_RUN=true" >> $GITHUB_ENV
|
echo "TEST_RUN=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
@ -189,15 +215,5 @@ jobs:
|
||||||
RUN_ID: ${{ github.run_id }}
|
RUN_ID: ${{ github.run_id }}
|
||||||
|
|
||||||
- name: Deleting KinD cluster
|
- name: Deleting KinD cluster
|
||||||
if: startsWith(github.event.comment.body, '/run-e2e')
|
if: always()
|
||||||
run: kind delete cluster
|
run: kind delete cluster
|
||||||
|
|
||||||
merge:
|
|
||||||
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/merge')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Add a merge label when all jobs are passed
|
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
|
||||||
with:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
labels: merge
|
|
Loading…
Reference in New Issue