From 09dddb5a4d034e7d42a854e010fe600b638c4e9e Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Thu, 27 May 2021 15:53:58 +0200 Subject: [PATCH] test: add coverage, deploy to pages --- .changeset/tough-ties-guess.md | 5 ++++ .github/workflows/gh-pages.yml | 46 ++++++++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 2 ++ jest.config.js | 5 ++-- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 .changeset/tough-ties-guess.md create mode 100644 .github/workflows/gh-pages.yml diff --git a/.changeset/tough-ties-guess.md b/.changeset/tough-ties-guess.md new file mode 100644 index 00000000000..df486b83e61 --- /dev/null +++ b/.changeset/tough-ties-guess.md @@ -0,0 +1,5 @@ +--- +'@stacks/wallet-web': patch +--- + +Adds code coverage and deploys to Github Pages https://blockstack.github.io/stacks-wallet-web/ diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 00000000000..f9aff0495ba --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,46 @@ +name: GH pages + +on: + push: + branches: + - 'main' + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Cache node_modules + id: cache + uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + ${{ runner.os }}-yarn + + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: yarn + + - name: Build prod + run: yarn build + + - name: Run jest + run: yarn test:unit + + - name: Make badge maker + run: npx make-coverage-badge + + - name: Publish test coverage report + uses: JamesIves/github-pages-deploy-action@4.0.0 + with: + branch: gh-pages + folder: coverage diff --git a/.gitignore b/.gitignore index ef5e9c83510..4c1a8d4182c 100755 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ packages web-ext-artifacts/ .yalc/ yalc.lock +coverage/ diff --git a/README.md b/README.md index c7997c20580..c566beadc62 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Stacks Wallet for web +[![coverage](https://raw.githubusercontent.com/blockstack/stacks-wallet-web/gh-pages/badge.svg)](https://blockstack.github.io/stacks-wallet-web/) + Stacks Wallet is a browser extension for managing your digital assets and connecting to apps built with the Stacks blockchain. Source code is available on GitHub at https://github.com/blockstack/stacks-wallet-web/tree/main diff --git a/jest.config.js b/jest.config.js index 45f3bf5e411..605ee096764 100755 --- a/jest.config.js +++ b/jest.config.js @@ -35,8 +35,9 @@ module.exports = { // Automatically clear mock calls and instances between every test // clearMocks: false, - // Indicates whether the coverage information should be collected while executing the test - // collectCoverage: false, + collectCoverage: true, + + coverageReporters: ['html', 'json-summary'], // An array of glob patterns indicating a set of files for which coverage information should be collected collectCoverageFrom: ['src/**/*.{ts,tsx}'],