diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 997e44a..2206332 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,45 +2,29 @@ name: Deploy on: push: branches: - - ci-test - master - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: true - default: 'warning' jobs: deploy: - name: deploy runs-on: ubuntu-latest steps: - - name: checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + - name: "Install Node" + uses: actions/setup-node@v4 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + node-version: "20" + cache: "yarn" - - name: setup - run: yarn + - name: "Setup" + run: yarn install - - name: test + - name: "Test" run: yarn test - - name: deploy + - name: "Deploy" env: CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} run: | yarn deploy - diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..c6d7cbf --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,61 @@ +name: PR tests +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + branch: + - ${{ github.head_ref }} + - "master" + + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + + - name: "Install Node" + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "yarn" + + - name: "Install Deps" + run: yarn install + + - name: "Test" + run: yarn coverage + + - name: "Upload Coverage" + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.branch }} + path: coverage + + report-coverage: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: "Download HEAD coverage artifacts" + uses: actions/download-artifact@v4 + with: + name: coverage-${{ github.head_ref }} + path: coverage + + - name: "Download master coverage artifacts" + uses: actions/download-artifact@v4 + with: + name: coverage-master + path: coverage-master + + - name: "Report Coverage" + uses: davelosert/vitest-coverage-report-action@v2 + with: + json-summary-compare-path: coverage-master/coverage-summary.json