|
| 1 | +version: 2 |
| 2 | + |
| 3 | +workflows: |
| 4 | + version: 2 |
| 5 | + |
| 6 | + build-test-deploy: |
| 7 | + jobs: |
| 8 | + - build: |
| 9 | + filters: |
| 10 | + branches: |
| 11 | + ignore: main |
| 12 | + tags: |
| 13 | + only: /.*/ |
| 14 | + - test-unit: |
| 15 | + requires: |
| 16 | + - build |
| 17 | + filters: |
| 18 | + branches: |
| 19 | + ignore: main |
| 20 | + - test-browser: |
| 21 | + requires: |
| 22 | + - build |
| 23 | + filters: |
| 24 | + branches: |
| 25 | + ignore: main |
| 26 | + - deploy-staging: |
| 27 | + requires: |
| 28 | + - build |
| 29 | + filters: |
| 30 | + tags: |
| 31 | + only: /.*/ |
| 32 | + branches: |
| 33 | + ignore: /.*/ |
| 34 | + - deploy-production: |
| 35 | + requires: |
| 36 | + - build |
| 37 | + filters: |
| 38 | + branches: |
| 39 | + only: |
| 40 | + - prod |
| 41 | + |
| 42 | + - tag-version: |
| 43 | + filters: |
| 44 | + branches: |
| 45 | + only: main |
| 46 | + |
| 47 | + |
| 48 | +defaults: &defaults |
| 49 | + working_directory: /home/circleci/mapmarker.io |
| 50 | + docker: |
| 51 | + - image: cimg/php:8.1-browsers |
| 52 | + |
| 53 | +jobs: |
| 54 | + build: |
| 55 | + <<: *defaults |
| 56 | + steps: |
| 57 | + # fetch source & prepare build image |
| 58 | + - checkout |
| 59 | + |
| 60 | + - restore_cache: |
| 61 | + keys: |
| 62 | + # "composer.lock" can be used if it is committed to the repo |
| 63 | + - v1-dependencies-composer-{{ checksum "composer.lock" }} |
| 64 | + # fallback to using the latest cache if no exact match is found |
| 65 | + - v1-dependencies-composer- |
| 66 | + - run: composer install -n --prefer-dist --no-progress --ignore-platform-req=ext-gd |
| 67 | + - save_cache: |
| 68 | + key: v1-dependencies-composer-{{ checksum "composer.lock" }} |
| 69 | + paths: |
| 70 | + - ./vendor |
| 71 | + |
| 72 | + # yarn (with dep caching) |
| 73 | + - restore_cache: |
| 74 | + keys: |
| 75 | + # "composer.lock" can be used if it is committed to the repo |
| 76 | + - v1-dependencies-yarn-{{ checksum "package.json" }} |
| 77 | + # fallback to using the latest cache if no exact match is found |
| 78 | + - v1-dependencies-yarn- |
| 79 | + - run: yarn |
| 80 | + - save_cache: |
| 81 | + key: v1-dependencies-yarn-{{ checksum "package.json" }} |
| 82 | + paths: |
| 83 | + - ./node_modules |
| 84 | + |
| 85 | + # compile js / css |
| 86 | + - run: yarn prod |
| 87 | + |
| 88 | + # save build to workspace for additional steps |
| 89 | + - persist_to_workspace: |
| 90 | + root: /home/circleci |
| 91 | + paths: |
| 92 | + - mapmarker.io |
| 93 | + |
| 94 | + tag-version: |
| 95 | + <<: *defaults |
| 96 | + steps: |
| 97 | + - checkout |
| 98 | + # load contents from build step |
| 99 | + - run: yarn |
| 100 | + - run: |
| 101 | + name: Tag version |
| 102 | + command: yarn release |
| 103 | + |
| 104 | + test-unit: |
| 105 | + <<: *defaults |
| 106 | + steps: |
| 107 | + # load contents from build step |
| 108 | + - attach_workspace: |
| 109 | + at: /home/circleci |
| 110 | + # run tests with phpunit |
| 111 | + - run: |
| 112 | + name: Prepare |
| 113 | + command: | |
| 114 | + mkdir ./test-results |
| 115 | + mkdir ./test-results/junit |
| 116 | + touch database/database.sqlite |
| 117 | + cp .env.circleci .env |
| 118 | + php artisan key:generate |
| 119 | + php artisan migrate |
| 120 | + - run: |
| 121 | + name: Tests |
| 122 | + command: ./vendor/bin/phpunit --log-junit ./test-results/junit/results.xml |
| 123 | + |
| 124 | + - store_test_results: |
| 125 | + path: test-results |
| 126 | + |
| 127 | + test-browser: |
| 128 | + <<: *defaults |
| 129 | + steps: |
| 130 | + # load contents from build step |
| 131 | + - attach_workspace: |
| 132 | + at: /home/circleci |
| 133 | + |
| 134 | + - run: |
| 135 | + name: Setup Chrome |
| 136 | + command: | |
| 137 | + wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb |
| 138 | + sudo apt install ./google-chrome-stable_current_amd64.deb |
| 139 | +
|
| 140 | + - run: |
| 141 | + name: "Prepare" |
| 142 | + command: | |
| 143 | + cp .env.circleci .env |
| 144 | + touch database/database.sqlite |
| 145 | + php artisan key:generate |
| 146 | + php artisan migrate |
| 147 | + php artisan dusk:chrome-driver --detect |
| 148 | +
|
| 149 | + - run: |
| 150 | + name: Start Server |
| 151 | + command: php artisan serve --host=localhost --port=80 |
| 152 | + background: true |
| 153 | + |
| 154 | + - run: |
| 155 | + name: Start Chrome Driver |
| 156 | + command: ./vendor/laravel/dusk/bin/chromedriver-linux |
| 157 | + background: true |
| 158 | + |
| 159 | + - run: |
| 160 | + name: Run Browser Tests |
| 161 | + command: php artisan dusk |
| 162 | + |
| 163 | + - store_artifacts: |
| 164 | + path: /home/circleci/mapmarker.io/tests/Browser/screenshots |
| 165 | + |
| 166 | + deploy-staging: |
| 167 | + <<: *defaults |
| 168 | + steps: |
| 169 | + - attach_workspace: |
| 170 | + at: /home/circleci |
| 171 | + - checkout |
| 172 | + - run: |
| 173 | + name: Deploy Staging |
| 174 | + command: yarn vapor deploy staging --commit $CIRCLE_SHA1 --message "$(git log --format=%B -n 1 $CIRCLE_SHA1)" |
| 175 | + - run: |
| 176 | + name: Notify velocity.codeclimate |
| 177 | + command: bash node_modules/circleci-util/src/notify-deployments.sh -o codeclimate-velocity |
| 178 | + |
| 179 | + deploy-production: |
| 180 | + <<: *defaults |
| 181 | + steps: |
| 182 | + - attach_workspace: |
| 183 | + at: /home/circleci |
| 184 | + - checkout |
| 185 | + - run: |
| 186 | + name: Deploy Production |
| 187 | + command: yarn vapor deploy production --commit $CIRCLE_SHA1 --message "$(git log --format=%B -n 1 $CIRCLE_SHA1)" |
| 188 | + - run: |
| 189 | + name: Notify velocity.codeclimate |
| 190 | + command: bash node_modules/circleci-util/src/notify-deployments.sh -o codeclimate-velocity |
0 commit comments