diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c50e7cf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: ci + +on: + - push + - pull_request + +jobs: + + build: + name: Continuous integration (build) + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + - name: Install 📦 + uses: bahmutov/npm-install@v1 + with: + install-command: yarn --frozen-lockfile --ignore-scripts + useRollingCache: true + + - name: Build 🏗️ + run: yarn build + + - name: Archive build 💽 + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + retention-days: 1 + + test: + needs: ["build"] + name: Continuous integration (tests) + runs-on: ubuntu-latest + strategy: + matrix: + bundle: ["modern", "module", "cjs"] + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + - name: Install 📦 + uses: bahmutov/npm-install@v1 + with: + install-command: yarn --frozen-lockfile --ignore-scripts + useRollingCache: true + + - name: Load build 💽 + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + + - name: Test 🔬 + run: yarn test:${{ matrix.bundle }} diff --git a/.github/workflows/ci:test.yml b/.github/workflows/ci:cover.yml similarity index 71% rename from .github/workflows/ci:test.yml rename to .github/workflows/ci:cover.yml index 03f7739..8364e23 100644 --- a/.github/workflows/ci:test.yml +++ b/.github/workflows/ci:cover.yml @@ -1,23 +1,23 @@ -name: ci:test +name: ci:cover on: - push - pull_request jobs: - test: - name: Continuous integration (tests) + cover: + name: Continuous integration (code coverage) runs-on: ubuntu-latest steps: - name: Checkout 🛎️ uses: actions/checkout@v3 - - name: Install 🔧 + - name: Install 📦 uses: bahmutov/npm-install@v1 with: install-command: yarn --frozen-lockfile --ignore-scripts useRollingCache: true - - name: Test 🔬 - run: yarn ci:test + - name: Test and record coverage 🔬 + run: yarn cover - name: Publish coverage report 📃 uses: codecov/codecov-action@v2 diff --git a/.github/workflows/ci:lint-config.yml b/.github/workflows/ci:lint-config.yml new file mode 100644 index 0000000..bdd3853 --- /dev/null +++ b/.github/workflows/ci:lint-config.yml @@ -0,0 +1,20 @@ +name: ci:lint-config +on: + - push + - pull_request +jobs: + cover: + name: Continuous integration (config linting) + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + - name: Install 📦 + uses: bahmutov/npm-install@v1 + with: + install-command: yarn --frozen-lockfile --ignore-scripts + useRollingCache: true + + - name: Lint config 👕 + run: yarn lint-config diff --git a/.github/workflows/ci:build.yml b/.github/workflows/ci:lint.yml similarity index 66% rename from .github/workflows/ci:build.yml rename to .github/workflows/ci:lint.yml index ee3a57c..7e0551c 100644 --- a/.github/workflows/ci:build.yml +++ b/.github/workflows/ci:lint.yml @@ -1,20 +1,20 @@ -name: ci:build +name: ci:lint on: - push - pull_request jobs: - test: - name: Continuous integration (build) + cover: + name: Continuous integration (code linting) runs-on: ubuntu-latest steps: - name: Checkout 🛎️ uses: actions/checkout@v3 - - name: Install 🔧 + - name: Install 📦 uses: bahmutov/npm-install@v1 with: install-command: yarn --frozen-lockfile --ignore-scripts useRollingCache: true - - name: Build 🏗️ - run: yarn ci:build + - name: Lint 👕 + run: yarn lint diff --git a/README.md b/README.md index b1be547..9afd511 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ U.find( a ) === U.find( b ) ; // true [![License](https://img.shields.io/github/license/union-find/contiguous.svg)](https://raw.githubusercontent.com/union-find/contiguous/main/LICENSE) [![Version](https://img.shields.io/npm/v/@union-find/contiguous.svg)](https://www.npmjs.org/package/@union-find/contiguous) -[![Tests](https://img.shields.io/github/workflow/status/union-find/contiguous/ci:test?event=push&label=tests)](https://github.com/union-find/contiguous/actions/workflows/ci:test.yml?query=branch:main) +[![Tests](https://img.shields.io/github/workflow/status/union-find/contiguous/ci?event=push&label=tests)](https://github.com/union-find/contiguous/actions/workflows/ci.yml?query=branch:main) [![Dependencies](https://img.shields.io/librariesio/github/union-find/contiguous.svg)](https://github.com/union-find/contiguous/network/dependencies) [![GitHub issues](https://img.shields.io/github/issues/union-find/contiguous.svg)](https://github.com/union-find/contiguous/issues) [![Downloads](https://img.shields.io/npm/dm/@union-find/contiguous.svg)](https://www.npmjs.org/package/@union-find/contiguous) diff --git a/package.json b/package.json index 516910f..bc44892 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,6 @@ "build": "NODE_ENV=production microbundle", "build-docs": "esdoc", "build-gh-pages": "npm run build-docs", - "ci:build": "npm run build", - "ci:test": "npm run lint-config && npm run lint && npm run cover", "commit-msg": "commitlint --edit", "cover": "NODE_ENV=cover c8 --all --src src --reporter lcov --reporter text-summary --reporter text npm test", "debug": "NODE_ENV=debug npm run test -- -st --fail-fast", @@ -67,7 +65,13 @@ "prepare": "npm run build", "prepublishOnly": "pinst --disable", "release": "np --message ':hatching_chick: release: Bumping to v%s.'", - "test": "ava" + "test": "npm run test:src", + "test-cmd": "NODE_LOADER_CONFIG=test/loader/config.js ava", + "test:cjs": "IMPORT_MAP_PATH=test/import-maps/dist/index.json npm run test-cmd", + "test:dist": "npm run test:modern && npm run test:module && npm run test:cjs", + "test:modern": "IMPORT_MAP_PATH=test/import-maps/dist/index.modern.json npm run test-cmd", + "test:module": "IMPORT_MAP_PATH=test/import-maps/dist/index.module.json npm run test-cmd", + "test:src": "IMPORT_MAP_PATH=test/import-maps/src/index.json npm run test-cmd" }, "dependencies": {}, "devDependencies": { @@ -77,6 +81,8 @@ "@commitlint/cli": "17.1.2", "@js-library/commitlint-config": "0.0.4", "@node-loader/babel": "2.0.1", + "@node-loader/core": "2.0.0", + "@node-loader/import-maps": "1.1.0", "ava": "4.3.3", "babel-plugin-transform-remove-console": "6.9.4", "babel-plugin-unassert": "3.2.0", @@ -100,14 +106,14 @@ "files": [ "test/src/**/*" ], - "nodeArguments": [ - "--experimental-loader=@node-loader/babel" - ], "require": [ "regenerator-runtime/runtime" ], "timeout": "1m", - "concurrency": 8 + "concurrency": 8, + "nodeArguments": [ + "--experimental-loader=@node-loader/core" + ] }, "babel": { "sourceMaps": true, diff --git a/test/import-maps/dist/index.json b/test/import-maps/dist/index.json new file mode 100644 index 0000000..7059eb6 --- /dev/null +++ b/test/import-maps/dist/index.json @@ -0,0 +1,5 @@ +{ + "imports": { + "#module": "./dist/index.cjs" + } +} diff --git a/test/import-maps/dist/index.modern.json b/test/import-maps/dist/index.modern.json new file mode 100644 index 0000000..8eafb2e --- /dev/null +++ b/test/import-maps/dist/index.modern.json @@ -0,0 +1,5 @@ +{ + "imports": { + "#module": "./dist/index.modern.js" + } +} diff --git a/test/import-maps/dist/index.module.json b/test/import-maps/dist/index.module.json new file mode 100644 index 0000000..74c8d44 --- /dev/null +++ b/test/import-maps/dist/index.module.json @@ -0,0 +1,5 @@ +{ + "imports": { + "#module": "./dist/index.module.js" + } +} diff --git a/test/import-maps/src/index.json b/test/import-maps/src/index.json new file mode 100644 index 0000000..6b576f1 --- /dev/null +++ b/test/import-maps/src/index.json @@ -0,0 +1,5 @@ +{ + "imports": { + "#module": "./src/index.js" + } +} diff --git a/test/loader/config.js b/test/loader/config.js new file mode 100644 index 0000000..e08c360 --- /dev/null +++ b/test/loader/config.js @@ -0,0 +1,8 @@ +import * as importMapLoader from '@node-loader/import-maps'; +import * as babelLoader from '@node-loader/babel'; + +const config = { + loaders: [importMapLoader, babelLoader], +}; + +export default config; diff --git a/test/src/disjointset.js b/test/src/disjointset.js index 7833a2c..b3de332 100644 --- a/test/src/disjointset.js +++ b/test/src/disjointset.js @@ -9,7 +9,7 @@ import { ForestAmortizedTwoPasses, ForestAmortizedSplitting, ForestAmortizedHalving, -} from '../../src/index.js'; +} from '#module'; function macro(t, Universe) { /* eslint-disable no-multi-assign */ diff --git a/yarn.lock b/yarn.lock index 727e616..b0d4b34 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1264,6 +1264,16 @@ resolved "https://registry.yarnpkg.com/@node-loader/babel/-/babel-2.0.1.tgz#a04d7535b5ade12e3987de04fc5ffe204f26c64c" integrity sha512-lulESaNn+jyn4lCbfcFWFcRYchsL0jY8q/mf5XRKOiX2uTpkXE3fGAlZ4+wyP/hIAMSlDPuHIUkRSTkJZ6SQyA== +"@node-loader/core@2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@node-loader/core/-/core-2.0.0.tgz#7f5a3a91fe137c8e71c0813f3bbaa0ee136a1308" + integrity sha512-7wV4qj2/tROXGgoYWmNvObUXbXqSv1yUD31K79Jt1q7NDuqrLz4WjjW+wVoCNgVcl8+YSj9BvLX8KsB/SrSzuw== + +"@node-loader/import-maps@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@node-loader/import-maps/-/import-maps-1.1.0.tgz#4785fdce3bc973c5b53a4549248ab42b370ecda9" + integrity sha512-RPB+7vBVhk9xF/eiSGSxEnL6hGQ0a1ua9hvl/MxXDmu7F+Nv+gMwA7AJ0S5TmcgulHAp9/IxobGoFiOxkX7xWQ== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"