From 0f96a76da2eb0b0cd804717a6fe12d01c4414881 Mon Sep 17 00:00:00 2001 From: Svyat Sobol Date: Sat, 1 Aug 2020 21:10:57 +0300 Subject: [PATCH] chore: Add codecov to ci --- .github/workflows/ci.yml | 13 +++++++++++-- .gitignore | 1 + .vscodeignore | 1 + README.md | 1 + package.json | 6 +++++- src/test/testRunner.ts | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caedc7f6..974a798e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,8 @@ jobs: matrix: os: [macos-10.15, ubuntu-18.04, windows-2019] runs-on: ${{ matrix.os }} + env: + OS: ${{ matrix.os }} steps: - uses: actions/checkout@v1 - name: Setup Node @@ -46,7 +48,14 @@ jobs: - name: Run Tests uses: GabrielBB/xvfb-action@v1.0 with: - run: yarn test + run: yarn test:ci + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/ + env_vars: OS + fail_ci_if_error: true create_release: name: Create Release if: success() && startsWith(github.ref, 'refs/tags/v') @@ -67,7 +76,7 @@ jobs: files: | markdown-memo-*.vsix publish: - name: Publish + name: Publish Release runs-on: ubuntu-18.04 needs: [create_release] steps: diff --git a/.gitignore b/.gitignore index d3e19a9c..42dd078b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules *.vsix yarn-error.log VERSION +coverage/ diff --git a/.vscodeignore b/.vscodeignore index b0e8574e..99f13d92 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -19,3 +19,4 @@ yarn-error.log **/*.ts node_modules VERSION +coverage/ diff --git a/README.md b/README.md index adffdbaa..fe3cb315 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Inspired by [Obsidian.md](https://obsidian.md/) and [RoamResearch](https://roamr [![](https://vsmarketplacebadge.apphb.com/version-short/svsool.markdown-memo.svg)](https://marketplace.visualstudio.com/items?itemName=svsool.markdown-memo) [![](https://github.com/svsool/vscode-memo/workflows/CI/badge.svg?branch=master)](https://github.com/svsool/vscode-memo/actions?query=workflow%3ACI+branch%3Amaster) +[![codecov](https://codecov.io/gh/svsool/vscode-memo/branch/master/graph/badge.svg)](https://codecov.io/gh/svsool/vscode-memo) ## Why? diff --git a/package.json b/package.json index c49d63c9..2f9ea0e0 100644 --- a/package.json +++ b/package.json @@ -133,11 +133,15 @@ "clean": "rimraf dist out", "lint": "eslint src --ext ts", "compile": "webpack --mode development", + "compile:tests": "tsc -p ./ && yarn run webpack --mode development", "watch": "webpack --mode development -w", - "pretest": "tsc -p ./ && yarn run webpack --mode development", + "pretest": "yarn compile:tests", + "pretest:ci": "yarn compile:tests", + "pretest:watch": "yarn compile:tests", "release": "standard-version", "ts": "tsc --noEmit", "test": "node ./out/test/runTest.js", + "test:ci": "cross-env JEST_COLLECT_COVERAGE=true node ./out/test/runTest.js", "test:watch": "cross-env JEST_WATCH=true node ./out/test/runTest.js" }, "devDependencies": { diff --git a/src/test/testRunner.ts b/src/test/testRunner.ts index e58b6582..46ded77a 100644 --- a/src/test/testRunner.ts +++ b/src/test/testRunner.ts @@ -42,6 +42,7 @@ export function run(): Promise { }, }), watch: process.env.JEST_WATCH === 'true', + collectCoverage: process.env.JEST_COLLECT_COVERAGE === 'true', }, [rootDir], );