WIP: split filtering and ordering #134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: TypeScript Checks | |
on: | |
workflow_call: | |
pull_request: | |
types: [opened, synchronize] | |
branches-ignore: [staging, production] | |
paths: ['**.js', '**.ts', '**.tsx', 'package.json', 'package-lock.json', 'tsconfig.json'] | |
concurrency: | |
group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-typecheck | |
cancel-in-progress: true | |
jobs: | |
typecheck: | |
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/composite/setupNode | |
- name: Type check with TypeScript | |
run: npm run typecheck | |
env: | |
CI: true | |
- name: Check for new JavaScript files | |
run: | | |
git fetch origin main --no-tags --depth=1 | |
# Explanation: | |
# - comm is used to get the intersection between two bash arrays | |
# - git diff is used to see the files that were added on this branch | |
# - gh pr view is used to list files touched by this PR. Git diff may give false positives if the branch isn't up-to-date with main | |
# - wc counts the words in the result of the intersection | |
count_new_js=$(comm -1 -2 <(git diff --name-only --diff-filter=A origin/main HEAD -- 'src/*.js' '__mocks__/*.js' '.storybook/*.js' 'assets/*.js' 'config/*.js' 'desktop/*.js' 'jest/*.js' 'scripts/*.js' 'tests/*.js' '.github/libs/*.js' '.github/scripts/*.js' ':!src/libs/SearchParser/*.js') <(gh pr view ${{ github.event.pull_request.number }} --json files | jq -r '.files | map(.path) | .[]') | wc -l) | |
if [ "$count_new_js" -gt "0" ]; then | |
echo "ERROR: Found new JavaScript files in the project; use TypeScript instead." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ github.token }} |