From 55640ca68957ad38f0a266edde1811ed51026a62 Mon Sep 17 00:00:00 2001 From: LGTM Migrator Date: Tue, 8 Nov 2022 17:27:05 +0000 Subject: [PATCH] ci: add CodeQL workflow for GitHub code scanning - close #18 --- .codesandbox/ci.json | 3 +- .eslintignore | 1 + .github/workflows/ci.yml | 2 +- .github/workflows/codeql.yml | 44 ++++++++++++++++++++++++ .gitignore | 1 + auto-imports.d.ts | 17 --------- package.json | 9 ++--- test/__snapshots__/fixtures.spec.ts.snap | 28 +++++++-------- vitest.config.ts | 1 + 9 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/codeql.yml delete mode 100644 auto-imports.d.ts diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index 4a4206be..f39103e6 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,5 +1,4 @@ { - "node": "16", - "installCommand": "codesandbox:install", + "node": "18", "sandboxes": [] } diff --git a/.eslintignore b/.eslintignore index 8a7b5869..f9f44702 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,6 +2,7 @@ coverage dist lib CHANGELOG.md +/auto-imports.d.ts /pnpm-lock.yaml !/.github !/.*.cjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a4654e9..8ef17711 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: run: pnpm i - name: Build, Lint and Test - run: pnpm run-s build lint test + run: pnpm run-s build lint env: EFF_NO_LINK_RULES: true PARSER_NO_WATCH: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..2c68a20d --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,44 @@ +name: CodeQL + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '18 13 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: + - javascript + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: '/language:${{ matrix.language }}' diff --git a/.gitignore b/.gitignore index 021af0c2..7f4a6076 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ coverage dist lib node_modules +/auto-imports.d.ts diff --git a/auto-imports.d.ts b/auto-imports.d.ts deleted file mode 100644 index d2df67f4..00000000 --- a/auto-imports.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by 'unplugin-auto-import' -export {} -declare global { - const afterAll: typeof import('vitest')['afterAll'] - const afterEach: typeof import('vitest')['afterEach'] - const assert: typeof import('vitest')['assert'] - const beforeAll: typeof import('vitest')['beforeAll'] - const beforeEach: typeof import('vitest')['beforeEach'] - const chai: typeof import('vitest')['chai'] - const describe: typeof import('vitest')['describe'] - const expect: typeof import('vitest')['expect'] - const it: typeof import('vitest')['it'] - const suite: typeof import('vitest')['suite'] - const test: typeof import('vitest')['test'] - const vi: typeof import('vitest')['vi'] - const vitest: typeof import('vitest')['vitest'] -} diff --git a/package.json b/package.json index c17314eb..5c451274 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,9 @@ "xml-sanitizer" ], "scripts": { - "build": "run-p build:*", + "build": "pnpm test && run-p build:*", "build:r": "r -f cjs", "build:tsc": "tsc -p src", - "codesandbox:install": "yarn", "dev": "vitest", "docs:build": "w -e docs -p --publicPath /", "docs:dev": "w -e docs", @@ -42,15 +41,13 @@ "lint:es": "eslint . --cache -f friendly --max-warnings 10", "lint:style": "stylelint . --cache", "lint:tsc": "tsc --noEmit", - "postversion": "pnpm i --no-frozen-lockfile", "prepare": "simple-git-hooks", - "prerelease": "pnpm build", - "release": "changeset publish", + "release": "pnpm build && changeset publish", "serve": "sirv dist -s", "test": "vitest run --coverage", "typecov": "type-coverage", "vercel-build": "pnpm docs:build", - "version": "changeset version" + "version": "changeset version && pnpm i --no-frozen-lockfile" }, "devDependencies": { "@1stg/app-config": "^7.2.1", diff --git a/test/__snapshots__/fixtures.spec.ts.snap b/test/__snapshots__/fixtures.spec.ts.snap index 1c9bf14c..b8c9796c 100644 --- a/test/__snapshots__/fixtures.spec.ts.snap +++ b/test/__snapshots__/fixtures.spec.ts.snap @@ -1,14 +1,14 @@ -// Vitest Snapshot v1 +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`fixtures > html 1`] = ` -" - - - +" + + + Document - + @@ -23,21 +23,21 @@ exports[`fixtures > svg 1`] = ` `; exports[`fixtures > svg 2`] = ` -" - +" + - + 11111 - - + + " `; exports[`fixtures > svg 3`] = ` -" - - +" + + " `; diff --git a/vitest.config.ts b/vitest.config.ts index 8319b96e..fd5f7fa8 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -12,6 +12,7 @@ export default defineConfig({ ], test: { coverage: { + include: ['src'], provider: 'istanbul', reporter: ['lcov', 'json', 'text'], },