From fd7bd033880ecac5cec41daf6eedf5b09f2377a0 Mon Sep 17 00:00:00 2001 From: Chad Killingsworth Date: Sat, 17 May 2025 07:41:34 -0500 Subject: [PATCH] Remove support for nightly/snapshot builds With a more-frequent compiler release schedule, nightly snapshots are no longer needed --- build-scripts/build-compiler.js | 12 +-- build-scripts/create-nightly-version.js | 51 ------------ build-scripts/publish.js | 4 - test/compiler.js | 106 ++++++++++++------------ 4 files changed, 53 insertions(+), 120 deletions(-) delete mode 100755 build-scripts/create-nightly-version.js diff --git a/build-scripts/build-compiler.js b/build-scripts/build-compiler.js index 86187574..cdd10fab 100755 --- a/build-scripts/build-compiler.js +++ b/build-scripts/build-compiler.js @@ -24,10 +24,6 @@ * * For pull requests and pushes to master, the compiler submodule is expected to be pointed at the tagged commit * that matches the package major version. - * - * When the COMPILER_NIGHTLY env variable is set, the compiler submodule will be pointing to the latest master - * commit. This is for regular integration testing of the compiler with the various tests in this repo's packages. - * In this case the compiler will be built as a SNAPSHOT. */ import fs from 'node:fs'; import path from 'node:path'; @@ -43,16 +39,12 @@ const packageInfo = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../packa * The compiler version that will be built. * * For release builds, this is of the form: "vYYYYMMDD" - * For nightly builds, this is "1.0-SNAPSHOT" * * @type {string} */ -const compilerVersion = process.env.COMPILER_NIGHTLY === 'true' - ? 'SNAPSHOT-1.0' - : `v${semver.major(packageInfo.version)}`; +const compilerVersion = `v${semver.major(packageInfo.version)}`; -const compilerTargetName = compilerVersion === 'SNAPSHOT-1.0' || parseInt(compilerVersion.slice(1), 10) > 20221004 ? - 'compiler_uberjar_deploy.jar' : 'compiler_unshaded_deploy.jar'; +const compilerTargetName = 'compiler_uberjar_deploy.jar'; const compilerJavaBinaryPath = `./compiler/bazel-bin/${compilerTargetName}`; async function main() { diff --git a/build-scripts/create-nightly-version.js b/build-scripts/create-nightly-version.js deleted file mode 100755 index 372766fa..00000000 --- a/build-scripts/create-nightly-version.js +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node -/* - * Copyright 2018 The Closure Compiler Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @fileoverview Create a nightly version of the package to publish to npm. - * The compiler in this version will be a snapshot version. - */ - -const runCommand = require('./run-command'); - -const today = new Date(); -const month = (today.getMonth() < 9 ? '0' : '') + (today.getMonth() + 1).toString(); -const day = (today.getDate() < 10 ? '0' : '') + today.getDate().toString(); - -// Version number is today's date with a -nightly prerelease suffix. -const nightlyVersion = `${today.getFullYear()}${month}${day}.0.0-nightly`; - -(async () => { - try { - // Create a branch then commit the changes for this nightly release. - await runCommand('git', ['checkout', '-b', `publish-${nightlyVersion}`]); - await runCommand('git', ['add', 'compiler']); - await runCommand( - 'yarn', - [ - 'version', - '--new-version', - nightlyVersion, - '--message', - `Create version for nightly release ${nightlyVersion}` - ] - ); - } catch (e) { - console.error(e); - process.exitCode = 1; - } -})(); diff --git a/build-scripts/publish.js b/build-scripts/publish.js index aabf49a6..14aa9587 100755 --- a/build-scripts/publish.js +++ b/build-scripts/publish.js @@ -30,7 +30,6 @@ import runCommand from './run-command.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); const packagesDirPath = path.resolve(__dirname, '../packages'); -const isNightlyVersion = process.env.COMPILER_NIGHTLY === 'true'; async function isPackageVersionPublished(packageName, version) { return fetch(`https://registry.npmjs.org/${encodeURI(packageName)}/${version}`) @@ -64,9 +63,6 @@ async function publishPackagesIfNeeded(packageInfo) { } console.log('Publishing', pkgJson.name, pkgJson.version); const publishArgs = ['-w', pkgJson.name, 'publish']; - if (isNightlyVersion) { - publishArgs.push('--tag', 'nightly'); - } await runCommand('npm', publishArgs); } diff --git a/test/compiler.js b/test/compiler.js index 98089419..151d0416 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -34,13 +34,29 @@ const compilerVersionMatch = /^Version: v(\d+)$/m; process.on('unhandledRejection', (e) => { throw e; }); -const isNightlyBuild = /^true|1$/i.test(process.env.COMPILER_NIGHTLY); +describe('compiler.jar', function () { + it('should not be a snapshot build', async () => { + const compiler = new Compiler({version: true}); + const {stdout} = await new Promise((resolve) => + compiler.run((exitCode, stdout, stderr) => + resolve({ + exitCode, + stdout, + stderr, + }) + ) + ); + let versionInfo = (stdout || '').match(compilerVersionMatch); + expect(versionInfo).not.toBeNullish(); + versionInfo = versionInfo || []; + expect(versionInfo.length).toBe(2); + expect(versionInfo[1].indexOf('SNAPSHOT')).toBeLessThan(0); + }); -if (!isNightlyBuild) { - describe('compiler.jar', function () { - it('should not be a snapshot build', async () => { - const compiler = new Compiler({version: true}); - const {stdout} = await new Promise((resolve) => + it('version should be equal to the package major version', async () => { + const compiler = new Compiler({version: true}); + const packageVer = new Semver(packageInfo.version); + const {stdout} = await new Promise((resolve) => compiler.run((exitCode, stdout, stderr) => resolve({ exitCode, @@ -48,57 +64,37 @@ if (!isNightlyBuild) { stderr, }) ) - ); - let versionInfo = (stdout || '').match(compilerVersionMatch); - expect(versionInfo).not.toBeNullish(); - versionInfo = versionInfo || []; - expect(versionInfo.length).toBe(2); - expect(versionInfo[1].indexOf('SNAPSHOT')).toBeLessThan(0); - }); + ); + let versionInfo = (stdout || '').match(compilerVersionMatch); + expect(versionInfo).not.toBeNullish(); + versionInfo = versionInfo || []; + expect(versionInfo.length).toBe(2); - it('version should be equal to the package major version', async () => { - const compiler = new Compiler({version: true}); - const packageVer = new Semver(packageInfo.version); - const {stdout} = await new Promise((resolve) => - compiler.run((exitCode, stdout, stderr) => - resolve({ - exitCode, - stdout, - stderr, - }) - ) - ); - let versionInfo = (stdout || '').match(compilerVersionMatch); - expect(versionInfo).not.toBeNullish(); - versionInfo = versionInfo || []; - expect(versionInfo.length).toBe(2); - - let compilerVersion; - try { - console.log(versionInfo[1] + '.0.0'); - compilerVersion = new Semver(versionInfo[1] + '.0.0'); - } catch (e) { - fail('should be a semver parseable'); - } - expect(compilerVersion.major).toBe(packageVer.major); - }); + let compilerVersion; + try { + console.log(versionInfo[1] + '.0.0'); + compilerVersion = new Semver(versionInfo[1] + '.0.0'); + } catch (e) { + fail('should be a semver parseable'); + } + expect(compilerVersion.major).toBe(packageVer.major); }); +}); - describe('compiler submodule', () => { - it('should be synced to the tagged commit', () => { - const gitCmd = spawn('git', ['tag', '--points-at', 'HEAD'], { - cwd: './compiler' - }); - expect(gitCmd.status).toBe(0); - console.log(gitCmd.stdout.toString()); - const currentTag = gitCmd.stdout.toString().replace(/\s/g, ''); - const packageVer = new Semver(packageInfo.version); - const mvnVersion = 'v' + packageVer.major; - let normalizedTag = currentTag; - if (normalizedTag) { - normalizedTag = currentTag.replace(/^([-a-z]+-)?(v\d{8})(.*)$/, '$2'); - } - expect(normalizedTag).toBe(mvnVersion) +describe('compiler submodule', () => { + it('should be synced to the tagged commit', () => { + const gitCmd = spawn('git', ['tag', '--points-at', 'HEAD'], { + cwd: './compiler' }); + expect(gitCmd.status).toBe(0); + console.log(gitCmd.stdout.toString()); + const currentTag = gitCmd.stdout.toString().replace(/\s/g, ''); + const packageVer = new Semver(packageInfo.version); + const mvnVersion = 'v' + packageVer.major; + let normalizedTag = currentTag; + if (normalizedTag) { + normalizedTag = currentTag.replace(/^([-a-z]+-)?(v\d{8})(.*)$/, '$2'); + } + expect(normalizedTag).toBe(mvnVersion) }); -} +});