From 4a5495ef568488977e4593e9b5b6a07f98ce046c 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/pr-test.yml | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/pr-test.yml diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml new file mode 100644 index 0000000..15bd70c --- /dev/null +++ b/.github/workflows/pr-test.yml @@ -0,0 +1,43 @@ +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 + + - 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