Skip to content

Commit

Permalink
🤖 test: Allow to test build with AVA.
Browse files Browse the repository at this point in the history
These changes were automatically generated by a transform whose code can be found at:
  - https://github.com/make-github-pseudonymous-again/rejuvenate/blob/7a92df9c28303ed9cd6ee1a5e4999acfc8c52497/src/transforms/ava:test-build.js
Please contact the author of the transform if you believe there was an error.
  • Loading branch information
a-flying-potato authored and make-github-pseudonymous-again committed Oct 12, 2022
1 parent cda52a7 commit b11aa0a
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 20 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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@v3
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@v3
with:
name: dist
path: dist

- name: Test 🔬
run: yarn test:${{ matrix.bundle }}
12 changes: 6 additions & 6 deletions .github/workflows/ci:test.yml → .github/workflows/ci:cover.yml
Original file line number Diff line number Diff line change
@@ -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@v3
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/ci:lint-config.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions .github/workflows/ci:build.yml → .github/workflows/ci:lint.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Parent is [@codec-bytes/about](https://github.com/codec-bytes/about).

[![License](https://img.shields.io/github/license/codec-bytes/ascii.svg)](https://raw.githubusercontent.com/codec-bytes/ascii/main/LICENSE)
[![Version](https://img.shields.io/npm/v/@codec-bytes/ascii.svg)](https://www.npmjs.org/package/@codec-bytes/ascii)
[![Tests](https://img.shields.io/github/workflow/status/codec-bytes/ascii/ci:test?event=push&label=tests)](https://github.com/codec-bytes/ascii/actions/workflows/ci:test.yml?query=branch:main)
[![Tests](https://img.shields.io/github/workflow/status/codec-bytes/ascii/ci?event=push&label=tests)](https://github.com/codec-bytes/ascii/actions/workflows/ci.yml?query=branch:main)
[![Dependencies](https://img.shields.io/librariesio/github/codec-bytes/ascii.svg)](https://github.com/codec-bytes/ascii/network/dependencies)
[![GitHub issues](https://img.shields.io/github/issues/codec-bytes/ascii.svg)](https://github.com/codec-bytes/ascii/issues)
[![Downloads](https://img.shields.io/npm/dm/@codec-bytes/ascii.svg)](https://www.npmjs.org/package/@codec-bytes/ascii)
Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,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",
Expand All @@ -62,7 +60,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": {
"@codec-bytes/error": "^5.0.0"
Expand All @@ -76,6 +80,8 @@
"@iterable-iterator/range": "^2.1.0",
"@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.0.1",
Expand Down Expand Up @@ -104,7 +110,7 @@
],
"timeout": "1m",
"nodeArguments": [
"--experimental-loader=@node-loader/babel"
"--experimental-loader=@node-loader/core"
]
},
"babel": {
Expand Down
5 changes: 5 additions & 0 deletions test/import-maps/dist/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"#module": "./dist/index.cjs"
}
}
5 changes: 5 additions & 0 deletions test/import-maps/dist/index.modern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"#module": "./dist/index.modern.js"
}
}
5 changes: 5 additions & 0 deletions test/import-maps/dist/index.module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"#module": "./dist/index.module.js"
}
}
5 changes: 5 additions & 0 deletions test/import-maps/src/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"#module": "./src/index.js"
}
}
8 changes: 8 additions & 0 deletions test/loader/config.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion test/src/_fixtures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as mod from '../../src/index.js';
import * as mod from '#module';

const _mod = mod.default ?? mod;

Expand Down
2 changes: 1 addition & 1 deletion test/src/decode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import {range} from '@iterable-iterator/range';

import {decode, ASCIIDecodeError, byte2char} from '../../src/index.js';
import {decode, ASCIIDecodeError, byte2char} from '#module';
import {CodecError} from './_fixtures.js';

function success(t, bytes, options, expected) {
Expand Down
2 changes: 1 addition & 1 deletion test/src/encode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import {range} from '@iterable-iterator/range';

import {encode, ASCIIEncodeError, byte2char} from '../../src/index.js';
import {encode, ASCIIEncodeError, byte2char} from '#module';
import {CodecError} from './_fixtures.js';

function success(t, string, options, expected) {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,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"
Expand Down

0 comments on commit b11aa0a

Please sign in to comment.