post_checkout: &post_checkout run: name: Checkout submodule and get changed files command: | git submodule sync git submodule update --init --recursive if [[ $CIRCLE_PULL_REQUEST ]]; then BASE_COMMIT=$(curl -s -H "Authorization: token a61ecb2fc5b72da54431""1b3db3875c96854958a8" \ https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER \ | jq -r ".base.sha | select(. != null)")... else BASE_COMMIT=HEAD^ fi if [[ $BASE_COMMIT ]]; then CHANGED=$(git diff --name-only $BASE_COMMIT) echo "$CHANGED" echo "export CHANGED=\"$CHANGED\"" >> $BASH_ENV fi node_modules_cache_key: &node_modules_cache_key yarn-deps-v1-{{ checksum "yarn.lock" }} restore_node_modules_cache: &restore_node_modules_cache restore_cache: keys: - *node_modules_cache_key - yarn-deps-v1- yarn_install: &yarn_install run: name: Install dependencies command: yarn codecov: &codecov run: name: Upload code coverage reports to Codecov command: ./node_modules/.bin/codecov screenshotter: &screenshotter steps: - checkout - *post_checkout - run: name: Skip screenshotter if no KaTeX code has been changed command: | if [[ $CHANGED ]]; then echo "$CHANGED" | grep -qvE '^contrib/|^docs/|^static/|^website/|^LICENSE|\.md$' || circleci step halt fi - *restore_node_modules_cache - *yarn_install - run: name: Verify screenshots and generate diffs and new screenshots command: node dockers/screenshotter/screenshotter.js --selenium-ip localhost -b $CIRCLE_JOB --verify --diff --new --coverage - *codecov - store_artifacts: path: test/screenshotter/new destination: new - store_artifacts: path: test/screenshotter/diff destination: diff version: 2 jobs: test: docker: - image: circleci/node:6 steps: - run: name: Check whether the build is running on the main repository command: | if [[ $CIRCLE_PULL_REQUEST && $CIRCLE_PROJECT_USERNAME != "Khan" ]]; then echo "Please disable CircleCI on your forked repository!" exit 1 fi - checkout - *post_checkout - run: name: Skip screenshotter if only documentation has been changed command: | if [[ $CHANGED ]]; then echo "$CHANGED" | grep -qvE '^docs/|^LICENSE|\.md$' || circleci step halt fi - *restore_node_modules_cache - *yarn_install - save_cache: key: *node_modules_cache_key paths: - node_modules - add_ssh_keys: fingerprints: - "e1:ac:13:98:98:8b:fd:38:81:12:28:55:75:a1:da:73" - run: name: Greenkeeper - update and commit yarn.lock command: | ./node_modules/.bin/greenkeeper-lockfile-update ./node_modules/.bin/greenkeeper-lockfile-upload - run: name: Run tests command: yarn test --coverage - *codecov - run: name: Build KaTeX command: USE_TTF=false yarn build - store_artifacts: path: dist/katex.min.js destination: katex.min.js - store_artifacts: path: dist/katex.min.css destination: katex.min.css - store_artifacts: path: dist/fonts destination: fonts firefox: docker: - image: circleci/node:6 - image: selenium/standalone-firefox:2.48.2 <<: *screenshotter chrome: docker: - image: circleci/node:6 - image: selenium/standalone-chrome:2.48.2 environment: DBUS_SESSION_BUS_ADDRESS: /dev/null <<: *screenshotter workflows: version: 2 test: jobs: - test - firefox - chrome