From a347e6f5352dda3611a0a18bf7accb591f4d0780 Mon Sep 17 00:00:00 2001 From: ishiko732 Date: Mon, 20 Nov 2023 22:19:58 +0800 Subject: [PATCH] chore/add pr-test-action --- .github/workflows/npm-publish.yml | 5 ++- .github/workflows/pr-test.yml | 54 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pr-test.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 161ce92..1f2ae6b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -6,9 +6,8 @@ name: Publish Package to npm.js on: release: types: [published] - push: - branches: - - master + repository_dispatch: + types: [publish-npm] jobs: diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml new file mode 100644 index 0000000..f64cf0c --- /dev/null +++ b/.github/workflows/pr-test.yml @@ -0,0 +1,54 @@ +name: PR Test + +on: + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2.2.2 + with: + version: 8.7.1 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run tests + run: pnpm test + + - name: jest coverage report + uses: ArtiomTr/jest-coverage-report-action@v2.0-rc.6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check test status + id: test-status + run: echo "::set-output name=status::$(if grep -q 'Test failed' test-results.txt; then echo 'failure'; else echo 'success'; fi)" + + merge: + needs: test + runs-on: ubuntu-latest + if: ${{ needs.test.outputs.status == 'success' }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Trigger npm-publish workflow + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ishiko732/ts-fsrs + event-type: publish-npm