Skip to content

Commit

Permalink
build: fail if there are deps version mismateches in package.json vs …
Browse files Browse the repository at this point in the history
…src-node/package.json
  • Loading branch information
abose committed Oct 18, 2023
1 parent 322572e commit f9aee9b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/playwright-on-push-main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Playwright-Chromium and firefox run full tests suite
name: On-Push-Main Chromium and firefox (Win/Mac/Linux) run full tests suite

on:
push:
Expand Down Expand Up @@ -302,16 +302,17 @@ jobs:
raiseIssue:
needs: [ playwrightChromiumLinux, playwrightChromiumWindows, playwrightChromiumMacos, playwrightFirefoxLinux, playwrightFirefoxWindows, playwrightFirefoxMacos]
runs-on: ubuntu-latest
if: always() # This ensures that this job runs even if the previous jobs failed
if: |
always() && ( # This ensures that this job runs even if the previous jobs failed
needs.playwrightChromiumLinux.result == 'failure' ||
needs.playwrightChromiumWindows.result == 'failure' ||
needs.playwrightChromiumMacos.result == 'failure' ||
needs.playwrightFirefoxLinux.result == 'failure' ||
needs.playwrightFirefoxWindows.result == 'failure' ||
needs.playwrightFirefoxMacos.result == 'failure'
)
steps:
- name: Check for failures and raise an issue
if: |
needs.playwrightChromiumLinux.result == 'failure' ||
needs.playwrightChromiumWindows.result == 'failure' ||
needs.playwrightChromiumMacos.result == 'failure' ||
needs.playwrightFirefoxLinux.result == 'failure' ||
needs.playwrightFirefoxWindows.result == 'failure' ||
needs.playwrightFirefoxMacos.result == 'failure'
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down
51 changes: 50 additions & 1 deletion gulpfile.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,59 @@ function makeLoggerConfig() {
});
}

function validatePackageVersions() {
return new Promise((resolve, reject)=>{
const mainPackageJson = require("../package.json", "utf8");
const nodePackageJson = require("../src-node/package.json", "utf8");
if(nodePackageJson.devDependencies){
reject("Node package json file(src-node/package.json) should not have any dev dependencies!");
return;
}
const mainDevDeps = mainPackageJson.devDependencies,
mainDeps = mainPackageJson.dependencies,
nodeDeps = nodePackageJson.dependencies;

// Create a merged list of all package names
const allPackages = new Set([
...Object.keys(mainDevDeps || {}),
...Object.keys(mainDeps || {}),
...Object.keys(nodeDeps || {})
]);

let hasMismatch = false;
for (let packageName of allPackages) {
const mainDevVersion = mainDevDeps && mainDevDeps[packageName];
const mainVersion = mainDeps && mainDeps[packageName];
const nodeVersion = nodeDeps && nodeDeps[packageName];

if (mainDevVersion && mainVersion && mainDevVersion !== mainVersion) {
console.error(`Version mismatch for package ${packageName}: ${mainDevVersion} (package.json devDependencies) vs ${mainVersion} (package.json dependencies)`);
hasMismatch = true;
}

if (mainDevVersion && nodeVersion && mainDevVersion !== nodeVersion) {
console.error(`Version mismatch for package ${packageName}: ${mainDevVersion} (package.json devDependencies) vs ${nodeVersion} (src-node/package.json dependencies)`);
hasMismatch = true;
}

if (mainVersion && nodeVersion && mainVersion !== nodeVersion) {
console.error(`Version mismatch for package ${packageName}: ${mainVersion} (package.json dependencies) vs ${nodeVersion} (src-node/package.json dependencies)`);
hasMismatch = true;
}
}

if (hasMismatch) {
reject("Package version mismatch detected. Check the errors above.");
} else {
resolve();
}
});
}

const createDistTest = series(copyDistToDistTestFolder, copyTestToDistTestFolder, copyIndexToDistTestFolder);

exports.build = series(copyThirdPartyLibs.copyAll, makeLoggerConfig, zipDefaultProjectFiles, zipSampleProjectFiles,
createSrcCacheManifest);
createSrcCacheManifest, validatePackageVersions);
exports.buildDebug = series(copyThirdPartyLibs.copyAllDebug, makeLoggerConfig, zipDefaultProjectFiles,
zipSampleProjectFiles, createSrcCacheManifest);
exports.clean = series(cleanDist);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@floating-ui/dom": "^0.5.4",
"@fortawesome/fontawesome-free": "^6.1.2",
"@highlightjs/cdn-assets": "^11.5.1",
"@phcode/fs": "^2.0.4",
"@phcode/fs": "^2.0.5",
"@pixelbrackets/gfm-stylesheet": "^1.1.0",
"@prettier/plugin-php": "0.18.9",
"bootstrap": "^5.1.3",
Expand Down
8 changes: 4 additions & 4 deletions src-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"IMPORTANT!!": "Adding things here will bloat up the package size",
"dependencies": {
"@phcode/fs": "^2.0.4",
"@phcode/fs": "^2.0.5",
"npm": "9.8.1"
}
}

0 comments on commit f9aee9b

Please sign in to comment.