From df05fbf0dcca514c5691c9fe537794ca80b4c4d6 Mon Sep 17 00:00:00 2001 From: Dhruba Jyoti Chakraborty <61685945+codewdhruv@users.noreply.github.com> Date: Mon, 28 Nov 2022 14:20:05 +0530 Subject: [PATCH 01/22] Update samplereactapp.yaml --- .harness/samplereactapp.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.harness/samplereactapp.yaml b/.harness/samplereactapp.yaml index 55bf547..b9b2c32 100644 --- a/.harness/samplereactapp.yaml +++ b/.harness/samplereactapp.yaml @@ -20,6 +20,13 @@ pipeline: spec: shell: Sh command: npm install + - step: + type: Run + name: build app + identifier: run_tests + spec: + shell: Sh + command: npm run build - step: type: BuildAndPushDockerRegistry name: build and push to docker @@ -42,4 +49,3 @@ pipeline: connectorRef: <+input> repoName: sample-react-app-ci build: <+input> - From bf07ddc4b99d790f518b632ae5ad424a908cc314 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 05:07:15 +0530 Subject: [PATCH 02/22] Create pipeline test-react --- .harness/testreact.yaml | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .harness/testreact.yaml diff --git a/.harness/testreact.yaml b/.harness/testreact.yaml new file mode 100644 index 0000000..b807913 --- /dev/null +++ b/.harness/testreact.yaml @@ -0,0 +1,90 @@ +pipeline: + name: test-react + identifier: testreact + projectIdentifier: DhrubaCI + orgIdentifier: default + tags: {} + variables: + - name: DOCKERHUB_USERNAME + type: String + description: Your Docker Hub username + value: <+input> + stages: + - stage: + name: Build + identifier: Build + type: CI + spec: + cloneCodebase: true + execution: + steps: + - step: + type: Run + name: build app + identifier: build_app + spec: + shell: Sh + command: npm run build + - step: + type: Run + name: run tests + identifier: run_tests + spec: + shell: Sh + command: npm run test + - step: + type: BuildAndPushDockerRegistry + name: Build and Push an image to Docker Registry + identifier: BuildandPushanimagetoDockerRegistry + spec: + connectorRef: DhrubajyotiDocker + repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react + tags: + - <+pipeline.sequenceId> + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + - stage: + name: Run Connectivity Test + identifier: Run_Connectivity_Test + description: "" + type: CI + spec: + cloneCodebase: false + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + execution: + steps: + - step: + type: Background + name: Run Java HTTP Server + identifier: Run_Java_HTTP_Server + spec: + connectorRef: DhrubajyotiDocker + image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> + shell: Sh + portBindings: + "8888": "8888" + - step: + type: Run + name: Test Connection to Java HTTP Server + identifier: Test_Connection_to_Java_HTTP_Server + spec: + shell: Sh + command: |- + until curl --max-time 1 http://localhost:8888; do + sleep 2; + done + properties: + ci: + codebase: + connectorRef: dhrubaaccountconnector + repoName: react-pipeline-sample + build: <+input> From ed13b43fdec3e22a9d2293f48c91dadcf12c67f3 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 06:25:49 +0530 Subject: [PATCH 03/22] Create pipeline test-react-2 --- .harness/testreact2.yaml | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .harness/testreact2.yaml diff --git a/.harness/testreact2.yaml b/.harness/testreact2.yaml new file mode 100644 index 0000000..69c5e5b --- /dev/null +++ b/.harness/testreact2.yaml @@ -0,0 +1,90 @@ +pipeline: + name: test-react-2 + identifier: testreact2 + projectIdentifier: DhrubaCI + orgIdentifier: default + tags: {} + variables: + - name: DOCKERHUB_USERNAME + type: String + description: Your Docker Hub username + value: <+input> + stages: + - stage: + name: Build + identifier: Build + type: CI + spec: + cloneCodebase: true + execution: + steps: + - step: + type: Run + name: build app + identifier: build_app + spec: + shell: Sh + command: npm run build + - step: + type: Run + name: run tests + identifier: run_tests + spec: + shell: Sh + command: npm run test + - step: + type: BuildAndPushDockerRegistry + name: Build and Push an image to Docker Registry + identifier: BuildandPushanimagetoDockerRegistry + spec: + connectorRef: DhrubajyotiDocker + repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react + tags: + - <+pipeline.sequenceId> + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + - stage: + name: Run Connectivity Test + identifier: Run_Connectivity_Test + description: "" + type: CI + spec: + cloneCodebase: false + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + execution: + steps: + - step: + type: Background + name: Test Server + identifier: Test_Server + spec: + connectorRef: DhrubajyotiDocker + image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> + shell: Sh + portBindings: + "8888": "8888" + - step: + type: Run + name: Test Connection to Java HTTP Server + identifier: Test_Connection_to_Java_HTTP_Server + spec: + shell: Sh + command: |- + until curl --max-time 1 http://localhost:8888; do + sleep 2; + done + properties: + ci: + codebase: + connectorRef: dhrubaaccountconnector + repoName: react-pipeline-sample + build: <+input> From 539d23bc5fbc0a9f8f84c31deb3abe172a056f64 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 06:26:06 +0530 Subject: [PATCH 04/22] Create pipeline test-react-2 --- .harness/testreact3.yaml | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .harness/testreact3.yaml diff --git a/.harness/testreact3.yaml b/.harness/testreact3.yaml new file mode 100644 index 0000000..69c5e5b --- /dev/null +++ b/.harness/testreact3.yaml @@ -0,0 +1,90 @@ +pipeline: + name: test-react-2 + identifier: testreact2 + projectIdentifier: DhrubaCI + orgIdentifier: default + tags: {} + variables: + - name: DOCKERHUB_USERNAME + type: String + description: Your Docker Hub username + value: <+input> + stages: + - stage: + name: Build + identifier: Build + type: CI + spec: + cloneCodebase: true + execution: + steps: + - step: + type: Run + name: build app + identifier: build_app + spec: + shell: Sh + command: npm run build + - step: + type: Run + name: run tests + identifier: run_tests + spec: + shell: Sh + command: npm run test + - step: + type: BuildAndPushDockerRegistry + name: Build and Push an image to Docker Registry + identifier: BuildandPushanimagetoDockerRegistry + spec: + connectorRef: DhrubajyotiDocker + repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react + tags: + - <+pipeline.sequenceId> + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + - stage: + name: Run Connectivity Test + identifier: Run_Connectivity_Test + description: "" + type: CI + spec: + cloneCodebase: false + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + execution: + steps: + - step: + type: Background + name: Test Server + identifier: Test_Server + spec: + connectorRef: DhrubajyotiDocker + image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> + shell: Sh + portBindings: + "8888": "8888" + - step: + type: Run + name: Test Connection to Java HTTP Server + identifier: Test_Connection_to_Java_HTTP_Server + spec: + shell: Sh + command: |- + until curl --max-time 1 http://localhost:8888; do + sleep 2; + done + properties: + ci: + codebase: + connectorRef: dhrubaaccountconnector + repoName: react-pipeline-sample + build: <+input> From 8cf6723f52ce89d318c947f5e1252daa9fb7b763 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 06:26:25 +0530 Subject: [PATCH 05/22] Create pipeline react-hdh --- .harness/reacthdh.yaml | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .harness/reacthdh.yaml diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml new file mode 100644 index 0000000..4748fe0 --- /dev/null +++ b/.harness/reacthdh.yaml @@ -0,0 +1,90 @@ +pipeline: + name: react-hdh + identifier: reacthdh + projectIdentifier: DhrubaCI + orgIdentifier: default + tags: {} + variables: + - name: DOCKERHUB_USERNAME + type: String + description: Your Docker Hub username + value: <+input> + stages: + - stage: + name: Build + identifier: Build + type: CI + spec: + cloneCodebase: true + execution: + steps: + - step: + type: Run + name: build app + identifier: build_app + spec: + shell: Sh + command: npm run build + - step: + type: Run + name: run tests + identifier: run_tests + spec: + shell: Sh + command: npm run test + - step: + type: BuildAndPushDockerRegistry + name: Build and Push an image to Docker Registry + identifier: BuildandPushanimagetoDockerRegistry + spec: + connectorRef: DhrubajyotiDocker + repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react + tags: + - <+pipeline.sequenceId> + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + - stage: + name: Run Connectivity Test + identifier: Run_Connectivity_Test + description: "" + type: CI + spec: + cloneCodebase: false + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + execution: + steps: + - step: + type: Background + name: Test Server + identifier: Test_Server + spec: + connectorRef: DhrubajyotiDocker + image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> + shell: Sh + portBindings: + "8888": "8888" + - step: + type: Run + name: Test Connection to Java HTTP Server + identifier: Test_Connection_to_Java_HTTP_Server + spec: + shell: Sh + command: |- + until curl --max-time 1 http://localhost:8888; do + sleep 2; + done + properties: + ci: + codebase: + connectorRef: dhrubaaccountconnector + repoName: react-pipeline-sample + build: <+input> From 06f081311aa29c499b26e478795c0c0694a621c7 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 06:29:07 +0530 Subject: [PATCH 06/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 4748fe0..8d7d23f 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -18,6 +18,13 @@ pipeline: cloneCodebase: true execution: steps: + - step: + type: Run + name: install node modules + identifier: install_node_modules + spec: + shell: Sh + command: npm install - step: type: Run name: build app From 6140d46b249c5128170230f65269d0a59f336de1 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 06:49:04 +0530 Subject: [PATCH 07/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 8d7d23f..d199fd8 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -38,7 +38,7 @@ pipeline: identifier: run_tests spec: shell: Sh - command: npm run test + command: "# npm run test" - step: type: BuildAndPushDockerRegistry name: Build and Push an image to Docker Registry From 9b268eb8492ac2eccf32a7e032ceeb37b45ec1e1 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:03:47 +0530 Subject: [PATCH 08/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index d199fd8..e44f2f9 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -44,7 +44,7 @@ pipeline: name: Build and Push an image to Docker Registry identifier: BuildandPushanimagetoDockerRegistry spec: - connectorRef: DhrubajyotiDocker + connectorRef: harnesscommunitydocker repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react tags: - <+pipeline.sequenceId> @@ -74,7 +74,7 @@ pipeline: name: Test Server identifier: Test_Server spec: - connectorRef: DhrubajyotiDocker + connectorRef: harnesscommunitydocker image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> shell: Sh portBindings: From f656dbba85275b9524f3032c3823ddc2a60bdae3 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:11:57 +0530 Subject: [PATCH 09/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index e44f2f9..d2ee64c 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -85,10 +85,7 @@ pipeline: identifier: Test_Connection_to_Java_HTTP_Server spec: shell: Sh - command: |- - until curl --max-time 1 http://localhost:8888; do - sleep 2; - done + command: curl http://localhost:8888 properties: ci: codebase: From 4ab97ebb179aba21960b49e48eef8cffa9be6578 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:12:51 +0530 Subject: [PATCH 10/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index d2ee64c..10dcc79 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -92,3 +92,4 @@ pipeline: connectorRef: dhrubaaccountconnector repoName: react-pipeline-sample build: <+input> + allowStageExecutions: true From a62d7eb05255de8cceb1ef1194ffd1d662fdab7c Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:15:28 +0530 Subject: [PATCH 11/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 10dcc79..735cab5 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -85,7 +85,7 @@ pipeline: identifier: Test_Connection_to_Java_HTTP_Server spec: shell: Sh - command: curl http://localhost:8888 + command: curl http://Test_Server:8888 properties: ci: codebase: From 92226448e267b6a4f1348b55a586ae4f662c9ca2 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:19:34 +0530 Subject: [PATCH 12/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 735cab5..8bbc9b9 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -78,14 +78,14 @@ pipeline: image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> shell: Sh portBindings: - "8888": "8888" + "8080": "8080" - step: type: Run - name: Test Connection to Java HTTP Server + name: test connection identifier: Test_Connection_to_Java_HTTP_Server spec: shell: Sh - command: curl http://Test_Server:8888 + command: curl reactjs_server:8080 properties: ci: codebase: From eed7a3847c75a2e20cff88bb11fcaffbb01c45d5 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:21:11 +0530 Subject: [PATCH 13/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 8bbc9b9..7f93c25 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -71,8 +71,8 @@ pipeline: steps: - step: type: Background - name: Test Server - identifier: Test_Server + name: reactjs server + identifier: reactjs_server spec: connectorRef: harnesscommunitydocker image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> From 38246da92b968521a61b4f80398dca8e6dbe4308 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:22:48 +0530 Subject: [PATCH 14/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 7f93c25..1030269 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -84,6 +84,8 @@ pipeline: name: test connection identifier: Test_Connection_to_Java_HTTP_Server spec: + connectorRef: account.harnessImage + image: curlimages/curl:7.73.0 shell: Sh command: curl reactjs_server:8080 properties: From ac46e4a382148813e82343e63ca12bdcb38cd695 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:27:04 +0530 Subject: [PATCH 15/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 1030269..e188a21 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -77,6 +77,9 @@ pipeline: connectorRef: harnesscommunitydocker image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> shell: Sh + command: |- + cd /src + node index.js portBindings: "8080": "8080" - step: @@ -87,7 +90,9 @@ pipeline: connectorRef: account.harnessImage image: curlimages/curl:7.73.0 shell: Sh - command: curl reactjs_server:8080 + command: |- + sleep 10 + curl reactjs_server:8080 properties: ci: codebase: From 35bea2dda24f4af8401cdd2ee2ed01de9f42a14c Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:33:46 +0530 Subject: [PATCH 16/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index e188a21..363324a 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -91,8 +91,9 @@ pipeline: image: curlimages/curl:7.73.0 shell: Sh command: |- - sleep 10 - curl reactjs_server:8080 + until curl --max-time 1 http://localhost:8080; do + sleep 2; + done properties: ci: codebase: From 2183d06d8686b2f89536ce50626f974930bfa7f5 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:36:16 +0530 Subject: [PATCH 17/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 363324a..5f8d081 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -77,9 +77,6 @@ pipeline: connectorRef: harnesscommunitydocker image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> shell: Sh - command: |- - cd /src - node index.js portBindings: "8080": "8080" - step: @@ -90,10 +87,7 @@ pipeline: connectorRef: account.harnessImage image: curlimages/curl:7.73.0 shell: Sh - command: |- - until curl --max-time 1 http://localhost:8080; do - sleep 2; - done + command: curl http://localhost:8080 properties: ci: codebase: From 953014addcf05e922888cec08711383425b881d5 Mon Sep 17 00:00:00 2001 From: Dhruba Jyoti Chakraborty <61685945+codewdhruv@users.noreply.github.com> Date: Tue, 27 Dec 2022 07:41:47 +0530 Subject: [PATCH 18/22] Update Dockerfile --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index cdfb36b..d2ab5f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,3 +7,5 @@ RUN npm run build FROM nginx:1.19 COPY ./nginx/nginx.conf /etc/nginx/nginx.conf COPY --from=build /react-app/build /usr/share/nginx/html +EXPOSE 8080 + From ee1bc1eb3c4dbfd3c4901491062a1e3a12109228 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Tue, 27 Dec 2022 07:48:18 +0530 Subject: [PATCH 19/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index 5f8d081..bbf241b 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -87,7 +87,7 @@ pipeline: connectorRef: account.harnessImage image: curlimages/curl:7.73.0 shell: Sh - command: curl http://localhost:8080 + command: curl http://reactjs_server:8080 properties: ci: codebase: From 63ca65be91d095c0ce249cac304db1efaf75cff9 Mon Sep 17 00:00:00 2001 From: Dhruba Jyoti Chakraborty <61685945+codewdhruv@users.noreply.github.com> Date: Tue, 27 Dec 2022 07:51:11 +0530 Subject: [PATCH 20/22] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index d2ab5f2..864e183 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ COPY package.json ./ RUN npm install COPY . . RUN npm run build +EXPOSE 8080 FROM nginx:1.19 COPY ./nginx/nginx.conf /etc/nginx/nginx.conf COPY --from=build /react-app/build /usr/share/nginx/html From 8572c9ed23e1e1d2e2c4a057a03f110e3843f054 Mon Sep 17 00:00:00 2001 From: rkapoor10 Date: Tue, 10 Jan 2023 13:17:49 +0530 Subject: [PATCH 21/22] TDD: for a sample react application --- .gitignore | 5 +++ package-lock.json | 28 +++++++++--- package.json | 1 + src/App.css | 36 +++------------ src/App.js | 26 +++++------ src/App.test.js | 4 +- src/components/Form.js | 44 ++++++++++++++++++ src/components/Header.js | 6 +++ src/components/Table.js | 36 +++++++++++++++ src/index.css | 12 ----- src/reducer/table.reducer.js | 39 ++++++++++++++++ src/reducer/table.reducer.test.js | 74 +++++++++++++++++++++++++++++++ 12 files changed, 245 insertions(+), 66 deletions(-) create mode 100644 src/components/Form.js create mode 100644 src/components/Header.js create mode 100644 src/components/Table.js create mode 100644 src/reducer/table.reducer.js create mode 100644 src/reducer/table.reducer.test.js diff --git a/.gitignore b/.gitignore index e43b0f9..b77f0c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ .DS_Store + +node_modules + +/coverage.data +/coverage/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2c09763..49a8347 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", + "uuid": "^9.0.0", "web-vitals": "^2.1.4" } }, @@ -14981,6 +14982,14 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -15985,9 +15994,9 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "bin": { "uuid": "dist/bin/uuid" } @@ -27514,6 +27523,13 @@ "faye-websocket": "^0.11.3", "uuid": "^8.3.2", "websocket-driver": "^0.7.4" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + } } }, "source-list-map": { @@ -28261,9 +28277,9 @@ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==" }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" }, "v8-to-istanbul": { "version": "8.1.1", diff --git a/package.json b/package.json index 57fe9f7..638d190 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", + "uuid": "^9.0.0", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/App.css b/src/App.css index 74b5e05..00d9bec 100644 --- a/src/App.css +++ b/src/App.css @@ -2,37 +2,13 @@ text-align: center; } -.App-logo { - height: 40vmin; - pointer-events: none; +table { + margin: 4rem auto; } -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } +table, +th, +td { + border: 1px solid black; } -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js index 3784575..e3838a0 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,17 @@ -import logo from './logo.svg'; -import './App.css'; +import "./App.css"; +import { useReducer } from "react"; +import tableReducer, { initialState } from "./reducer/table.reducer"; +import Header from "./components/Header"; +import Form from "./components/Form"; +import Table from "./components/Table"; function App() { + const [state, dispatch] = useReducer(tableReducer, initialState); return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+
+
+ ); } diff --git a/src/App.test.js b/src/App.test.js index 1f03afe..1923bf3 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -3,6 +3,6 @@ import App from './App'; test('renders learn react link', () => { render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); + const titleElement = screen.getByText(/React Sample Application/i); + expect(titleElement).toBeInTheDocument(); }); diff --git a/src/components/Form.js b/src/components/Form.js new file mode 100644 index 0000000..1d4a872 --- /dev/null +++ b/src/components/Form.js @@ -0,0 +1,44 @@ +import { useState } from "react"; +import { v4 as uuidv4 } from "uuid"; + +const Form = ({dispatch}) => { + const initialObj = { + id: uuidv4(), + name: "", + role: "", + } + const [contributorObj, setContributorObj] = useState(initialObj); + return( +
+

Form

+ + setContributorObj({ ...contributorObj, name: e.target.value }) + } + /> + + setContributorObj({ ...contributorObj, role: e.target.value }) + } + /> + +
+ ) +} + + +export default Form \ No newline at end of file diff --git a/src/components/Header.js b/src/components/Header.js new file mode 100644 index 0000000..20ec67a --- /dev/null +++ b/src/components/Header.js @@ -0,0 +1,6 @@ +const Header = () => { + return
+

React Sample Application

+
; +} +export default Header \ No newline at end of file diff --git a/src/components/Table.js b/src/components/Table.js new file mode 100644 index 0000000..63c3505 --- /dev/null +++ b/src/components/Table.js @@ -0,0 +1,36 @@ +const Table = ({ state, dispatch }) => { + return ( +
+ + + + + + + + {state.members?.map((contributor) => { + return ( + + + + + + ); + })} + +
NameRole
{contributor.name}{contributor.role} + +
+ ); +}; + +export default Table; diff --git a/src/index.css b/src/index.css index ec2585e..8b13789 100644 --- a/src/index.css +++ b/src/index.css @@ -1,13 +1 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/src/reducer/table.reducer.js b/src/reducer/table.reducer.js new file mode 100644 index 0000000..2080d4e --- /dev/null +++ b/src/reducer/table.reducer.js @@ -0,0 +1,39 @@ +export const initialState = { + members: [{ id: 1234, name: "Jessica Adams", role: "Community Engineer" }], + totalMembers: 1, +}; + +const tableReducer = (state = initialState, action) => { + switch (action.type) { + case "ADD_MEMBER": + console.log("result", { + ...state, + members: [...state.members, action.payload.member], + totalMembers: state.totalMembers + 1, + }); + return { + ...state, + members: [...state.members, action.payload.member], + totalMembers: state.totalMembers + 1, + }; + + case "REMOVE_MEMBER": + const memberToBeRemoved = state.members.find( + (member) => member.id === action.payload.member.id + ); + + const members = state.members.filter( + (member) => member.id !== action.payload.member.id + ); + return { + ...state, + members, + totalMembers: state.totalMembers - 1, + }; + + default: + break; + } +}; + +export default tableReducer; diff --git a/src/reducer/table.reducer.test.js b/src/reducer/table.reducer.test.js new file mode 100644 index 0000000..886d69e --- /dev/null +++ b/src/reducer/table.reducer.test.js @@ -0,0 +1,74 @@ +import tableReducer, { initialState } from "./table.reducer"; + +describe("testing reducer", () => { + test("ADD_MEMBER", () => { + const initialState = { + members: [ + { id: 1234, name: "Jessica Adams", role: "Community Engineer" }, + ], + totalMembers: 1, + }; + + const action = { + type: "ADD_MEMBER", + payload: { + member: { + id: 1235, + name: "Ompragash Vishwanathan", + role: "Senior Software Engineer", + }, + }, + }; + + const expectedState = { + members: [ + { id: 1234, name: "Jessica Adams", role: "Community Engineer" },{ + id: 1235, + name: "Ompragash Vishwanathan", + role: "Senior Software Engineer", + } + ], + totalMembers: 2, + }; + + const state = tableReducer(initialState, action) + expect(state).toEqual(expectedState) + }); + + + test("REMOVE_MEMBER", () => { + const initialState = { + members: [ + { id: 1234, name: "Jessica Adams", role: "Community Engineer" }, + { id: 1235, name: "Ompragash Vishwanathan", role: "Senior Software Engineer" }, + { id: 1236, name: "Pravin Mali", role: "Community Engineer Manager" }, + { id: 1237, name: "Alex Garg", role: "Community Engineer" }, + ], + totalMembers: 4, + }; + + const action = { + type: "REMOVE_MEMBER", + payload: { + member: { + id: 1237, + name: "Alex Garg", + role: "Community Engineer", + }, + }, + }; + + const expectedState = { + members: [ + { id: 1234, name: "Jessica Adams", role: "Community Engineer" }, + { id: 1235, name: "Ompragash Vishwanathan", role: "Senior Software Engineer" }, + { id: 1236, name: "Pravin Mali", role: "Community Engineer Manager" } + ], + totalMembers: 3, + }; + + const state = tableReducer(initialState, action) + expect(state).toEqual(expectedState) + + }) +}); From 2754aed4801ddb15ef085c0fe74f46269b7878f8 Mon Sep 17 00:00:00 2001 From: "dhrubajyoti.chakraborty" Date: Fri, 13 Jan 2023 09:09:25 +0530 Subject: [PATCH 22/22] Update pipeline react-hdh --- .harness/reacthdh.yaml | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/.harness/reacthdh.yaml b/.harness/reacthdh.yaml index bbf241b..c3771e0 100644 --- a/.harness/reacthdh.yaml +++ b/.harness/reacthdh.yaml @@ -54,40 +54,6 @@ pipeline: runtime: type: Cloud spec: {} - - stage: - name: Run Connectivity Test - identifier: Run_Connectivity_Test - description: "" - type: CI - spec: - cloneCodebase: false - platform: - os: Linux - arch: Amd64 - runtime: - type: Cloud - spec: {} - execution: - steps: - - step: - type: Background - name: reactjs server - identifier: reactjs_server - spec: - connectorRef: harnesscommunitydocker - image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId> - shell: Sh - portBindings: - "8080": "8080" - - step: - type: Run - name: test connection - identifier: Test_Connection_to_Java_HTTP_Server - spec: - connectorRef: account.harnessImage - image: curlimages/curl:7.73.0 - shell: Sh - command: curl http://reactjs_server:8080 properties: ci: codebase: