js-build-and-lint.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. name: js build and lint
  2. on:
  3. # Only runs webpack on master to save bundle size info into artifacts
  4. # which are then used on PRs to compare against
  5. push:
  6. branches:
  7. - master
  8. pull_request:
  9. jobs:
  10. typescript-and-lint:
  11. name: typescript and lint
  12. runs-on: ubuntu-16.04
  13. steps:
  14. - uses: actions/checkout@v2
  15. - name: Internal github app token
  16. id: token
  17. uses: getsentry/action-github-app-token@v1
  18. continue-on-error: true
  19. with:
  20. app_id: ${{ secrets.SENTRY_INTERNAL_APP_ID }}
  21. private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
  22. - name: Check for frontend file changes
  23. uses: getsentry/paths-filter@v2
  24. id: changes
  25. with:
  26. list-files: shell
  27. token: ${{ github.token }}
  28. filters: .github/file-filters.yml
  29. - uses: volta-cli/action@v1
  30. if: steps.changes.outputs.frontend == 'true'
  31. # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  32. - name: Get yarn cache directory path
  33. id: yarn-cache-dir-path
  34. if: steps.changes.outputs.frontend == 'true'
  35. run: echo "::set-output name=dir::$(yarn cache dir)"
  36. - uses: actions/cache@v2
  37. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  38. if: steps.changes.outputs.frontend == 'true'
  39. with:
  40. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  41. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  42. restore-keys: |
  43. ${{ runner.os }}-yarn-
  44. - name: Install dependencies
  45. if: steps.changes.outputs.frontend == 'true'
  46. run: yarn install --frozen-lockfile
  47. # Setup custom tsc matcher, see https://github.com/actions/setup-node/issues/97
  48. - name: setup matchers
  49. id: matchers
  50. if: steps.changes.outputs.frontend == 'true'
  51. run: |
  52. echo "::remove-matcher owner=masters::"
  53. echo "::add-matcher::.github/tsc.json"
  54. echo "::add-matcher::.github/eslint-stylish.json"
  55. # Lint entire frontend if this is on main branch
  56. - name: eslint
  57. if: github.ref == 'refs/heads/master' && steps.changes.outputs.frontend == 'true'
  58. run: |
  59. # Run relax config on main branch (and stricter config for changed files)
  60. yarn lint -c .eslintrc.relax.js
  61. yarn lint:css
  62. # Otherwise if it's not main branch, only lint modified files
  63. # Note `eslint --fix` will not fail when it auto fixes files
  64. - name: eslint (changed files only)
  65. if: github.ref != 'refs/heads/master' && steps.changes.outputs.frontend == 'true'
  66. run: |
  67. yarn eslint --fix ${{ steps.changes.outputs.frontend_modified_lintable_files }}
  68. # Check (and error) for dirty working tree for forks
  69. # Reason being we need a different token to auto commit changes and
  70. # forks do not have access to said token
  71. - name: Check for dirty git working tree (forks)
  72. if: steps.token.outcome != 'success' && github.ref != 'refs/heads/master' && steps.changes.outputs.frontend == 'true'
  73. run: |
  74. git diff --quiet || (echo '::error ::lint produced file changes, run linter locally and try again' && exit 1)
  75. # If working tree is dirty, commit and update if we have a token
  76. - name: Commit any eslint fixed files
  77. if: steps.token.outcome == 'success' && github.ref != 'refs/heads/master' && steps.changes.outputs.frontend == 'true'
  78. uses: getsentry/action-github-commit@main
  79. with:
  80. github-token: ${{ steps.token.outputs.token }}
  81. - name: tsc
  82. if: always() && steps.changes.outputs.frontend == 'true'
  83. run: |
  84. yarn tsc -p config/tsconfig.build.json
  85. - name: storybook
  86. if: github.ref != 'refs/heads/master' && steps.changes.outputs.frontend == 'true'
  87. env:
  88. STORYBOOK_BUILD: 1
  89. run: |
  90. yarn storybook-build
  91. webpack:
  92. runs-on: ubuntu-16.04
  93. steps:
  94. - uses: actions/checkout@v2
  95. - name: Check for frontend file changes
  96. uses: getsentry/paths-filter@v2
  97. id: changes
  98. with:
  99. token: ${{ github.token }}
  100. filters: .github/file-filters.yml
  101. - uses: volta-cli/action@v1
  102. if: github.ref == 'refs/heads/master' || steps.changes.outputs.frontend == 'true'
  103. # See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
  104. - name: Get yarn cache directory path
  105. id: yarn-cache-dir-path
  106. if: github.ref == 'refs/heads/master' || steps.changes.outputs.frontend == 'true'
  107. run: echo "::set-output name=dir::$(yarn cache dir)"
  108. - uses: actions/cache@v2
  109. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  110. if: github.ref == 'refs/heads/master' || steps.changes.outputs.frontend == 'true'
  111. with:
  112. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  113. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  114. restore-keys: |
  115. ${{ runner.os }}-yarn-
  116. - name: Install dependencies
  117. if: github.ref == 'refs/heads/master' || steps.changes.outputs.frontend == 'true'
  118. run: yarn install --frozen-lockfile
  119. - uses: getsentry/size-limit-action@v3
  120. if: github.ref == 'refs/heads/master' || steps.changes.outputs.frontend == 'true'
  121. env:
  122. SENTRY_INSTRUMENTATION: 1
  123. SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
  124. with:
  125. main_branch: master
  126. workflow_name: 'js-build-and-lint'
  127. skip_step: install
  128. build_script: build
  129. windows_verbatim_arguments: false
  130. github_token: ${{ secrets.GITHUB_TOKEN }}