diff --git a/.github/workflows/client-test.yml b/.github/workflows/test-build-docker-image.yml similarity index 72% rename from .github/workflows/client-test.yml rename to .github/workflows/test-build-docker-image.yml index fa966b11f6..4d34865766 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/test-build-docker-image.yml @@ -1,4 +1,4 @@ -name: Appsmith Test Workflow +name: Test, build and push Docker Image on: # This line enables manual triggering of this workflow. @@ -10,6 +10,7 @@ on: paths: - "app/client/**" - "app/server/**" + - "app/rts/**" - "!app/client/cypress/manual_TestSuite/**" # trigger for pushes to release and master @@ -18,6 +19,7 @@ on: paths: - "app/client/**" - "app/server/**" + - "app/rts/**" - "!app/client/cypress/manual_TestSuite/**" # Change the working directory for all the jobs in this workflow @@ -40,12 +42,12 @@ jobs: working-directory: app/client shell: bash - steps: + steps: # Checkout the code - uses: actions/checkout@v2 with: fetch-depth: 0 - + # Checkout the code - name: Checkout the merged commit from PR and base branch if: github.event_name == 'pull_request_review' @@ -136,7 +138,7 @@ jobs: runs-on: ubuntu-latest # Only run this workflow for internally triggered events if: | - github.event.pull_request.head.repo.full_name == github.repository || + github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' || github.event_name == 'workflow_dispatch' @@ -193,8 +195,8 @@ jobs: echo "next_version = $next_version" echo ::set-output name=version::$next_version-SNAPSHOT echo ::set-output name=tag::$(echo ${GITHUB_REF:11}) - - - name: Build package + + - name: Test and Build package env: APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools" APPSMITH_REDIS_URL: "redis://127.0.0.1:6379" @@ -212,10 +214,65 @@ jobs: name: build path: app/server/dist/ + buildRts: + defaults: + run: + working-directory: app/rts + runs-on: ubuntu-latest + # Only run this workflow for internally triggered events + if: | + github.event.pull_request.head.repo.full_name == github.repository || + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + + steps: + # Checkout the code + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Use Node.js 14.15.4 + uses: actions/setup-node@v1 + with: + node-version: "14.15.4" + + # Here, the GITHUB_REF is of type /refs/head/. We extract branch_name from this by removing the + # first 11 characters. This can be used to build images for several branches + # Since this is an unreleased build, we get the latest released version number, increment the minor number in it, + # append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version. + - name: Get the version to tag the Docker image + id: vars + run: | + # Since this is an unreleased build, we set the version to incremented version number with a + # `-SNAPSHOT` suffix. + latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head -1)" + echo "latest_released_version = $latest_released_version" + next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')" + echo "next_version = $next_version" + echo ::set-output name=version::$next_version-SNAPSHOT + echo ::set-output name=tag::$(echo ${GITHUB_REF:11}) + + - name: Build + run: ./build.sh + + # Upload the build artifact so that it can be used by the test & deploy job in the workflow + - name: Upload server build bundle + uses: actions/upload-artifact@v2 + with: + name: build + path: app/rts/dist/ + ui-test: - needs: [buildClient, buildServer] + needs: [buildClient, buildServer, buildRts] # Only run if the build step is successful - if: success() + # If the build has been triggered manually via workflow_dispatch or via a push to protected branches + # then we don't check for the PR approved state + if: | + success() && + (github.event_name == 'workflow_dispatch' || + github.event_name == 'push' || + (github.event_name == 'pull_request_review' && + github.event.review.state == 'approved')) runs-on: ubuntu-latest defaults: run: @@ -225,7 +282,7 @@ jobs: fail-fast: false matrix: job: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] - + # Service containers to run with this job. Required for running tests services: # Label used to access the service container @@ -250,7 +307,7 @@ jobs: - name: Checkout the head commit of the branch if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' - uses: actions/checkout@v2 + uses: actions/checkout@v2 # Setup Java - name: Set up JDK 1.11 @@ -292,7 +349,7 @@ jobs: echo ::set-output name=tag::$(echo ${GITHUB_REF:11}) # Start server - - name: start server + - name: Start server working-directory: app/server env: APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools" @@ -311,11 +368,12 @@ jobs: - name: Wait for 30 seconds for server to start run: | - sleep 30s - - - name: Exit if Server hasnt started + sleep 30s + + - name: "Exit if Server hasn't started" run: | - if [[ `ps -ef | grep "server-1.0-SNAPSHOT" | grep java |wc -l` == 0 ]]; then + lsof -i :8080 || true; + if [[ `ps -ef | grep "server-1.0-SNAPSHOT" | grep java |wc -l` == 0 ]]; then echo "Server Not Started"; exit 1; else @@ -418,7 +476,6 @@ jobs: ui-test-result: needs: ui-test - # Only run if the ui-test with matrices step is successful if: always() runs-on: ubuntu-latest defaults: @@ -467,6 +524,18 @@ jobs: name: build path: app/client/build + - name: Download the server build artifact + uses: actions/download-artifact@v2 + with: + name: build + path: app/server/dist + + - name: Download the server build artifact + uses: actions/download-artifact@v2 + with: + name: build + path: app/rts/dist + # Here, the GITHUB_REF is of type /refs/head/. We extract branch_name from this by removing the # first 11 characters. This can be used to build images for several branches - name: Get the version to tag the Docker image @@ -474,27 +543,82 @@ jobs: run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11}) # Build release Docker image and push to Docker Hub - - name: Push release image to Docker Hub + - name: Push client release image to Docker Hub if: success() && github.ref == 'refs/heads/release' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - run: | - docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.branch_name.outputs.tag}} . - echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin - docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.branch_name.outputs.tag}} - - # Build release-frozen Docker image and push to Docker Hub - - name: Push release-frozen image to Docker Hub - if: success() && github.ref == 'refs/heads/release-frozen' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + working-directory: app/client run: | docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.branch_name.outputs.tag}} . echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.branch_name.outputs.tag}} # Build master Docker image and push to Docker Hub - - name: Push production image to Docker Hub with commit tag + - name: Push client master image to Docker Hub with commit tag if: success() && github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + working-directory: app/client run: | docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${GITHUB_SHA} . docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:nightly . echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${GITHUB_SHA} docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:nightly + + # Build release Docker image and push to Docker Hub + - name: Push server release image to Docker Hub + if: success() && github.ref == 'refs/heads/release' + working-directory: app/server + run: | + docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{steps.vars.outputs.tag}} . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{steps.vars.outputs.tag}} + + # Build master Docker image and push to Docker Hub + - name: Push server master image to Docker Hub with commit tag + if: success() && github.ref == 'refs/heads/master' + working-directory: app/server + run: | + docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${GITHUB_SHA} . + docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:nightly . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${GITHUB_SHA} + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:nightly + + # Build release Docker image and push to Docker Hub + - name: Push RTS release image to Docker Hub + if: success() && github.ref == 'refs/heads/release' + working-directory: app/rts + run: | + docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${{steps.vars.outputs.tag}} . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${{steps.vars.outputs.tag}} + + # Build master Docker image and push to Docker Hub + - name: Push RTS master image to Docker Hub with commit tag + if: success() && github.ref == 'refs/heads/master' + working-directory: app/rts + run: | + docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${GITHUB_SHA} . + docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:nightly . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${GITHUB_SHA} + docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:nightly + + - name: Build and push release image to Docker Hub + if: success() && github.ref == 'refs/heads/release' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + run: | + docker build \ + --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} \ + --tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:${{steps.branch_name.outputs.tag}} \ + . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push --all-tags ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce + + - name: Build and push master image to Docker Hub with commit tag + if: success() && github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') + run: | + docker build \ + --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} \ + --tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:${GITHUB_SHA} \ + --tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:nightly \ + . + echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin + docker push --all-tags ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce diff --git a/app/client/cypress/setup-test.sh b/app/client/cypress/setup-test.sh index 6b55ad5cb3..47d47f2ff4 100755 --- a/app/client/cypress/setup-test.sh +++ b/app/client/cypress/setup-test.sh @@ -1,6 +1,6 @@ #! /bin/sh -# This script is responsible for setting up the local Nginx server for running E2E Cypress tests +# This script is responsible for setting up the local Nginx server for running E2E Cypress tests # on our CI/CD system. Currently the script is geared towards Github Actions # Serve the react bundle on a specific port. Nginx will proxy to this port @@ -47,7 +47,15 @@ echo "Sleeping for 30 seconds to let the servers start" sleep 30 echo "Checking if the containers have started" -sudo docker ps -a +sudo docker ps -a +for fcid in $(sudo docker ps -a | awk '/Exited/ { print $1 }'); do + echo "Logs for container '$fcid'." + docker logs "$fcid" +done +if sudo docker ps -a | grep -q Exited; then + echo "One or more containers failed to start." >&2 + exit 1 +fi echo "Checking if the server has started" status_code=$(curl -o /dev/null -s -w "%{http_code}\n" https://dev.appsmith.com/api/v1/users) @@ -62,7 +70,7 @@ while [ "$retry_count" -le "3" -a "$status_code" -eq "502" ]; do done echo "Checking if client and server have started" -ps -ef |grep java 2>&1 +ps -ef |grep java 2>&1 ps -ef |grep serve 2>&1 if [ "$status_code" -eq "502" ]; then @@ -70,7 +78,7 @@ if [ "$status_code" -eq "502" ]; then exit 1 fi -# Create the test user +# Create the test user curl -k --request POST -v 'https://dev.appsmith.com/api/v1/users' \ --header 'Content-Type: application/json' \ --data-raw '{