.only-default: &only-default only: - release - master - merge_requests .set_env_variables: &set_env_variables - | if [ "$CI_COMMIT_BRANCH" == "master" ]; then REACT_APP_ENVIRONMENT="PRODUCTION" REACT_APP_BASE_URL="https://api.appsmith.com" elif [ "$CI_COMMIT_BRANCH" == "release" ]; then REACT_APP_ENVIRONMENT="STAGING" REACT_APP_BASE_URL="https://release-api.appsmith.com" else REACT_APP_ENVIRONMENT="DEVELOPMENT" REACT_APP_BASE_URL="https://release-api.appsmith.com" fi # This image contains Nginx & Cypress binaries image: appsmith/cypress-nginx variables: npm_config_cache: "$CI_PROJECT_DIR/.npm" CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress" DOCKER_DRIVER: overlay DOCKER_IMAGE_NAME: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA cache: key: ${CI_COMMIT_REF_SLUG} paths: - .npm - cache/Cypress - node_modules stages: - build - test - package - deploy react-build-release: stage: build script: - *set_env_variables - yarn install # show where the Cypress test runner binaries are cached - $(npm bin)/cypress cache path # show all installed versions of Cypress binary - $(npm bin)/cypress cache list - $(npm bin)/cypress verify - REACT_APP_ENVIRONMENT=$REACT_APP_ENVIRONMENT REACT_APP_BASE_URL=$REACT_APP_BASE_URL GIT_SHA=$CI_COMMIT_SHORT_SHA yarn build artifacts: expire_in: 1 week paths: - build/ only: - release - merge_requests unit_test: stage: test script: - *set_env_variables - yarn run test:unit only: - release - merge_requests # all jobs that actually run tests can use the same definition .test_job_template: image: appsmith/cypress-nginx stage: test script: - *set_env_variables # This is required in order to ensure that all the test cases pass - echo "127.0.0.1 dev.appsmith.com" >> /etc/hosts - serve -s build -p 3000 & - mkdir -p /var/www/appsmith /etc/certificate - cp ./docker/nginx-linux.conf /etc/nginx/conf.d/app.conf - cp $APPSMITH_SSL_CERTIFICATE /etc/certificate/dev.appsmith.com.pem - cp $APPSMITH_SSL_KEY /etc/certificate/dev.appsmith.com-key.pem - nginx - yarn test:ci artifacts: when: always expire_in: 1 week paths: - cypress/screenshots - cypress/videos only: # We don't test on master right now because of changing environment variables for REACT_APP_BASE_URL. Need to figure out a way to configure that. - release - merge_requests cypress-test-release-1: extends: .test_job_template cypress-test-release-2: extends: .test_job_template cypress-test-release-3: extends: .test_job_template cypress-test-release-4: extends: .test_job_template cypress-test-release-5: extends: .test_job_template cypress-test-release-6: extends: .test_job_template docker-package-release: image: docker:dind services: - docker:dind stage: package script: - *set_env_variables - docker build -t appsmith/appsmith-editor:release . - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_ACCESS_TOKEN - docker push appsmith/appsmith-editor:release only: - release react-build-prod: stage: build script: - *set_env_variables - yarn install - REACT_APP_ENVIRONMENT=$REACT_APP_ENVIRONMENT GIT_SHA=$CI_COMMIT_SHORT_SHA yarn build artifacts: when: on_success expire_in: 1 week paths: - build/ only: - master docker-package-prod: image: docker:dind services: - docker:dind stage: package script: - *set_env_variables - docker build -t appsmith/appsmith-editor:latest . - docker build -t appsmith/appsmith-editor:$CI_COMMIT_SHORT_SHA . - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_ACCESS_TOKEN # If we don't add the tag to the `docker push` command, all the tags for this image will be pushed - docker push appsmith/appsmith-editor only: - master