From 7fb7be3860729f8b4674c0b1c6b23529a0a5bb86 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Thu, 29 Oct 2020 14:06:44 -0300 Subject: [PATCH] Add circleci config --- .circleci/config.yml | 84 ++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + Makefile | 25 +++++++++++++ build.sh | 1 - client/package.json | 2 +- server/composer.json | 6 ++++ 6 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..7cd72c9b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,84 @@ +version: 2.1 +orbs: + php: circleci/php@1.0.2 + node: circleci/node@1.1.6 + aws-cli: circleci/aws-cli@1.0.0 +jobs: + install_composer_packages: + executor: php/default + steps: + - checkout + - php/install-composer + + - run: + name: Install php extensions + command: | + sudo add-apt-repository ppa:ondrej/php + sudo apt install php-imap + + - php/install-packages: + app-dir: server/ + + - persist_to_workspace: + root: . + paths: + - . + + install_node_packages: + docker: + - image: circleci/node:11.15.0-stretch + + steps: + - attach_workspace: + at: . + + - restore_cache: + keys: + - node-cache-{{ checksum "client/package.json" }} + + - run: + name: Install dependencies + command: | + sudo npm install -g npm@6.7.0 + sudo npm install -g mocha@6.2.0 + cd client && npm install + + - save_cache: + paths: + - client/node_modules + key: node-cache-{{ checksum "client/package.json" }} + + - persist_to_workspace: + root: . + paths: + - . + + deploy_staging_files: + docker: + - image: circleci/node:11.15.0-stretch + + steps: + - attach_workspace: + at: . + + - deploy: + name: Deploy staging files + command: | + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + sudo python get-pip.py pip==19.3.1 + sudo pip install awscli + sudo apt-get update + sudo apt-get install lftp + if [ "$CIRCLE_BRANCH" = "master" ]; then make deploy-staging-files; fi + +workflows: + install: + jobs: + - install_composer_packages + - install_node_packages: + requires: + - install_composer_packages + - deploy_staging_files: + requires: + - install_node_packages + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 657ebbbe..428f575a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea .jshintrc +.DS_Store client/package-lock.json tests/Gemfile.lock server/composer.lock diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..475a1038 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +deploy-staging-files: + ./build.sh + FOLDER=dev1 DOMAIN=dev1.opensupports.com make deploy-instance-files + FOLDER=dev2 DOMAIN=dev2.opensupports.com make deploy-instance-files + BUCKET=opensupports-packages FILE=dist/opensupports_dev.zip make s3upload + +deploy-instance-files: + cd client && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R build /${FOLDER}" && \ + cd ../api && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; put -O /${FOLDER}/api/ index.php" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; put -O /${FOLDER}/api/ .htaccess" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; put -O /${FOLDER}/api/ composer.json" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; put -O /${FOLDER}/api/ composer.lock" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R controllers/ /${FOLDER}/api/controllers/" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R data/ /${FOLDER}/api/data/" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R libs/ /${FOLDER}/api/libs/" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R models/ /${FOLDER}/api/models/" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R files/ /${FOLDER}/api/files" && \ + lftp -c "open -u $(FTP_USER),$(FTP_PASSWORD) $(FTP_HOST); set ssl:verify-certificate no; mirror -R vendor/ /${FOLDER}/api/vendor" || true && \ + (curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://${DOMAIN}/api/clear.php || true) && \ + cd .. ; + +s3upload: + aws s3 cp ${FILE} s3://$(BUCKET)/ --cache-control max-age=0 diff --git a/build.sh b/build.sh index 844acc4c..3ebce7e4 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,6 @@ npm run build rm build/index.html echo "2/3 Creating api folder..." cd ../server -composer install echo -n > config.php mkdir files2 mv files/.htaccess files2 diff --git a/client/package.json b/client/package.json index d0eeea56..af22ad0d 100644 --- a/client/package.json +++ b/client/package.json @@ -15,7 +15,7 @@ "scripts": { "start": "webpack-dev-server", "start-fixtures": "webpack-dev-server --env.FIXTURES=1", - "build": "rimraf build && NODE_ENV=production webpack -p --devtool none", + "build": "./node_modules/.bin/rimraf build && NODE_ENV=production ./node_modules/.bin/webpack -p --devtool none", "test": "export NODE_PATH=src && mocha src/lib-test/preprocessor.js --require @babel/register --recursive src/**/**/__tests__/*-test.js" }, "devDependencies": { diff --git a/server/composer.json b/server/composer.json index 698d7607..3866abae 100755 --- a/server/composer.json +++ b/server/composer.json @@ -1,4 +1,10 @@ { + "config": { + "platform": { + "php": "7.1", + "ext-fileinfo": "1.0.5" + } + }, "require": { "slim/slim": "~2.0", "respect/validation": "^1.1",