Skip to content

Commit 3a7ada3

Browse files
🤖 config(ci): Allow to test build with AVA.
These changes were automatically generated by a transform whose code can be found at: - https://github.com/make-github-pseudonymous-again/rejuvenate/blob/b27ce6d333a4c46ff5161eaddfbe16895bbabf0f/src/transforms/ava:test-build.js Please contact the author of the transform if you believe there was an error.
1 parent 7cb1faa commit 3a7ada3

12 files changed

+107
-27
lines changed

.github/workflows/ci.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: ci
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
9+
build:
10+
name: Continuous integration (build)
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout 🛎️
14+
uses: actions/checkout@v4
15+
16+
- name: Install 📦
17+
uses: bahmutov/npm-install@v1
18+
with:
19+
install-command: yarn --frozen-lockfile --ignore-scripts
20+
useRollingCache: true
21+
22+
- name: Build 🏗️
23+
run: yarn build
24+
25+
- name: Archive build 💽
26+
uses: actions/upload-artifact@v3
27+
with:
28+
name: dist
29+
path: dist
30+
retention-days: 1
31+
32+
test:
33+
needs: ["build"]
34+
name: Continuous integration (tests)
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
bundle: ["modern", "module", "cjs"]
39+
steps:
40+
- name: Checkout 🛎️
41+
uses: actions/checkout@v4
42+
43+
- name: Install 📦
44+
uses: bahmutov/npm-install@v1
45+
with:
46+
install-command: yarn --frozen-lockfile --ignore-scripts
47+
useRollingCache: true
48+
49+
- name: Load build 💽
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: dist
53+
path: dist
54+
55+
- name: Test 🔬
56+
run: yarn test:${{ matrix.bundle }}

.github/workflows/ci:build.yml

-20
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ knapsackApprox(eps, n, v, w, W); // 1-eps approximation
2323

2424
[![License](https://img.shields.io/github/license/computational-problem-solving/knapsack.svg)](https://raw.githubusercontent.com/computational-problem-solving/knapsack/main/LICENSE)
2525
[![Version](https://img.shields.io/npm/v/@problem-solving/knapsack.svg)](https://www.npmjs.org/package/@problem-solving/knapsack)
26-
[![Tests](https://img.shields.io/github/workflow/status/computational-problem-solving/knapsack/ci:cover?event=push&label=tests)](https://github.com/computational-problem-solving/knapsack/actions/workflows/ci:cover.yml?query=branch:main)
26+
[![Tests](https://img.shields.io/github/workflow/status/computational-problem-solving/knapsack/ci?event=push&label=tests)](https://github.com/computational-problem-solving/knapsack/actions/workflows/ci.yml?query=branch:main)
2727
[![Dependencies](https://img.shields.io/librariesio/github/computational-problem-solving/knapsack.svg)](https://github.com/computational-problem-solving/knapsack/network/dependencies)
2828
[![GitHub issues](https://img.shields.io/github/issues/computational-problem-solving/knapsack.svg)](https://github.com/computational-problem-solving/knapsack/issues)
2929
[![Downloads](https://img.shields.io/npm/dm/@problem-solving/knapsack.svg)](https://www.npmjs.org/package/@problem-solving/knapsack)

package.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
"build": "NODE_ENV=production microbundle",
5858
"build-docs": "esdoc",
5959
"build-gh-pages": "npm run build-docs",
60-
"ci:build": "npm run build",
61-
"ci:test": "npm run lint-config && npm run lint && npm run cover",
6260
"commit-msg": "commitlint --edit",
6361
"cover": "NODE_ENV=cover c8 --all --src src --reporter lcov --reporter text-summary --reporter text npm test",
6462
"debug": "NODE_ENV=debug npm run test -- -st --fail-fast",
@@ -74,7 +72,13 @@
7472
"prepare": "npm run build",
7573
"prepublishOnly": "pinst --disable",
7674
"release": "np --message ':hatching_chick: release: Bumping to v%s.'",
77-
"test": "ava"
75+
"test": "npm run test:src",
76+
"test-cmd": "NODE_LOADER_CONFIG=test/loader/config.js ava",
77+
"test:cjs": "IMPORT_MAP_PATH=test/import-maps/dist/index.json npm run test-cmd",
78+
"test:dist": "npm run test:modern && npm run test:module && npm run test:cjs",
79+
"test:modern": "IMPORT_MAP_PATH=test/import-maps/dist/index.modern.json npm run test-cmd",
80+
"test:module": "IMPORT_MAP_PATH=test/import-maps/dist/index.module.json npm run test-cmd",
81+
"test:src": "IMPORT_MAP_PATH=test/import-maps/src/index.json npm run test-cmd"
7882
},
7983
"dependencies": {
8084
"@iterable-iterator/filter": "^1.0.1",
@@ -91,6 +95,8 @@
9195
"@commitlint/cli": "19.0.3",
9296
"@js-library/commitlint-config": "0.0.4",
9397
"@node-loader/babel": "2.0.1",
98+
"@node-loader/core": "2.0.0",
99+
"@node-loader/import-maps": "1.1.0",
94100
"ava": "6.1.2",
95101
"babel-plugin-transform-remove-console": "6.9.4",
96102
"babel-plugin-unassert": "3.2.0",
@@ -116,7 +122,7 @@
116122
"test/src/**/*"
117123
],
118124
"nodeArguments": [
119-
"--experimental-loader=@node-loader/babel"
125+
"--experimental-loader=@node-loader/core"
120126
],
121127
"require": [
122128
"regenerator-runtime/runtime.js"

test/import-maps/dist/index.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.cjs"
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.modern.js"
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.module.js"
4+
}
5+
}

test/import-maps/src/index.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./src/index.js"
4+
}
5+
}

test/loader/config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as babelLoader from '@node-loader/babel';
2+
import * as importMapLoader from '@node-loader/import-maps';
3+
4+
const config = {
5+
loaders: [importMapLoader, babelLoader],
6+
};
7+
8+
export default config;

test/src/0-1-knapsack-problem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
integerWeightsKnapsack,
99
knapsackGreedy,
1010
knapsackApprox,
11-
} from '../../src/index.js';
11+
} from '#module';
1212

1313
const macro = (t, solve, _name, v, w, n, W, opt, approx) => {
1414
t.is(n, v.length);

test/src/unbounded-knapsack-problem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
integerValuesKnapsackUnbounded,
88
integerWeightsKnapsackUnbounded,
99
knapsackUnboundedGreedy,
10-
} from '../../src/index.js';
10+
} from '#module';
1111

1212
const macro = (t, solve, _name, v, w, n, W, opt, approx) => {
1313
t.is(n, v.length);

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -2445,6 +2445,16 @@
24452445
resolved "https://registry.yarnpkg.com/@node-loader/babel/-/babel-2.0.1.tgz#a04d7535b5ade12e3987de04fc5ffe204f26c64c"
24462446
integrity sha512-lulESaNn+jyn4lCbfcFWFcRYchsL0jY8q/mf5XRKOiX2uTpkXE3fGAlZ4+wyP/hIAMSlDPuHIUkRSTkJZ6SQyA==
24472447

2448+
"@node-loader/[email protected]":
2449+
version "2.0.0"
2450+
resolved "https://registry.yarnpkg.com/@node-loader/core/-/core-2.0.0.tgz#7f5a3a91fe137c8e71c0813f3bbaa0ee136a1308"
2451+
integrity sha512-7wV4qj2/tROXGgoYWmNvObUXbXqSv1yUD31K79Jt1q7NDuqrLz4WjjW+wVoCNgVcl8+YSj9BvLX8KsB/SrSzuw==
2452+
2453+
"@node-loader/[email protected]":
2454+
version "1.1.0"
2455+
resolved "https://registry.yarnpkg.com/@node-loader/import-maps/-/import-maps-1.1.0.tgz#4785fdce3bc973c5b53a4549248ab42b370ecda9"
2456+
integrity sha512-RPB+7vBVhk9xF/eiSGSxEnL6hGQ0a1ua9hvl/MxXDmu7F+Nv+gMwA7AJ0S5TmcgulHAp9/IxobGoFiOxkX7xWQ==
2457+
24482458
"@nodelib/[email protected]":
24492459
version "2.1.5"
24502460
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"

0 commit comments

Comments
 (0)