Skip to content

Commit 43e78ed

Browse files
authored
Merge pull request #657 from relative-ci/update-tests
Update tests
2 parents aa81579 + bcb22ba commit 43e78ed

22 files changed

+328
-27
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: ci
2-
on:
2+
on:
33
push:
4-
branches:
4+
branches:
55
- master
66
- next
77
tags:
@@ -51,8 +51,8 @@ jobs:
5151
retention-days: 1
5252
path: dist*/
5353

54-
test-package:
55-
name: Test package on node ${{ matrix.node }} / ${{ matrix.os }} / rollup v${{ matrix.rollup }}
54+
test-package-rollup:
55+
name: 'rollup v${{ matrix.rollup }} / node ${{ matrix.node }} / ${{ matrix.os }}'
5656
needs:
5757
- build
5858
runs-on: ubuntu-latest
@@ -98,19 +98,72 @@ jobs:
9898

9999
- name: Install test package dependencies
100100
run: |
101-
npm install
101+
npm install
102102
npm install rollup@${{ matrix.rollup }} --force
103103
npx rollup -v
104-
working-directory: test/package
104+
working-directory: test/package/rollup
105105

106106
- name: Test package
107-
run: npm run test:package
107+
run: npm run test
108+
working-directory: test/package/rollup
109+
110+
test-package-vite:
111+
name: 'vite v${{ matrix.vite }} / node ${{ matrix.node }} / ${{ matrix.os }}'
112+
needs:
113+
- build
114+
runs-on: ubuntu-latest
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
node: ['22', '20', '18']
119+
os: [ubuntu-latest, windows-latest]
120+
vite: ['5', '6', '7']
121+
exclude:
122+
- os: windows-latest
123+
node: 20
124+
- os: windows-latest
125+
node: 18
126+
- vite: 7
127+
node: 18
128+
steps:
129+
- name: Checkout repo
130+
uses: actions/checkout@v5.0.0
131+
132+
- name: Setup node & npm
133+
uses: relative-ci/.github/actions/setup-node-npm@v1.1.5
134+
with:
135+
version: ${{ matrix.node }}
136+
cache: never
137+
install: false
138+
139+
- name: Install vitest
140+
run: npm install vitest
141+
142+
- name: Download build files
143+
uses: actions/download-artifact@v6.0.0
144+
with:
145+
name: build-artifacts
146+
147+
- name: Setup local npm registry
148+
run: ./scripts/setup-registry.sh
149+
150+
- name: Install test package dependencies
151+
run: |
152+
npm install
153+
npm install vite@${{ matrix.vite }} --force
154+
npx vite -v
155+
working-directory: test/package/vite
156+
157+
- name: Test package
158+
run: npm run test
159+
working-directory: test/package/vite
108160

109161
tests:
110162
needs:
111163
- lint
112164
- test-unit
113-
- test-package
165+
- test-package-rollup
166+
- test-package-vite
114167
runs-on: ubuntu-latest
115168
steps:
116169
- run: exit 0

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
"build": "tsc && rollup -c rollup.config.mjs",
5151
"lint": "exit 0",
5252
"test:unit": "vitest test/unit",
53-
"test:package": "cd test/package && vitest",
53+
"test:package": "npm run test:package:rollup && npm run test:package:vite",
54+
"test:package:rollup": "cd test/package/rollup && vitest",
55+
"test:package:vite": "cd test/package/vite && vitest",
5456
"bump": "./scripts/bump.sh",
5557
"release": "./scripts/release.sh"
5658
},

test/package/package.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/package/rollup/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock.json
2+
dist*

test/package/rollup/case-config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
2+
const { defineConfig } = require('rollup');
3+
const webpackStatsPlugin = require('rollup-plugin-webpack-stats');
4+
5+
module.exports = defineConfig({
6+
input: 'src/index.js',
7+
output: {
8+
dir: 'dist',
9+
},
10+
plugins: [webpackStatsPlugin()],
11+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'rollup';
2+
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';
3+
4+
export default defineConfig({
5+
input: 'src/index.js',
6+
output: {
7+
dir: 'dist',
8+
},
9+
plugins: [webpackStatsPlugin()],
10+
});

test/package/rollup/case-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'rollup';
2+
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';
3+
4+
export default defineConfig({
5+
input: 'src/index.js',
6+
output: {
7+
dir: 'dist',
8+
},
9+
plugins: [webpackStatsPlugin({})],
10+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { promisify } from 'node:util';
2+
import { exec as execCallback} from 'node:child_process';
3+
import { describe, expect, test } from 'vitest';
4+
5+
const exec = promisify(execCallback);
6+
7+
const testCases = [
8+
{ type: 'commonjs', run: 'npm run build-commonjs' },
9+
{ type: 'esm', run: 'npm run build-esm' },
10+
{ type: 'ts', run: 'npm run build-ts' },
11+
];
12+
13+
describe('package - rollup configs', () => {
14+
testCases.forEach((testCase) => {
15+
test(`should build successfully with rollup ${testCase.type} config`, async () => {
16+
const { stderr } = await exec(`cross-env NO_COLOR=true ${testCase.run}`);
17+
18+
expect(stderr).toMatch('Stats saved to dist');
19+
expect(stderr).toMatch('created dist in');
20+
});
21+
});
22+
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { beforeEach, describe, test, expect } from 'vitest';
44
import { rollup } from 'rollup';
55
import { vol } from 'memfs';
66

7-
import rollupConfig from './rollup.config';
7+
import rollupConfig from './case-options.mjs';
88

9-
describe('package test', () => {
9+
describe('rollup options', () => {
1010
beforeEach(() => {
1111
vol.reset();
1212
});

0 commit comments

Comments
 (0)