config.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. version: 2.1
  2. executors:
  3. firefox:
  4. docker:
  5. - image: circleci/node:6
  6. - image: selenium/standalone-firefox:2.48.2
  7. chrome:
  8. docker:
  9. - image: circleci/node:6
  10. - image: selenium/standalone-chrome:2.48.2
  11. environment:
  12. # workaround for https://github.com/SeleniumHQ/docker-selenium/issues/87
  13. DBUS_SESSION_BUS_ADDRESS: /dev/null
  14. commands:
  15. checkout_repo:
  16. steps:
  17. - checkout
  18. - run:
  19. name: Checkout submodule
  20. command: |
  21. git submodule sync
  22. git submodule update --init --recursive
  23. - run:
  24. name: Get changed files
  25. command: |
  26. if [[ $CIRCLE_PULL_REQUEST ]]; then
  27. BASE_COMMIT=$(curl -s -H "Authorization: token a61ecb2fc5b72da54431""1b3db3875c96854958a8" \
  28. https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER \
  29. | jq -r ".base.sha | select(. != null)")...
  30. else
  31. BASE_COMMIT=HEAD^
  32. fi
  33. if [[ $BASE_COMMIT ]]; then
  34. CHANGED=$(git diff --name-only $BASE_COMMIT)
  35. echo "$CHANGED"
  36. echo "export CHANGED=\"$CHANGED\"" >> $BASH_ENV
  37. fi
  38. skip_if_only_changed:
  39. parameters:
  40. filter:
  41. type: string
  42. steps:
  43. - run:
  44. name: Skip tests if only "<< parameters.filter >>" are changed
  45. command: echo "$CHANGED" | grep -qvE '<< parameters.filter >>' || circleci step halt
  46. install_dependencies:
  47. steps:
  48. - restore_cache:
  49. keys:
  50. - yarn-deps-v3-{{ checksum "yarn.lock" }}
  51. - yarn-deps-v3-
  52. - run:
  53. name: Install dependencies
  54. # upgrade Yarn before installing dependencies, if needed
  55. command: |
  56. if ! yarn check; then
  57. curl -o- -L https://yarnpkg.com/install.sh | PROFILE=$BASH_ENV bash
  58. source $BASH_ENV
  59. yarn
  60. fi
  61. - save_cache:
  62. key: yarn-deps-v3-{{ checksum "yarn.lock" }}
  63. paths:
  64. - node_modules
  65. codecov:
  66. parameters:
  67. flag:
  68. type: string
  69. steps:
  70. - run:
  71. name: Upload code coverage reports to Codecov
  72. # do not upload if screenshotter tests are skipped
  73. command: ./node_modules/.bin/codecov -F "<< parameters.flag >>"
  74. jobs:
  75. test:
  76. docker:
  77. - image: circleci/node:6
  78. steps:
  79. - run:
  80. name: Check whether the build is running on the main repository
  81. command: |
  82. if [[ $CIRCLE_PULL_REQUEST && $CIRCLE_PROJECT_USERNAME != "KaTeX" ]]; then
  83. echo "Please disable CircleCI on your forked repository!"
  84. exit 1
  85. fi
  86. - checkout_repo
  87. - skip_if_only_changed:
  88. filter: '^docs/|^LICENSE|\.md$'
  89. - install_dependencies
  90. - run:
  91. name: Lint code
  92. command: yarn test:lint
  93. - skip_if_only_changed:
  94. filter: '^static/|^website/'
  95. - run:
  96. name: Run Flow and Jest tests
  97. command: |
  98. yarn test:flow
  99. yarn test:jest --coverage
  100. - codecov:
  101. flag: test
  102. screenshotter:
  103. parameters:
  104. browser:
  105. type: executor
  106. executor: << parameters.browser >>
  107. steps:
  108. - checkout_repo
  109. - skip_if_only_changed:
  110. filter: '^docs/|^static/|^website/|^LICENSE|\.md$'
  111. - install_dependencies
  112. - run:
  113. name: Verify screenshots and generate diffs and new screenshots
  114. command: node dockers/screenshotter/screenshotter.js --selenium-ip localhost -b $CIRCLE_JOB --verify --diff --new --coverage
  115. - codecov:
  116. flag: screenshotter
  117. - store_artifacts:
  118. path: test/screenshotter/new
  119. destination: new
  120. - store_artifacts:
  121. path: test/screenshotter/diff
  122. destination: diff
  123. workflows:
  124. test:
  125. jobs:
  126. - test
  127. - screenshotter:
  128. name: firefox
  129. browser: firefox
  130. - screenshotter:
  131. name: chrome
  132. browser: chrome