Skip to content

Commit

Permalink
fix(hadron-build): make sure that target gets the distribution in CI …
Browse files Browse the repository at this point in the history
…consistently
  • Loading branch information
gribnoysup committed Aug 21, 2024
1 parent f5edfe3 commit 3c3b9cd
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .evergreen/compass_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ "$OSTYPE" == "cygwin" ]]; then
fi

echo "Creating signed release build..."
npm run package-compass-nocompile $COMPASS_DISTRIBUTION
npm run package-compass-nocompile
npm run generate-first-party-deps-json

ls -la packages/compass/dist
Expand Down
7 changes: 4 additions & 3 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,13 @@ functions:
shell: bash
env:
<<: *compass-env
HADRON_DISTRIBUTION: ${compass_distribution}
script: |
set -e
# Load environment variables
eval $(.evergreen/print-compass-env.sh)
# Generates and expansion file with build target metadata in packages/compass/expansions.yml
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten ${compass_distribution} --out expansions.raw.yml
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten --out expansions.raw.yml
# the 'author' key conflicts with evergreen's own expansion
grep -v '^author:' < packages/compass/expansions.raw.yml > packages/compass/expansions.yml
- command: expansions.update
Expand Down Expand Up @@ -405,7 +406,7 @@ functions:
<<: *compass-env
DEBUG: ${debug}
npm_config_loglevel: ${npm_loglevel}
COMPASS_DISTRIBUTION: ${compass_distribution}
HADRON_DISTRIBUTION: ${compass_distribution}
script: |
set -e
Expand Down Expand Up @@ -443,7 +444,7 @@ functions:
<<: *compass-env
DEBUG: ${debug}
npm_config_loglevel: ${npm_loglevel}
COMPASS_DISTRIBUTION: ${compass_distribution}
HADRON_DISTRIBUTION: ${compass_distribution}
SIGNING_SERVER_HOSTNAME: ${SIGNING_SERVER_HOSTNAME}
SIGNING_SERVER_PRIVATE_KEY: ${SIGNING_SERVER_PRIVATE_KEY}
SIGNING_SERVER_PRIVATE_KEY_CYGPATH: ${SIGNING_SERVER_PRIVATE_KEY_CYGPATH}
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ In addition to running lerna commands directly, there are a few convenient npm s
To build compass you can run `package-compass` script:

```sh
npm run package-compass
HADRON_DISTRIBUTION='compass' npm run package-compass
```

You can change the type of distribution you are building with `HADRON_DISTRIBUTION` environmental variable:
It is required to provide `HADRON_DISTRIBUTION` env variable explicitly. You can change the type of distribution you are building by setting a different `HADRON_DISTRIBUTION` value:

```sh
HADRON_DISTRIBUTION='compass-readonly' npm run package-compass
Expand Down
3 changes: 0 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"release": "npm run release --workspace mongodb-compass --",
"reformat": "lerna run reformat --stream --no-bail",
"package-compass": "npm run package-compass --workspace=mongodb-compass --",
"package-compass-debug": "npm run package-compass-debug --workspace=mongodb-compass --",
"package-compass-nocompile": "npm run package-compass-nocompile --workspace=mongodb-compass --",
"prestart": "npm run compile --workspace=@mongodb-js/webpack-config-compass",
"prestart-web": "npm run prestart",
Expand Down
5 changes: 2 additions & 3 deletions packages/compass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
}
],
"distributions": {
"default": "compass",
"compass": {
"name": "mongodb-compass",
"productName": "MongoDB Compass",
Expand Down Expand Up @@ -143,7 +142,7 @@
"install": "node scripts/download-fonts.js && node scripts/download-csfle.js",
"electron-rebuild": "electron-rebuild --only kerberos,keytar,interruptor,os-dns-native,win-export-certificate-and-key,macos-export-certificate-and-key --prebuild-tag-prefix not-real-prefix-to-force-rebuild",
"prestart": "npm run electron-rebuild",
"start": "npm run webpack serve -- --mode development",
"start": "HADRON_DISTRIBUTION=${HADRON_DISTRIBUTION:-compass} npm run webpack serve -- --mode development",
"test-electron": "npm run test-main && npm run test-renderer",
"test-main": "xvfb-maybe electron-mocha --no-sandbox \"./src/main/**/*.spec.*\" \"./src/main/**/*.test.*\"",
"test-renderer": "xvfb-maybe electron-mocha --no-sandbox --config ./.mocharc.renderer.js \"./src/app/**/*.spec.*\"",
Expand All @@ -158,7 +157,7 @@
"package-compass-nocompile": "hadron-build release",
"prepackage-compass": "npm run compile",
"package-compass": "npm run package-compass-nocompile",
"package-compass-debug": "DEBUG='*' HADRON_SKIP_INSTALLER=true NO_ASAR=true npm run package-compass",
"package-compass-debug": "DEBUG='hadron*,compass*' HADRON_SKIP_INSTALLER=true NO_ASAR=true npm run package-compass",
"upload": "hadron-build upload",
"download": "hadron-build download",
"evergreen-expansions": "hadron-build info --format=yaml --flatten > expansions.yml",
Expand Down
1 change: 0 additions & 1 deletion packages/hadron-build/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const yargs = require('yargs')
.command(require('./commands/info'))
.command(require('./commands/upload'))
.command(require('./commands/download'))
.command(require('./commands/verify'))
.demand(1, 'Please specify a command.')
.strict()
.env()
Expand Down
3 changes: 0 additions & 3 deletions packages/hadron-build/commands/info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
const _ = require('lodash');
const Target = require('../lib/target');
const verifyDistro = require('../lib/distro');
const Table = require('cli-table');
const yaml = require('js-yaml');
const inspect = require('util').inspect;
Expand Down Expand Up @@ -74,8 +73,6 @@ const toTable = (target) => {
};

exports.handler = (argv) => {
verifyDistro(argv);

let target = new Target(argv.dir, {
version: argv.version,
platform: argv.platform,
Expand Down
8 changes: 0 additions & 8 deletions packages/hadron-build/commands/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

const Target = require('../lib/target');
const verifyDistro = require('../lib/distro');
const cli = require('mongodb-js-cli')('hadron-build:release');
const util = require('util');
const format = util.format;
Expand All @@ -30,8 +29,6 @@ const run = require('./../lib/run');
const rebuild = require('@electron/rebuild').rebuild;
const { signArchive } = require('./../lib/signtool');

const verify = require('./verify');

exports.command = 'release';

exports.describe = ':shipit:';
Expand Down Expand Up @@ -514,8 +511,6 @@ exports.builder = {
}
};

_.assign(exports.builder, verify.builder);


/**
* @param {any} argv Parsed command arguments
Expand All @@ -525,8 +520,6 @@ _.assign(exports.builder, verify.builder);
exports.run = async (argv, done) => {
cli.argv = argv;

verifyDistro(argv);

const target = new Target(argv.dir);

cli.debug(`Building distribution: ${target.distribution}`);
Expand All @@ -551,7 +544,6 @@ exports.run = async (argv, done) => {
const noAsar = process.env.NO_ASAR === 'true' || argv.no_asar;

const tasks = _.flatten([
() => verify.tasks(argv),
task('copy npmrc from root', ({ dir }, done) => {
fs.cp(
path.resolve(dir, '..', '..', '.npmrc'),
Expand Down
53 changes: 0 additions & 53 deletions packages/hadron-build/commands/verify.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/hadron-build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ exports = function() {};
exports.release = require('./commands/release');
exports.upload = require('./commands/upload');
exports.download = require('./commands/download');
exports.verify = require('./commands/verify');

module.exports = exports;
13 changes: 0 additions & 13 deletions packages/hadron-build/lib/distro.js

This file was deleted.

16 changes: 15 additions & 1 deletion packages/hadron-build/lib/target.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,25 @@ class Target {

const distributions = pkg.config.hadron.distributions;

if (!process.env.HADRON_DISTRIBUTION) {
throw new Error(
'You need to explicitly set HADRON_DISTRIBUTION before building Compass'
);
}

if (!distributions[process.env.HADRON_DISTRIBUTION]) {
throw new Error(
`Unknown distribution "${
process.env.HADRON_DISTRIBUTION
}". Available distributions: ${Object.keys(distributions).join(', ')}`
);
}

_.defaults(opts, { version: process.env.HADRON_APP_VERSION }, pkg, {
platform: process.platform,
arch: process.arch,
sign: true,
distribution: process.env.HADRON_DISTRIBUTION || distributions.default
distribution: process.env.HADRON_DISTRIBUTION,
});

this.distribution = opts.distribution;
Expand Down

0 comments on commit 3c3b9cd

Please sign in to comment.