Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DROP: Remove cli test on win #3811

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 3 additions & 93 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
push:
branches:
- master
- fix-baseline-write
tags:
- v*
pull_request:

jobs:
build:
Expand Down Expand Up @@ -169,8 +169,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [20, 18, 16, 14]
os: [windows-latest, ubuntu-latest]
node: [14]
runs-on: ${{ matrix.os }}
name: CLI ${{ matrix.os }} nodejs ${{ matrix.node }}
steps:
Expand Down Expand Up @@ -208,102 +208,12 @@ jobs:
run: npm run test:package
working-directory: packages/cli

test-package-webpack-plugin:
needs:
- build
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node: [20, 18, 16, 14]
webpack: ['webpack4', 'webpack5']
exclude:
- webpack: 'webpack4'
node: 18
- webpack: 'webpack4'
node: 20
- os: windows-latest
node: 20
- os: windows-latest
node: 18
- os: windows-latest
node: 16
runs-on: ${{ matrix.os }}
name: ${{ matrix.webpack }} plugin ${{ matrix.os }} nodejs ${{ matrix.node }}
steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}

- name: Download build files
uses: actions/download-artifact@v3
with:
name: build-artifacts

- name: Download local registry files
uses: actions/download-artifact@v3
with:
name: local-registry

- name: Install dependencies
run: npm install -g verdaccio

- name: Run local npm registry
run: ./scripts/local-registry.sh &

- name: Test package
run: npm run test:package -- -t ${{ matrix.webpack }}
working-directory: packages/webpack-plugin

test-package-rollup-plugin:
needs:
- build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16]
runs-on: ${{ matrix.os }}
name: rollup plugin ${{ matrix.os }} nodejs ${{ matrix.node }}
steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}

- name: Download build files
uses: actions/download-artifact@v3
with:
name: build-artifacts

- name: Download local registry files
uses: actions/download-artifact@v3
with:
name: local-registry

- name: Install dependencies
run: npm install -g verdaccio

- name: Run local npm registry
run: ./scripts/local-registry.sh &

- name: Test package
run: npm run test:package
working-directory: packages/rollup-plugin

tests:
needs:
- lint
- test-unit
- test-e2e
- test-package-cli
- test-package-webpack-plugin
- test-package-rollup-plugin
runs-on: ubuntu-latest
steps:
- run: echo "Tests done."
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import yargs from 'yargs';
import updateNotifier from 'update-notifier';

import run from './run';
// @ts-ignore
import info from '../package.json';

const DEFAULT_OUTPUT_DIR = './dist';
const WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
Expand Down Expand Up @@ -35,6 +37,8 @@ export default async function cli(pkg: object) {
return;
}

console.info('CLI', info.version, info.name);

const args = yargs
.usage('Usage: $0 OPTIONS [STATS_FILE]...')
.demandCommand(1, 'Webpack stats file path is required.')
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export default async function run(options: RunOptions): Promise<void> {
// Generate relative path relative to process.cwd()
const baselinePath = getBaselineRelativePath(process.cwd(), '', baselineAbsolutePath);

console.log({
dirname: __dirname,
console.log('RUN', {
cwd: process.cwd(),
baselineAbsolutePath,
baselinePath,
Expand Down
14 changes: 11 additions & 3 deletions packages/cli/test/package/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,29 @@ describe('CLI', () => {
expect(stdout).toContain('[SUCCESS] Save reports');
});

test('should generate report with custom relative baseline filepath', async () => {
test.only('should generate report with custom relative baseline filepath', async () => {
// prime relative custom baseline
const baselineCustomRelativeDirectory = path.join('dist', baselineCustomDirectory);
const baselineCustomRelativeFilepath = path.join('dist', baselineCustomFilepath);

await fs.mkdir(baselineCustomRelativeDirectory, { recursive: true });
await fs.mkdir(path.join(__dirname, baselineCustomRelativeDirectory), { recursive: true });
await fs.copyFile(
'../../__fixtures__/webpack-stats.baseline.json',
baselineCustomRelativeFilepath,
path.join(__dirname, baselineCustomRelativeFilepath),
);

console.log('TEST', {
cwd: process.cwd() || 'process.cwd is empty',
baselineCustomRelativeDirectory,
baselineCustomRelativeFilepath,
});

const { stdout } = await exec(
`npx bundle-stats --compare --baseline --baseline-filepath ${baselineCustomFilepath} ../../__fixtures__/webpack-stats.current.json`,
);

console.log(stdout);

const htmlReport = await fs.readFile('dist/bundle-stats.html', 'utf8');
expect(htmlReport).toContain('Bundle Size — 2MiB (-3.11%). - BundleStats');

Expand Down
Loading