Skip to content

Commit

Permalink
Integration test (#11)
Browse files Browse the repository at this point in the history
* Integration test draft.

* CI job.

* Format.

* Install in the test.

* Universal approach for manifest import.

* Only use Node for the test.
  • Loading branch information
Anna Bocharova authored Aug 8, 2024
1 parent 333beb6 commit 6616df4
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,48 @@ jobs:
continue-on-error: true
with:
github-token: ${{ secrets.github_token }}

integrationTest:
needs: unitTest
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 18.18.0
- 18.x
- 20.9.0
- 20.x
- 22.0.0
- 22.x
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Get bun cache dir and hash
id: bunCache
run: |
echo "dir=$(bun pm cache)" >> $GITHUB_OUTPUT
echo "hash=$(bun pm hash)" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v4
with:
path: ${{ steps.bunCache.outputs.dir }}
key: ${{ runner.os }}-build-cache-bun-${{ steps.bunCache.outputs.hash }}
- name: Install dependencies
run: bun install
- name: Build
run: bun run build
- name: Install Node.js ${{ matrix.node-version }}
id: setup-node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install the test dependencies
working-directory: integration-test
run: yarn
- name: Test
working-directory: integration-test
run: yarn eslint sample.ts --debug
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
.DS_Store
node_modules
coverage
integration-test/yarn.lock
27 changes: 27 additions & 0 deletions integration-test/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { readFileSync } from "node:fs";
import jsPlugin from "@eslint/js";
import allowedDepsPlugin from "eslint-plugin-allowed-dependencies";
import tsPlugin from "typescript-eslint";

export default [
{
plugins: {
allowed: allowedDepsPlugin,
},
},
jsPlugin.configs.recommended,
...tsPlugin.configs.recommended,
// For the sources:
{
files: ["*.ts"], // implies that "src" only contains the sources
rules: {
"allowed/dependencies": [
"error",
{
manifest: JSON.parse(readFileSync("package.json", "utf8")),
typeOnly: ["typescript"],
},
],
},
},
];
12 changes: 12 additions & 0 deletions integration-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "integration-test",
"private": true,
"version": "0.0.1",
"type": "module",
"devDependencies": {
"eslint": "^9",
"typescript-eslint": "^8",
"typescript": "^5",
"eslint-plugin-allowed-dependencies": "link:.."
}
}
3 changes: 3 additions & 0 deletions integration-test/sample.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { factory } from "typescript";

export type Test = typeof factory;

0 comments on commit 6616df4

Please sign in to comment.