feat: run changed testsuites in PR ci #655
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
ci: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- run: corepack enable | |
- run: pnpm --version | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
cache-dependency-path: "**/pnpm-lock.yaml" | |
- name: install | |
run: pnpm install --frozen-lockfile --prefer-offline | |
# - name: format | |
# run: pnpm format | |
# - name: lint | |
# run: pnpm run lint | |
# - name: audit | |
# if: (${{ success() }} || ${{ failure() }}) | |
# run: pnpm audit | |
# - name: test self | |
# if: (${{ success() }} || ${{ failure() }}) | |
# run: pnpm test:self | |
- name: test changed suites | |
if: (${{ github.event.number }} != null ) | |
env: | |
GH_TOKEN: ${{ github.token }} | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
GH_DIFF=$(gh pr diff $PR_NUMBER --name-only --color never) | |
echo $GH_DIFF | |
CHANGED_SUITES=$(echo $GH_DIFF | grep -o '^tests/[^_].*\.ts' | xargs -d '\n' ls -1df 2>/dev/null |cut -d '/' -f 2 | cut -d '.' -f 1 | xargs -rd '\n') | |
if [ -n "$CHANGED_SUITES" ]; then | |
pnpm tsx ecosystem-ci.ts $CHANGED_SUITES | |
fi |