Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run changed testsuites in PR ci #237

Closed
wants to merge 15 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
branches:
- main

# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
ci:
timeout-minutes: 10
Expand All @@ -33,6 +38,55 @@ jobs:
- name: audit
if: (${{ success() }} || ${{ failure() }})
run: pnpm audit
- name: test
- name: test self
if: (${{ success() }} || ${{ failure() }})
run: pnpm test:self

find_changed_testfiles:
if: (${{ github.event.number }})
runs-on: ubuntu-latest
outputs:
changed: ${{steps.list.outputs.changed_suites}}
steps:
- uses: actions/checkout@v3
- id: list
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.number }}
run: |
echo "changed_suites=$(\
gh pr diff $PR_NUMBER --name-only --color never \
| grep '^tests/[^_].*\.ts' \
| xargs -d '\n' ls -1df 2>/dev/null \
| cut -d '/' -f 2 | cut -d '.' -f 1 \
| jq -cnR '[inputs]' \
)" >> $GITHUB_OUTPUT

run_changed_tests:
if: (${{ github.event.number }} && ${{needs.find_changed_testfiles.outputs.changed}} )
runs-on: ubuntu-latest
needs: [ci, find_changed_testfiles]
timeout-minutes: 30
strategy:
matrix:
suite: ${{fromJson(needs.find_changed_testfiles.outputs.changed)}}
fail-fast: false
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"
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
id: setup-deno
continue-on-error: true
- run: pnpm i --frozen-lockfile
- run: pnpm tsx ecosystem-ci.ts ${{ matrix.suite }}
Loading