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

ci: refactor #830

Merged
merged 3 commits into from Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/nodejs.yml
Expand Up @@ -90,13 +90,15 @@ jobs:

- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:coverage -- --ci
env:
EXPERIMENTAL_USE_IMPORT_MODULE: "false"

- name: Submit coverage data to codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

test2:
test-new-api:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack latest, experimentalUseImportModule

strategy:
Expand Down
13 changes: 10 additions & 3 deletions test/TestCases.test.js
Expand Up @@ -9,6 +9,8 @@ import webpack from "webpack";

import Self from "../src/index";

import yn from "./helpers/yn";

function clearDirectory(dirPath) {
let files;

Expand Down Expand Up @@ -128,9 +130,12 @@ describe("TestCases", () => {
config.plugins.map((p) => {
if (p.constructor === Self) {
const { options } = p;
options.experimentalUseImportModule =
!!process.env.EXPERIMENTAL_USE_IMPORT_MODULE;

options.experimentalUseImportModule = yn(
process.env.EXPERIMENTAL_USE_IMPORT_MODULE
);
}

return p;
}),
},
Expand Down Expand Up @@ -192,7 +197,9 @@ describe("TestCases", () => {
const expectedDirectoryByVersion = path.join(
expectedDirectory,
`webpack-${webpack.version[0]}${
process.env.EXPERIMENTAL_USE_IMPORT_MODULE ? "-importModule" : ""
yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE)
? "-importModule"
: ""
}`
);

Expand Down
4 changes: 3 additions & 1 deletion test/cases/auxiliary-assets/test.filter.js
@@ -1 +1,3 @@
module.exports = () => !process.env.EXPERIMENTAL_USE_IMPORT_MODULE;
import yn from "../../helpers/yn";

module.exports = () => !yn(process.env.EXPERIMENTAL_USE_IMPORT_MODULE);
13 changes: 13 additions & 0 deletions test/helpers/yn.js
@@ -0,0 +1,13 @@
function yn(value, defaultValue = false) {
if (/^(?:y|yes|true|1|on)$/i.test(value)) {
return true;
}

if (/^(?:n|no|false|0|off)$/i.test(value)) {
return false;
}

return defaultValue;
}

module.exports = yn;