From d04fe8fdb630b5590879a2a2e9ea991202e8a0bd Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Fri, 18 Feb 2022 10:11:49 -0300 Subject: [PATCH 01/79] GitHub action and script to retrieve versions --- .github/workflows/automatic-updates.yml | 25 +++++++++++++ build-automation.js | 49 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/automatic-updates.yml create mode 100644 build-automation.js diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml new file mode 100644 index 0000000000..8117427469 --- /dev/null +++ b/.github/workflows/automatic-updates.yml @@ -0,0 +1,25 @@ +name: Automatically update Docker image versions + +on: + schedule: + - cron: "15 * * * *" + +jobs: + build: + runs-on: ubuntu-latest + if: github.repository_owner == 'nodejs' + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + + - name: Run automation script + run: node ./build-automation.js + + + + + diff --git a/build-automation.js b/build-automation.js new file mode 100644 index 0000000000..a37abf8d36 --- /dev/null +++ b/build-automation.js @@ -0,0 +1,49 @@ +const util = require("util") + +const exec = util.promisify(require("child_process").exec); + +const https = require("https"); + +// a function that takes an URL as argument and makes a request to that URL +// returning the response as a promise +const request = (url) => { + return new Promise((resolve, reject) => { + https.get(url, (res) => { + let body = ''; + res.on('data', (chunk) => { + body += chunk; + }); + res.on('end', () => { + if (res.statusCode < 400) { + resolve(body); + } else { + reject(new Error(`Request failed: ${res.statusCode}`)); + } + }) + }); + }); +}; + +const getLatestVersions = async () => { + try { + // const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); + // const nodeWebsiteText = nodeWebsite.toString(); + + // const { stdout: versionsOutput } = await exec(". functions.sh && get_versions ."); + + // const supportedVersions = versionsOutput.trim().split(" "); + + // const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); + + const { stdout: latestVersionsOutput, stderr } = await exec(". functions.sh && get_full_version ./16/bullseye"); + + console.log(latestVersionsOutput.trim()); + console.log(stderr); + } catch (error) { + console.log(error); + } +}; + +(async () => { + await getLatestVersions(); +})(); From 93e42d6c5b3fa7af321206259330d368982348e7 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Tue, 22 Feb 2022 00:26:03 -0300 Subject: [PATCH 02/79] Check if there are any new versions --- build-automation.js | 47 +++++++++++++++++++++++++++++++++++---------- functions.sh | 2 ++ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/build-automation.js b/build-automation.js index a37abf8d36..8502274628 100644 --- a/build-automation.js +++ b/build-automation.js @@ -24,26 +24,53 @@ const request = (url) => { }); }; -const getLatestVersions = async () => { +const checkIfThereAreNewVersions = async () => { try { - // const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); - // const nodeWebsiteText = nodeWebsite.toString(); + const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); + const nodeWebsiteText = nodeWebsite.toString(); - // const { stdout: versionsOutput } = await exec(". functions.sh && get_versions ."); + const { stdout: versionsOutput } = await exec(". functions.sh && get_versions ."); - // const supportedVersions = versionsOutput.trim().split(" "); + const supportedVersions = versionsOutput.trim().split(" "); - // const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); + const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); - const { stdout: latestVersionsOutput, stderr } = await exec(". functions.sh && get_full_version ./16/bullseye"); + let lsOutput = ""; + let latestSupportedVersions = {}; - console.log(latestVersionsOutput.trim()); - console.log(stderr); + for (let supportedVersion of supportedVersions) { + lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; + + const { stdout: fullVersionOutput } = await exec(`. functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); + + latestSupportedVersions[supportedVersion] = fullVersionOutput.trim(); + } + + // filter only more recent versions of availableVersions for each major version in latestSupportedVersions' keys + // e.g. if latestSupportedVersions = { "12": "12.22.10", "14": "14.19.0", "16": "16.14.0", "17": "17.5.0" } + // and availableVersions = ["Node.js 12.22.10", "Node.js 12.24.0", "Node.js 14.19.0", "Node.js 14.22.0", "Node.js 16.14.0", "Node.js 16.16.0", "Node.js 17.5.0", "Node.js 17.8.0"] + // return { "12": "12.24.0", "14": "14.22.0", "16": "16.16.0", "17": "17.8.0" } + + const filteredNewerVersions = latestSupportedVersions; + for (let availableVersion of availableVersions) { + if (availableVersion.includes("Node.js ")) { + const [availableMajor, availableMinor, availablePatch] = availableVersion.split(" ")[1].split("."); + const [_latestMajor, latestMinor, latestPatch] = filteredNewerVersions[availableMajor].split("."); + if (filteredNewerVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { + console.log(availableMajor, availableMinor, availablePatch, _latestMajor, latestMinor, latestPatch, availableMinor > latestMinor, (availableMinor === latestMinor && availablePatch > latestPatch)); + filteredNewerVersions[availableMajor] = `${availableMajor}.${availableMinor}.${availablePatch}`; + continue + } + } + } + + return JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions); } catch (error) { console.log(error); } }; (async () => { - await getLatestVersions(); + const shouldUpdate = await checkIfThereAreNewVersions(); + console.log(shouldUpdate); })(); diff --git a/functions.sh b/functions.sh index be9c575396..df1883f732 100755 --- a/functions.sh +++ b/functions.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # # Utlity functions +# Don't change this file unless needed +# The GitHub Action for automating new builds rely on this file info() { printf "%s\\n" "$@" From 47809f1897bba1cbd7f3e2616f81293f274d9a42 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Tue, 22 Feb 2022 00:28:08 -0300 Subject: [PATCH 03/79] exit if there is no new version --- build-automation.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-automation.js b/build-automation.js index 8502274628..8fac151977 100644 --- a/build-automation.js +++ b/build-automation.js @@ -72,5 +72,7 @@ const checkIfThereAreNewVersions = async () => { (async () => { const shouldUpdate = await checkIfThereAreNewVersions(); - console.log(shouldUpdate); + if (!shouldUpdate) { + process.exit(0); + } })(); From 613a7052c2180a39a6f2227ccb13a41820454b75 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Tue, 22 Feb 2022 01:14:18 -0300 Subject: [PATCH 04/79] check for security releases --- build-automation.js | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/build-automation.js b/build-automation.js index 8fac151977..8a28319c56 100644 --- a/build-automation.js +++ b/build-automation.js @@ -24,6 +24,9 @@ const request = (url) => { }); }; +// a function that queries the Node.js release website for new versions, +// compare the available ones with the ones we use in this repo +// and returns whether we should update or not const checkIfThereAreNewVersions = async () => { try { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); @@ -43,7 +46,7 @@ const checkIfThereAreNewVersions = async () => { const { stdout: fullVersionOutput } = await exec(`. functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); - latestSupportedVersions[supportedVersion] = fullVersionOutput.trim(); + latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } // filter only more recent versions of availableVersions for each major version in latestSupportedVersions' keys @@ -55,24 +58,51 @@ const checkIfThereAreNewVersions = async () => { for (let availableVersion of availableVersions) { if (availableVersion.includes("Node.js ")) { const [availableMajor, availableMinor, availablePatch] = availableVersion.split(" ")[1].split("."); - const [_latestMajor, latestMinor, latestPatch] = filteredNewerVersions[availableMajor].split("."); + const [_latestMajor, latestMinor, latestPatch] = filteredNewerVersions[availableMajor].fullVersion.split("."); if (filteredNewerVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { console.log(availableMajor, availableMinor, availablePatch, _latestMajor, latestMinor, latestPatch, availableMinor > latestMinor, (availableMinor === latestMinor && availablePatch > latestPatch)); - filteredNewerVersions[availableMajor] = `${availableMajor}.${availableMinor}.${availablePatch}`; + filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; continue } } } - return JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions); + return { + shouldUpdate: JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions), + versions: filteredNewerVersions, + } } catch (error) { console.log(error); } }; +// a function that queries the Node.js unofficial release website for new musl versions and security releases, +// and returns relevant information +const checkForMuslVersionsAndSecurityReleases = async (versions) => { + try { + let unofficialBuildsIndexText = JSON.parse(await request('https://unofficial-builds.nodejs.org/download/release/index.json')); + + let unofficialBuildsWebsiteText = ""; + + for (let version of Object.keys(versions)) { + unofficialBuildsWebsiteText = await request(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`); + versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); + + versions[version].isSecurityRelease = unofficialBuildsIndexText.find(indexVersion => indexVersion.version === `v${versions[version].fullVersion}`)?.security; + } + return versions; + } catch (error) { + console.log(error); + } +}; + +// if there are no new versions, exit gracefully (async () => { - const shouldUpdate = await checkIfThereAreNewVersions(); + const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); if (!shouldUpdate) { process.exit(0); + } else { + const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); + console.log(newVersions); } })(); From 44086cd667f140bb16bc70f0940d91e1496e3822 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 15:59:34 -0300 Subject: [PATCH 05/79] remove trailing spaces --- .github/workflows/automatic-updates.yml | 2 +- build-automation.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 8117427469..a56edb5401 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -8,7 +8,7 @@ jobs: build: runs-on: ubuntu-latest if: github.repository_owner == 'nodejs' - + steps: - uses: actions/checkout@v2 diff --git a/build-automation.js b/build-automation.js index 8a28319c56..690ba768da 100644 --- a/build-automation.js +++ b/build-automation.js @@ -43,7 +43,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - + const { stdout: fullVersionOutput } = await exec(`. functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; @@ -53,7 +53,7 @@ const checkIfThereAreNewVersions = async () => { // e.g. if latestSupportedVersions = { "12": "12.22.10", "14": "14.19.0", "16": "16.14.0", "17": "17.5.0" } // and availableVersions = ["Node.js 12.22.10", "Node.js 12.24.0", "Node.js 14.19.0", "Node.js 14.22.0", "Node.js 16.14.0", "Node.js 16.16.0", "Node.js 17.5.0", "Node.js 17.8.0"] // return { "12": "12.24.0", "14": "14.22.0", "16": "16.16.0", "17": "17.8.0" } - + const filteredNewerVersions = latestSupportedVersions; for (let availableVersion of availableVersions) { if (availableVersion.includes("Node.js ")) { @@ -66,11 +66,11 @@ const checkIfThereAreNewVersions = async () => { } } } - + return { shouldUpdate: JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions), versions: filteredNewerVersions, - } + } } catch (error) { console.log(error); } @@ -87,7 +87,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { for (let version of Object.keys(versions)) { unofficialBuildsWebsiteText = await request(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`); versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); - + versions[version].isSecurityRelease = unofficialBuildsIndexText.find(indexVersion => indexVersion.version === `v${versions[version].fullVersion}`)?.security; } return versions; From a6da3600cc1e23142babd9c448536d2b33a2c032 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 17:44:16 -0300 Subject: [PATCH 06/79] fix comparison login --- build-automation.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/build-automation.js b/build-automation.js index 690ba768da..6dff66ed34 100644 --- a/build-automation.js +++ b/build-automation.js @@ -8,8 +8,13 @@ const https = require("https"); // returning the response as a promise const request = (url) => { return new Promise((resolve, reject) => { - https.get(url, (res) => { + https.get(url, async (res) => { let body = ''; + + if(res.statusCode === 301 || res.statusCode === 302) { + resolve(await request(res.headers.location, resolve, reject)); + } + res.on('data', (chunk) => { body += chunk; }); @@ -54,13 +59,15 @@ const checkIfThereAreNewVersions = async () => { // and availableVersions = ["Node.js 12.22.10", "Node.js 12.24.0", "Node.js 14.19.0", "Node.js 14.22.0", "Node.js 16.14.0", "Node.js 16.16.0", "Node.js 17.5.0", "Node.js 17.8.0"] // return { "12": "12.24.0", "14": "14.22.0", "16": "16.16.0", "17": "17.8.0" } - const filteredNewerVersions = latestSupportedVersions; + let filteredNewerVersions = {}; + + Object.assign(filteredNewerVersions, latestSupportedVersions); + for (let availableVersion of availableVersions) { if (availableVersion.includes("Node.js ")) { const [availableMajor, availableMinor, availablePatch] = availableVersion.split(" ")[1].split("."); const [_latestMajor, latestMinor, latestPatch] = filteredNewerVersions[availableMajor].fullVersion.split("."); if (filteredNewerVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { - console.log(availableMajor, availableMinor, availablePatch, _latestMajor, latestMinor, latestPatch, availableMinor > latestMinor, (availableMinor === latestMinor && availablePatch > latestPatch)); filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; continue } @@ -83,7 +90,6 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { let unofficialBuildsIndexText = JSON.parse(await request('https://unofficial-builds.nodejs.org/download/release/index.json')); let unofficialBuildsWebsiteText = ""; - for (let version of Object.keys(versions)) { unofficialBuildsWebsiteText = await request(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`); versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); @@ -104,5 +110,9 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); console.log(newVersions); + let stdout = ""; + newVersions.map((version) => { + + }); } })(); From d063f389ad7cb4c3e98c2cf7d491c1228b0080ba Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 18:05:03 -0300 Subject: [PATCH 07/79] musl version and security release logic --- build-automation.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/build-automation.js b/build-automation.js index 6dff66ed34..8ea5c9e3ac 100644 --- a/build-automation.js +++ b/build-automation.js @@ -61,13 +61,11 @@ const checkIfThereAreNewVersions = async () => { let filteredNewerVersions = {}; - Object.assign(filteredNewerVersions, latestSupportedVersions); - for (let availableVersion of availableVersions) { if (availableVersion.includes("Node.js ")) { const [availableMajor, availableMinor, availablePatch] = availableVersion.split(" ")[1].split("."); - const [_latestMajor, latestMinor, latestPatch] = filteredNewerVersions[availableMajor].fullVersion.split("."); - if (filteredNewerVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { + const [_latestMajor, latestMinor, latestPatch] = latestSupportedVersions[availableMajor].fullVersion.split("."); + if (latestSupportedVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; continue } @@ -108,11 +106,19 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { if (!shouldUpdate) { process.exit(0); } else { + let ranUpdates = falseƧ const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - console.log(newVersions); - let stdout = ""; - newVersions.map((version) => { - + newVersions.map(async (version) => { + if (version.muslBuildExists) { + const { stdout } = await exec(`./update.sh ${version.isSecurityRelease ? "-s" : ""} ${version}`); + ranUpdates = true; + console.log(stdout); + } else { + console.log(`There's no musl build for version ${version.fullVersion} yet.`); + } }); + if (!ranUpdates) { + process.exit(0); + } } })(); From 578e4e06a63376137e2248565d522b29ae0cf5c3 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 18:06:59 -0300 Subject: [PATCH 08/79] comment ranUpdates logic --- build-automation.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build-automation.js b/build-automation.js index 8ea5c9e3ac..21c91213b3 100644 --- a/build-automation.js +++ b/build-automation.js @@ -106,19 +106,19 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { if (!shouldUpdate) { process.exit(0); } else { - let ranUpdates = falseƧ + // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - newVersions.map(async (version) => { + Object.keys(newVersions).map(async (version) => { if (version.muslBuildExists) { const { stdout } = await exec(`./update.sh ${version.isSecurityRelease ? "-s" : ""} ${version}`); - ranUpdates = true; + // ranUpdates = true; console.log(stdout); } else { console.log(`There's no musl build for version ${version.fullVersion} yet.`); } }); - if (!ranUpdates) { - process.exit(0); - } + // if (!ranUpdates) { + // process.exit(0); + // } } })(); From 8c80519dfd1f3d8a1a76719afea012c62fdd94ae Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 18:09:09 -0300 Subject: [PATCH 09/79] replace map by for..of --- build-automation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-automation.js b/build-automation.js index 21c91213b3..4bb59d0daf 100644 --- a/build-automation.js +++ b/build-automation.js @@ -108,7 +108,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - Object.keys(newVersions).map(async (version) => { + for (let version of newVersions) { if (version.muslBuildExists) { const { stdout } = await exec(`./update.sh ${version.isSecurityRelease ? "-s" : ""} ${version}`); // ranUpdates = true; @@ -116,7 +116,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { console.log(`There's no musl build for version ${version.fullVersion} yet.`); } - }); + }; // if (!ranUpdates) { // process.exit(0); // } From 926b1a69b1bfb091f57313be235c1039e5ece8a0 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 18:09:54 -0300 Subject: [PATCH 10/79] for..of newVersions Object.keys --- build-automation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.js b/build-automation.js index 4bb59d0daf..91a9edd544 100644 --- a/build-automation.js +++ b/build-automation.js @@ -108,7 +108,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - for (let version of newVersions) { + for (let version of Object.keys(newVersions)) { if (version.muslBuildExists) { const { stdout } = await exec(`./update.sh ${version.isSecurityRelease ? "-s" : ""} ${version}`); // ranUpdates = true; From 4f6c62e48861b8ab68610d438dfca14ac6fc8b21 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 23 Feb 2022 18:11:28 -0300 Subject: [PATCH 11/79] revert logic changes --- build-automation.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build-automation.js b/build-automation.js index 91a9edd544..74772bf1ee 100644 --- a/build-automation.js +++ b/build-automation.js @@ -108,15 +108,15 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - for (let version of Object.keys(newVersions)) { - if (version.muslBuildExists) { - const { stdout } = await exec(`./update.sh ${version.isSecurityRelease ? "-s" : ""} ${version}`); + newVersions.map(version => { + if (newVersions[version].muslBuildExists) { + const { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s" : ""} ${version}`); // ranUpdates = true; console.log(stdout); } else { - console.log(`There's no musl build for version ${version.fullVersion} yet.`); + console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); } - }; + }); // if (!ranUpdates) { // process.exit(0); // } From a28cc65ded3d7d9062658e73214ca9e771fe1a59 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:10:15 -0300 Subject: [PATCH 12/79] testing the automation in github actions --- .github/workflows/automatic-updates.yml | 8 +++++--- build-automation.js | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index a56edb5401..c0c3856ac6 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -1,13 +1,15 @@ name: Automatically update Docker image versions on: - schedule: - - cron: "15 * * * *" + # schedule: + # - cron: "15 * * * *" + pull_request: + types: [ synchronize ] jobs: build: runs-on: ubuntu-latest - if: github.repository_owner == 'nodejs' + # if: github.repository_owner == 'nodejs' steps: - uses: actions/checkout@v2 diff --git a/build-automation.js b/build-automation.js index 74772bf1ee..770c9c47f5 100644 --- a/build-automation.js +++ b/build-automation.js @@ -4,6 +4,16 @@ const exec = util.promisify(require("child_process").exec); const https = require("https"); +const mapSeries = (arr) => { + const length = arr.length; + const results = new Array(length); + + arr.reduce((chain, item, i) => { + return chain.then(() => item).then(val => results[i] = val); + }, Promise.resolve()) + .then(() => results); +} + // a function that takes an URL as argument and makes a request to that URL // returning the response as a promise const request = (url) => { @@ -37,7 +47,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec(". functions.sh && get_versions ."); + const { stdout: versionsOutput } = await exec("source ./functions.sh && get_versions ."); const supportedVersions = versionsOutput.trim().split(" "); @@ -49,7 +59,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - const { stdout: fullVersionOutput } = await exec(`. functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); + const { stdout: fullVersionOutput } = await exec(`source ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } @@ -108,15 +118,17 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } else { // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - newVersions.map(version => { + mapSeries(Object.keys(newVersions).map(async version => { if (newVersions[version].muslBuildExists) { - const { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s" : ""} ${version}`); + let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); // ranUpdates = true; console.log(stdout); + stdout = (await exec(`git diff`)).stdout; + console.log(stdout); } else { console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); } - }); + })); // if (!ranUpdates) { // process.exit(0); // } From 92c29cdf59674e0f2fb301e6b40c812c11a81c5e Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:12:03 -0300 Subject: [PATCH 13/79] replace source with . --- build-automation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-automation.js b/build-automation.js index 770c9c47f5..668681b3e6 100644 --- a/build-automation.js +++ b/build-automation.js @@ -47,7 +47,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec("source ./functions.sh && get_versions ."); + const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions ."); const supportedVersions = versionsOutput.trim().split(" "); @@ -59,7 +59,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - const { stdout: fullVersionOutput } = await exec(`source ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); + const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } From c5333a72d66fbdf266ad8bba6f7eb88a2032ce7f Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:34:48 -0300 Subject: [PATCH 14/79] set -ue --- build-automation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-automation.js b/build-automation.js index 668681b3e6..382be0d7bc 100644 --- a/build-automation.js +++ b/build-automation.js @@ -47,7 +47,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions ."); + const { stdout: versionsOutput } = await exec("set -ue && . ./functions.sh && get_versions ."); const supportedVersions = versionsOutput.trim().split(" "); @@ -59,7 +59,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); + const { stdout: fullVersionOutput } = await exec(`set -ue && . ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } From 029d93cbea0b28f991cc6a787e2ed38387b58a58 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:37:34 -0300 Subject: [PATCH 15/79] use bash as shell --- build-automation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-automation.js b/build-automation.js index 382be0d7bc..99ca8809f5 100644 --- a/build-automation.js +++ b/build-automation.js @@ -47,7 +47,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec("set -ue && . ./functions.sh && get_versions ."); + const { stdout: versionsOutput } = await exec("set -ue && . ./functions.sh && get_versions .", { shell: "bash" }); const supportedVersions = versionsOutput.trim().split(" "); @@ -59,7 +59,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - const { stdout: fullVersionOutput } = await exec(`set -ue && . ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`); + const { stdout: fullVersionOutput } = await exec(`set -ue && . ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`, { shell: "bash" }); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } From 56bd0cb50f467ef5cb2652b570e7e271dc817714 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:38:50 -0300 Subject: [PATCH 16/79] stop using set -ue --- build-automation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-automation.js b/build-automation.js index 99ca8809f5..083bce7d8e 100644 --- a/build-automation.js +++ b/build-automation.js @@ -47,7 +47,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec("set -ue && . ./functions.sh && get_versions .", { shell: "bash" }); + const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions .", { shell: "bash" }); const supportedVersions = versionsOutput.trim().split(" "); @@ -59,7 +59,7 @@ const checkIfThereAreNewVersions = async () => { for (let supportedVersion of supportedVersions) { lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; - const { stdout: fullVersionOutput } = await exec(`set -ue && . ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`, { shell: "bash" }); + const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`, { shell: "bash" }); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } From e823a9d58a426988f3f550baba5f744749d4b0ac Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 24 Feb 2022 12:39:57 -0300 Subject: [PATCH 17/79] debug --- build-automation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build-automation.js b/build-automation.js index 083bce7d8e..2f782f4da5 100644 --- a/build-automation.js +++ b/build-automation.js @@ -113,6 +113,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { // if there are no new versions, exit gracefully (async () => { const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); + console.log("debug"); if (!shouldUpdate) { process.exit(0); } else { From d27ea05b43cf78fded8a59a284d2f782a47bb370 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 13:48:02 -0300 Subject: [PATCH 18/79] debug --- build-automation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-automation.js b/build-automation.js index 2f782f4da5..64d961e9b4 100644 --- a/build-automation.js +++ b/build-automation.js @@ -113,8 +113,9 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { // if there are no new versions, exit gracefully (async () => { const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); - console.log("debug"); + console.log(versions); if (!shouldUpdate) { + console.log("No new versions found. No update required."); process.exit(0); } else { // let ranUpdates = false; From 7693e81125fb20e71ca33b2a10f14d7f80cf9e43 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 13:52:42 -0300 Subject: [PATCH 19/79] debug --- build-automation.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build-automation.js b/build-automation.js index 64d961e9b4..a5fb309735 100644 --- a/build-automation.js +++ b/build-automation.js @@ -7,7 +7,7 @@ const https = require("https"); const mapSeries = (arr) => { const length = arr.length; const results = new Array(length); - + arr.reduce((chain, item, i) => { return chain.then(() => item).then(val => results[i] = val); }, Promise.resolve()) @@ -47,8 +47,10 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); const nodeWebsiteText = nodeWebsite.toString(); - const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions .", { shell: "bash" }); + const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); + console.log(versionsOutput); + const supportedVersions = versionsOutput.trim().split(" "); const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); @@ -61,6 +63,8 @@ const checkIfThereAreNewVersions = async () => { const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`, { shell: "bash" }); + console.log(fullVersionOutput); + latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } @@ -83,7 +87,7 @@ const checkIfThereAreNewVersions = async () => { } return { - shouldUpdate: JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions), + shouldUpdate: Object.keys(filteredNewerVersions).length > 0 && JSON.stringify(filteredNewerVersions) !== JSON.stringify(latestSupportedVersions), versions: filteredNewerVersions, } } catch (error) { From d36225608b20a4bc0cd0f3a2349ed74ea428e2a6 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 13:56:21 -0300 Subject: [PATCH 20/79] more debug --- .github/workflows/automatic-updates.yml | 2 +- build-automation.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index c0c3856ac6..0a4994f861 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -4,7 +4,7 @@ on: # schedule: # - cron: "15 * * * *" pull_request: - types: [ synchronize ] + types: [ opened, synchronize ] jobs: build: diff --git a/build-automation.js b/build-automation.js index a5fb309735..111e2b87e4 100644 --- a/build-automation.js +++ b/build-automation.js @@ -48,9 +48,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsiteText = nodeWebsite.toString(); const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); - - console.log(versionsOutput); - + const supportedVersions = versionsOutput.trim().split(" "); const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); From ebd3737cd50cb43435ff80d2af45c567c850b766 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 13:57:46 -0300 Subject: [PATCH 21/79] not running actions on the official repo for now --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 0a4994f861..5ec7bee96a 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -9,7 +9,7 @@ on: jobs: build: runs-on: ubuntu-latest - # if: github.repository_owner == 'nodejs' + if: github.repository_owner != 'nodejs' steps: - uses: actions/checkout@v2 From 81293c6842b8a7647f1da94698013df97530d9ad Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:14:27 -0300 Subject: [PATCH 22/79] test PR creation --- .github/workflows/automatic-updates.yml | 12 ++++++++++++ build-automation.js | 9 +++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 5ec7bee96a..b53a90e497 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -21,6 +21,18 @@ jobs: - name: Run automation script run: node ./build-automation.js + - name: Create update PR + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GH_API_TOKEN }} + branch: update-branch + commit-message: "version update" + title: "Version update" + body: | + @LaurentGoderre @PeterDaveHello @SimenB @Starefossen @nschonni @ttshivers + + + diff --git a/build-automation.js b/build-automation.js index 111e2b87e4..75a405e3a5 100644 --- a/build-automation.js +++ b/build-automation.js @@ -113,19 +113,19 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { }; // if there are no new versions, exit gracefully +// if there are new versions, +// check for musl builds +// then run update.sh (async () => { const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); - console.log(versions); if (!shouldUpdate) { console.log("No new versions found. No update required."); process.exit(0); } else { - // let ranUpdates = false; const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); mapSeries(Object.keys(newVersions).map(async version => { if (newVersions[version].muslBuildExists) { let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); - // ranUpdates = true; console.log(stdout); stdout = (await exec(`git diff`)).stdout; console.log(stdout); @@ -133,8 +133,5 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); } })); - // if (!ranUpdates) { - // process.exit(0); - // } } })(); From dd4234a3955af884f8032bd88ef8d33dd40787d0 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:16:01 -0300 Subject: [PATCH 23/79] using main as the base branch for the newly created PR --- .github/workflows/automatic-updates.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index b53a90e497..487e16d3f0 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + ref: main - uses: actions/setup-node@v2 with: From 86601f7971e3d76d74b9eedf6282f3c5aad61c8d Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:26:24 -0300 Subject: [PATCH 24/79] fallback value for base branch --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 487e16d3f0..8aaf48519c 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: main + ref: ${{ github.base_ref || "main" }} - uses: actions/setup-node@v2 with: From 35aa688a2274857079ce863033d3eeefb6946c73 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:28:25 -0300 Subject: [PATCH 25/79] using single quotes for fallback value --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 8aaf48519c..9ae438c47f 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: ${{ github.base_ref || "main" }} + ref: ${{ github.base_ref || 'main' }} - uses: actions/setup-node@v2 with: From df651830a1a58983654173d661a32116a8c4fb49 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:33:15 -0300 Subject: [PATCH 26/79] github ref name --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 9ae438c47f..64ec25969e 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: ${{ github.base_ref || 'main' }} + ref: ${{ env.GITHUB_REF_NANE || (env.GITHUB_BASE_REF || 'main') }} - uses: actions/setup-node@v2 with: From 518565079f7e298246b00da84e1f50330240fac5 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:35:11 -0300 Subject: [PATCH 27/79] ref_name typo --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 64ec25969e..b096fcb4d0 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: ${{ env.GITHUB_REF_NANE || (env.GITHUB_BASE_REF || 'main') }} + ref: ${{ env.GITHUB_REF_NAME || (env.GITHUB_BASE_REF || 'main') }} - uses: actions/setup-node@v2 with: From 67137ce1067218eff94e1eb5e63e8f398853a15d Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:37:54 -0300 Subject: [PATCH 28/79] using pull request head ref for testing the action --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index b096fcb4d0..5b10b98ca3 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: ${{ env.GITHUB_REF_NAME || (env.GITHUB_BASE_REF || 'main') }} + ref: ${{ github.event.pull_request.head.ref || 'main') }} - uses: actions/setup-node@v2 with: From 87538058fa59a47d57bbb781ce6d1f63719fccf9 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:38:19 -0300 Subject: [PATCH 29/79] fix typo --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 5b10b98ca3..2b8e386bfa 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: ${{ github.event.pull_request.head.ref || 'main') }} + ref: ${{ github.event.pull_request.head.ref || 'main' }} - uses: actions/setup-node@v2 with: From ad1eabddfdd7d5cc4ed7503489dd37ea2111caa8 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:52:39 -0300 Subject: [PATCH 30/79] testing check suite pass --- .github/workflows/automatic-updates.yml | 10 +++------- .../workflows/automatically-merge-updates.yml | 17 +++++++++++++++++ build-automation.js | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/automatically-merge-updates.yml diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 2b8e386bfa..1e0a57e4be 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -1,10 +1,8 @@ name: Automatically update Docker image versions on: - # schedule: - # - cron: "15 * * * *" - pull_request: - types: [ opened, synchronize ] + schedule: + - cron: "15 * * * *" jobs: build: @@ -13,8 +11,6 @@ jobs: steps: - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref || 'main' }} - uses: actions/setup-node@v2 with: @@ -32,7 +28,7 @@ jobs: title: "Version update" body: | @LaurentGoderre @PeterDaveHello @SimenB @Starefossen @nschonni @ttshivers - + diff --git a/.github/workflows/automatically-merge-updates.yml b/.github/workflows/automatically-merge-updates.yml new file mode 100644 index 0000000000..9950c834c0 --- /dev/null +++ b/.github/workflows/automatically-merge-updates.yml @@ -0,0 +1,17 @@ +name: Automatically merge version update PRs + +on: + check_suite: + types: [ completed ] + branches: [ update-branch ] + +jobs: + build: + runs-on: ubuntu-latest + if: github.repository_owner != 'nodejs' + + steps: + - run: | + echo "Completed the checks" + exit 1 + diff --git a/build-automation.js b/build-automation.js index 75a405e3a5..224737161d 100644 --- a/build-automation.js +++ b/build-automation.js @@ -48,7 +48,7 @@ const checkIfThereAreNewVersions = async () => { const nodeWebsiteText = nodeWebsite.toString(); const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); - + const supportedVersions = versionsOutput.trim().split(" "); const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); From 1cc6a5b9736034959a523c70a80057ee028f5ed9 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 27 Feb 2022 14:56:20 -0300 Subject: [PATCH 31/79] prevent cron from running for now --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 1e0a57e4be..ebcd1d7cb1 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -7,7 +7,7 @@ on: jobs: build: runs-on: ubuntu-latest - if: github.repository_owner != 'nodejs' + if: github.repository_owner == 'iasuhiu3hdiuwdhiuwhqfs' steps: - uses: actions/checkout@v2 From 1b5da142bc3724a6a44522df759de5e7ad6e3659 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Mon, 28 Feb 2022 10:36:27 -0300 Subject: [PATCH 32/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ebcd1d7cb1..8d5cf76501 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -2,7 +2,7 @@ name: Automatically update Docker image versions on: schedule: - - cron: "15 * * * *" + - cron: "*/15 * * * *" jobs: build: From b912711a4523988e78b3661e242d3b73edb53821 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 19:10:56 -0300 Subject: [PATCH 33/79] apply changes asked by SimenB --- .github/workflows/automatic-updates.yml | 12 ++++++---- build-automation.js | 31 +++---------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ebcd1d7cb1..3635edeb79 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -12,12 +12,12 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: - node-version: 'lts/*' + node-version: '17' - name: Run automation script - run: node ./build-automation.js + run: node --experimental-fetch ./build-automation.js - name: Create update PR uses: peter-evans/create-pull-request@v3 @@ -26,8 +26,10 @@ jobs: branch: update-branch commit-message: "version update" title: "Version update" - body: | - @LaurentGoderre @PeterDaveHello @SimenB @Starefossen @nschonni @ttshivers + delete-branch: "true" + team-reviewers: | + owners + maintainers diff --git a/build-automation.js b/build-automation.js index 224737161d..53d9e84a21 100644 --- a/build-automation.js +++ b/build-automation.js @@ -14,37 +14,12 @@ const mapSeries = (arr) => { .then(() => results); } -// a function that takes an URL as argument and makes a request to that URL -// returning the response as a promise -const request = (url) => { - return new Promise((resolve, reject) => { - https.get(url, async (res) => { - let body = ''; - - if(res.statusCode === 301 || res.statusCode === 302) { - resolve(await request(res.headers.location, resolve, reject)); - } - - res.on('data', (chunk) => { - body += chunk; - }); - res.on('end', () => { - if (res.statusCode < 400) { - resolve(body); - } else { - reject(new Error(`Request failed: ${res.statusCode}`)); - } - }) - }); - }); -}; - // a function that queries the Node.js release website for new versions, // compare the available ones with the ones we use in this repo // and returns whether we should update or not const checkIfThereAreNewVersions = async () => { try { - const nodeWebsite = await request('https://nodejs.org/en/download/releases/'); + const nodeWebsite = await (await fetch('https://nodejs.org/en/download/releases/')).text(); const nodeWebsiteText = nodeWebsite.toString(); const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); @@ -97,11 +72,11 @@ const checkIfThereAreNewVersions = async () => { // and returns relevant information const checkForMuslVersionsAndSecurityReleases = async (versions) => { try { - let unofficialBuildsIndexText = JSON.parse(await request('https://unofficial-builds.nodejs.org/download/release/index.json')); + let unofficialBuildsIndexText = await (await fetch('https://unofficial-builds.nodejs.org/download/release/index.json')).json(); let unofficialBuildsWebsiteText = ""; for (let version of Object.keys(versions)) { - unofficialBuildsWebsiteText = await request(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`); + unofficialBuildsWebsiteText = await (await fetch(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`)).text(); versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); versions[version].isSecurityRelease = unofficialBuildsIndexText.find(indexVersion => indexVersion.version === `v${versions[version].fullVersion}`)?.security; From 8e0e021775d55c70446ebfc6db7f0ea8a4b23155 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 19:38:49 -0300 Subject: [PATCH 34/79] trigger pr synchronize --- .github/workflows/automatic-updates.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index d355ddacde..20157b7b12 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -1,13 +1,15 @@ name: Automatically update Docker image versions on: - schedule: - - cron: "*/15 * * * *" + # schedule: + # - cron: "*/15 * * * *" + pull_request: + types: [ synchronize, opened, reopened, edited ] jobs: build: runs-on: ubuntu-latest - if: github.repository_owner == 'iasuhiu3hdiuwdhiuwhqfs' + if: github.repository_owner != 'nodejs' steps: - uses: actions/checkout@v2 @@ -17,7 +19,7 @@ jobs: node-version: '17' - name: Run automation script - run: node --experimental-fetch ./build-automation.js + run: node --experimental-fetch build-automation.js - name: Create update PR uses: peter-evans/create-pull-request@v3 From f21ad7841ca5d4d3c5c49b33e20a2cd97ec7bd88 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 19:51:18 -0300 Subject: [PATCH 35/79] removes mapSeries --- build-automation.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/build-automation.js b/build-automation.js index 53d9e84a21..4e16db7abc 100644 --- a/build-automation.js +++ b/build-automation.js @@ -2,18 +2,6 @@ const util = require("util") const exec = util.promisify(require("child_process").exec); -const https = require("https"); - -const mapSeries = (arr) => { - const length = arr.length; - const results = new Array(length); - - arr.reduce((chain, item, i) => { - return chain.then(() => item).then(val => results[i] = val); - }, Promise.resolve()) - .then(() => results); -} - // a function that queries the Node.js release website for new versions, // compare the available ones with the ones we use in this repo // and returns whether we should update or not @@ -98,15 +86,15 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { process.exit(0); } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - mapSeries(Object.keys(newVersions).map(async version => { + for(let version of newVersions) { if (newVersions[version].muslBuildExists) { let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); console.log(stdout); - stdout = (await exec(`git diff`)).stdout; - console.log(stdout); } else { console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); } - })); + }; + let stdout = (await exec(`git diff`)).stdout; + console.log(stdout); } })(); From 18c71d08661c4f3ef385bebeec7106003e91701a Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 19:53:02 -0300 Subject: [PATCH 36/79] for..of with actually iterable object --- build-automation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.js b/build-automation.js index 4e16db7abc..f6b0962f9d 100644 --- a/build-automation.js +++ b/build-automation.js @@ -86,7 +86,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { process.exit(0); } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - for(let version of newVersions) { + for(let version of Object.keys(newVersions)) { if (newVersions[version].muslBuildExists) { let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); console.log(stdout); From c18b65b3bff83b8a0d98e0702842212293b63cf3 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 20:00:18 -0300 Subject: [PATCH 37/79] using main branch as base to the generated PR --- .github/workflows/automatic-updates.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 20157b7b12..9e00473021 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -26,6 +26,7 @@ jobs: with: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch + base: main commit-message: "version update" title: "Version update" delete-branch: "true" From dafff87d6ba7361bce3de85e85cdb744ad6bea17 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 20:07:20 -0300 Subject: [PATCH 38/79] head_branch option --- .github/workflows/automatically-merge-updates.yml | 2 +- build-automation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatically-merge-updates.yml b/.github/workflows/automatically-merge-updates.yml index 9950c834c0..af3a8e7ce6 100644 --- a/.github/workflows/automatically-merge-updates.yml +++ b/.github/workflows/automatically-merge-updates.yml @@ -3,7 +3,7 @@ name: Automatically merge version update PRs on: check_suite: types: [ completed ] - branches: [ update-branch ] + head_branch: update-branch jobs: build: diff --git a/build-automation.js b/build-automation.js index f6b0962f9d..4d1529c1eb 100644 --- a/build-automation.js +++ b/build-automation.js @@ -82,7 +82,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { (async () => { const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); if (!shouldUpdate) { - console.log("No new versions found. No update required."); + console.log("No new versions found. No update required for now."); process.exit(0); } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); From c0953d9b1a61fc7635e34eedb55154b9544e1616 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Mon, 28 Feb 2022 23:13:18 -0300 Subject: [PATCH 39/79] check_suite event without arguments --- .github/workflows/automatically-merge-updates.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automatically-merge-updates.yml b/.github/workflows/automatically-merge-updates.yml index af3a8e7ce6..6a1c2d6fbb 100644 --- a/.github/workflows/automatically-merge-updates.yml +++ b/.github/workflows/automatically-merge-updates.yml @@ -3,7 +3,6 @@ name: Automatically merge version update PRs on: check_suite: types: [ completed ] - head_branch: update-branch jobs: build: From 759a0f4ecd0c5210451e408bc48d7ed1a9033340 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 11:41:58 -0300 Subject: [PATCH 40/79] testing auto-merge --- .github/workflows/automatic-updates.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 9e00473021..ce0a87f54d 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -22,11 +22,12 @@ jobs: run: node --experimental-fetch build-automation.js - name: Create update PR + id: cpr uses: peter-evans/create-pull-request@v3 with: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch - base: main + base: test-branch commit-message: "version update" title: "Version update" delete-branch: "true" @@ -34,6 +35,11 @@ jobs: owners maintainers + - name: Auto-merge PR when ready + uses: peter-evans/enable-pull-request-automerge@v1 + with: + token: ${{ secrets.GH_API_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} From 224047014dfb3b2b94d64526d649635bedd2d0a5 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 11:58:37 -0300 Subject: [PATCH 41/79] triggering action --- build-automation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.js b/build-automation.js index 4d1529c1eb..f6b0962f9d 100644 --- a/build-automation.js +++ b/build-automation.js @@ -82,7 +82,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { (async () => { const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); if (!shouldUpdate) { - console.log("No new versions found. No update required for now."); + console.log("No new versions found. No update required."); process.exit(0); } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); From ee8b9e9333848af0c6a357ec3191d764c09353c6 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 12:06:34 -0300 Subject: [PATCH 42/79] add a simple sleep --- .github/workflows/automatic-updates.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ce0a87f54d..39bc17701f 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,6 +35,9 @@ jobs: owners maintainers + - name: Wait 2 seconds + run: sleep 2 + - name: Auto-merge PR when ready uses: peter-evans/enable-pull-request-automerge@v1 with: From b2eec255bb41a946b1867276d3ae9013c70e033c Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 12:10:47 -0300 Subject: [PATCH 43/79] wait 1 sec --- .github/workflows/automatic-updates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 39bc17701f..26e352fe8e 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,8 +35,8 @@ jobs: owners maintainers - - name: Wait 2 seconds - run: sleep 2 + - name: Wait 1 second + run: sleep 1 - name: Auto-merge PR when ready uses: peter-evans/enable-pull-request-automerge@v1 From 1d8bfcdd4701647dbf3682fb26840c50541b310f Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 12:26:39 -0300 Subject: [PATCH 44/79] wait 2 seconds --- .github/workflows/automatic-updates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 26e352fe8e..d135441011 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,8 +35,8 @@ jobs: owners maintainers - - name: Wait 1 second - run: sleep 1 + - name: Wait 2 second + run: sleep 2 - name: Auto-merge PR when ready uses: peter-evans/enable-pull-request-automerge@v1 From dc117dfef5f688b032f581a75a46b93ed8af927a Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 12:28:35 -0300 Subject: [PATCH 45/79] wait 10 seconds --- .github/workflows/automatic-updates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index d135441011..ad59953908 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,8 +35,8 @@ jobs: owners maintainers - - name: Wait 2 second - run: sleep 2 + - name: Wait 10 seconds + run: sleep 10 - name: Auto-merge PR when ready uses: peter-evans/enable-pull-request-automerge@v1 From e35cab7d536f847b67e66ec2455f4b572e0eee44 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 13:15:33 -0300 Subject: [PATCH 46/79] create update PR --- .github/workflows/automatic-updates.yml | 18 ++++++++------- check-pr-status.js | 30 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 check-pr-status.js diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ad59953908..43fc794ba5 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,14 +35,16 @@ jobs: owners maintainers - - name: Wait 10 seconds - run: sleep 10 - - - name: Auto-merge PR when ready - uses: peter-evans/enable-pull-request-automerge@v1 - with: - token: ${{ secrets.GH_API_TOKEN }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + # - name: Check CI status periodically + # env: + # GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} + # run: node --experimental-fetch check-pr-status.js + + # - name: Auto-merge PR when ready + # uses: peter-evans/enable-pull-request-automerge@v1 + # with: + # token: ${{ secrets.GH_API_TOKEN }} + # pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} diff --git a/check-pr-status.js b/check-pr-status.js new file mode 100644 index 0000000000..fb301175b8 --- /dev/null +++ b/check-pr-status.js @@ -0,0 +1,30 @@ +// fetch /repos/{owner}/{repo}/pulls/{pull_number} +// and check if the status checks of a pull request are all green +// if so, exit with status code 0 +// else exit with error +(async () => { + const [owner, repo, pull_number] = process.argv.slice(2); + + const response = await (await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`)).json(); + + console.log(response); + + // const { data: pullRequest } = await octokit.pulls.get({ + // owner, + // repo, + // pull_number, + // }); + // const { data: statusChecks } = await octokit.checks.listForRef({ + // owner, + // repo, + // ref: pullRequest.head.sha, + // }); + // const statusChecksPassed = statusChecks.check_runs.every( + // (check) => check.conclusion === "success" + // ); + // if (statusChecksPassed) { + // process.exit(0); + // } else { + // process.exit(1); + // } +})(); From 06e3eeaaae0a6cfb0cc02fe3bcffcc0064afb921 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 13:32:26 -0300 Subject: [PATCH 47/79] changing base branch --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 43fc794ba5..5308a1027b 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -27,7 +27,7 @@ jobs: with: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch - base: test-branch + base: main commit-message: "version update" title: "Version update" delete-branch: "true" From 1550ccb64dc296dbd22bd847ffadf6806698a918 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 14:39:34 -0300 Subject: [PATCH 48/79] testing auto-merge in test-branch-main --- .github/workflows/automatic-updates.yml | 24 +++++++------- check-pr-status.js | 42 +++++++++++-------------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 5308a1027b..46b2ff966e 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -27,7 +27,7 @@ jobs: with: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch - base: main + base: test-branch-main commit-message: "version update" title: "Version update" delete-branch: "true" @@ -35,19 +35,17 @@ jobs: owners maintainers - # - name: Check CI status periodically - # env: - # GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} - # run: node --experimental-fetch check-pr-status.js - - # - name: Auto-merge PR when ready - # uses: peter-evans/enable-pull-request-automerge@v1 - # with: - # token: ${{ secrets.GH_API_TOKEN }} - # pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} - - + - name: Check CI status periodically + env: + GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} + run: node --experimental-fetch check-pr-status.js + - name: Merge PR + uses: juliangruber/merge-pull-request-action@v1 + with: + github-token: ${{ secrets.GH_API_TOKEN }} + number: ${{ steps.cpr.outputs.pull-request-number }} + method: squash diff --git a/check-pr-status.js b/check-pr-status.js index fb301175b8..655ac7b653 100644 --- a/check-pr-status.js +++ b/check-pr-status.js @@ -1,30 +1,26 @@ // fetch /repos/{owner}/{repo}/pulls/{pull_number} -// and check if the status checks of a pull request are all green -// if so, exit with status code 0 +// and check its mergeable_state +// if "clean", exit with status code 0 // else exit with error +const { setTimeout } = require('timers/promises'); + (async () => { - const [owner, repo, pull_number] = process.argv.slice(2); + const retries = 10; + const retryDelay = 10000; - const response = await (await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`)).json(); + for (let tries = 0; tries < retries; tries++) { + try { + const [owner, repo, pull_number] = process.argv.slice(2); - console.log(response); + const data = await (await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`)).json(); - // const { data: pullRequest } = await octokit.pulls.get({ - // owner, - // repo, - // pull_number, - // }); - // const { data: statusChecks } = await octokit.checks.listForRef({ - // owner, - // repo, - // ref: pullRequest.head.sha, - // }); - // const statusChecksPassed = statusChecks.check_runs.every( - // (check) => check.conclusion === "success" - // ); - // if (statusChecksPassed) { - // process.exit(0); - // } else { - // process.exit(1); - // } + if (data.mergeable_state === 'clean') { + process.exit(0); + } + setTimeout(retryDelay); + } catch (error) { + process.exit(1); + } + } + process.exit(1); })(); From 41358c89ea8b138d0458ff6ad30e9f54e4990c87 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 14:45:30 -0300 Subject: [PATCH 49/79] checkout again once the PR is created --- .github/workflows/automatic-updates.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 46b2ff966e..6f37515d96 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -35,6 +35,8 @@ jobs: owners maintainers + - uses: actions/checkout@v2 + - name: Check CI status periodically env: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} From a3a2835cd7dc49b96d375a66c42731595bfe761a Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 14:47:47 -0300 Subject: [PATCH 50/79] await setTimeout --- check-pr-status.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check-pr-status.js b/check-pr-status.js index 655ac7b653..446c0621b3 100644 --- a/check-pr-status.js +++ b/check-pr-status.js @@ -17,8 +17,9 @@ const { setTimeout } = require('timers/promises'); if (data.mergeable_state === 'clean') { process.exit(0); } - setTimeout(retryDelay); + await setTimeout(retryDelay); } catch (error) { + console.log(error); process.exit(1); } } From e6566a7ee2ce3d722d1d10753674c63dc5dd82b5 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 14:56:17 -0300 Subject: [PATCH 51/79] fix arguments --- .github/workflows/automatic-updates.yml | 2 +- check-pr-status.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 6f37515d96..f59090a08c 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -40,7 +40,7 @@ jobs: - name: Check CI status periodically env: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} - run: node --experimental-fetch check-pr-status.js + run: node --experimental-fetch check-pr-status.js ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} - name: Merge PR uses: juliangruber/merge-pull-request-action@v1 diff --git a/check-pr-status.js b/check-pr-status.js index 446c0621b3..f1b4b30d2c 100644 --- a/check-pr-status.js +++ b/check-pr-status.js @@ -6,13 +6,13 @@ const { setTimeout } = require('timers/promises'); (async () => { const retries = 10; - const retryDelay = 10000; + const retryDelay = 20000; for (let tries = 0; tries < retries; tries++) { try { - const [owner, repo, pull_number] = process.argv.slice(2); + const [repo, pull_number] = process.argv.slice(2); - const data = await (await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`)).json(); + const data = await (await fetch(`https://api.github.com/repos/${repo}/pulls/${pull_number}`)).json(); if (data.mergeable_state === 'clean') { process.exit(0); From 3f2a7b907d76abba68424d3125ac9ef33779e194 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 15:02:08 -0300 Subject: [PATCH 52/79] debug --- check-pr-status.js | 1 + 1 file changed, 1 insertion(+) diff --git a/check-pr-status.js b/check-pr-status.js index f1b4b30d2c..c61b3291be 100644 --- a/check-pr-status.js +++ b/check-pr-status.js @@ -14,6 +14,7 @@ const { setTimeout } = require('timers/promises'); const data = await (await fetch(`https://api.github.com/repos/${repo}/pulls/${pull_number}`)).json(); + console.log(data); if (data.mergeable_state === 'clean') { process.exit(0); } From 212e6c5f9d7a544e8c8690200cbf6173826cabfe Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 15:21:22 -0300 Subject: [PATCH 53/79] debug --- .github/workflows/automatic-updates.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index f59090a08c..ceeb2ab958 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -9,7 +9,8 @@ on: jobs: build: runs-on: ubuntu-latest - if: github.repository_owner != 'nodejs' + # if the repo owner isn't nodejs and the branch isn't update-branch + if: github.repository_owner != 'nodejs' && github.ref != 'refs/heads/update-branch' steps: - uses: actions/checkout@v2 From 94d1081a6457a0ee22f39ecbaaf01dbee5338ab5 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 15:35:19 -0300 Subject: [PATCH 54/79] ignoring update branch --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ceeb2ab958..80be161bb9 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest # if the repo owner isn't nodejs and the branch isn't update-branch - if: github.repository_owner != 'nodejs' && github.ref != 'refs/heads/update-branch' + if: github.repository_owner != 'nodejs' && github.event.pull_request.base.ref != 'update-branch' steps: - uses: actions/checkout@v2 From eedf0cbee3e12bdf8c8fe91f0eecc6044d1e7c76 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 15:45:47 -0300 Subject: [PATCH 55/79] debug schedule --- .github/workflows/automatic-updates.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 80be161bb9..b0f101ee88 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -1,16 +1,14 @@ name: Automatically update Docker image versions on: - # schedule: - # - cron: "*/15 * * * *" - pull_request: - types: [ synchronize, opened, reopened, edited ] + schedule: + - cron: "*/48 * * * *" jobs: build: runs-on: ubuntu-latest # if the repo owner isn't nodejs and the branch isn't update-branch - if: github.repository_owner != 'nodejs' && github.event.pull_request.base.ref != 'update-branch' + if: github.repository_owner != 'nodejs' steps: - uses: actions/checkout@v2 From 88d3e3b7cc74bb0fe8dfc6f444de954b1acd8315 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 16:22:59 -0300 Subject: [PATCH 56/79] finish --- .github/workflows/automatic-updates.yml | 6 +++--- check-pr-status.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index b0f101ee88..b620ae3211 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -2,13 +2,13 @@ name: Automatically update Docker image versions on: schedule: - - cron: "*/48 * * * *" + - cron: "*/15 * * * *" jobs: build: runs-on: ubuntu-latest # if the repo owner isn't nodejs and the branch isn't update-branch - if: github.repository_owner != 'nodejs' + if: github.repository_owner == 'nodejs' steps: - uses: actions/checkout@v2 @@ -26,7 +26,7 @@ jobs: with: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch - base: test-branch-main + base: main commit-message: "version update" title: "Version update" delete-branch: "true" diff --git a/check-pr-status.js b/check-pr-status.js index c61b3291be..7d3bbf67ba 100644 --- a/check-pr-status.js +++ b/check-pr-status.js @@ -5,10 +5,12 @@ const { setTimeout } = require('timers/promises'); (async () => { - const retries = 10; - const retryDelay = 20000; + const tries = 10; + const retryDelay = 30000; - for (let tries = 0; tries < retries; tries++) { + await setTimeout(retryDelay); + + for (let t = 0; t < tries; t++) { try { const [repo, pull_number] = process.argv.slice(2); From 01b63ba6c8a78ee53eb77c0114cbec8d253278fd Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 16:27:32 -0300 Subject: [PATCH 57/79] remove PR for updates section from CONTRIBUTING.md --- CONTRIBUTING.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6952d37890..a98969cad5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,17 +10,6 @@ New **NPM** releases are not tracked. We simply use the NPM version bundled in t **Yarn** is updated to the latest version only when there is a new Node.js SemVer PATCH release (unless Yarn has received a security update), and it's updated only in the branch with the new release, preferably in the same PR. The `update.sh` script does this automatically when invoked with a specific branch, e.g. `./update.sh 6.10`. -### Submitting a PR for a version update - -If you'd like to help us by submitting a PR for a version update, please do the following: - -1. [Fork this project.](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) -1. [Clone the forked repository.](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) -1. Create a branch for the update PR. For example, `git checkout main; git checkout -b version-update`. -1. Run `./update.sh`. You can see additional options by using accessing the built-in help documentation with `./update.sh -h`. This script will automatically update the appropriate files with the latest versions and checksums. -1. Commit the modified files to the `version-update` branch and push the branch to your fork. -1. [Create a PR to merge the branch from your fork into this project's default branch.](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork). - ## Adding dependencies to the base images NodeJS is a big ecosystem with a variety of different use cases. The docker images for node are designed to provide the minimum for running core node. Additional dependencies (including dependencies for npm or yarn such as git) will not be included in these base images and will need to be included in descendent image. From ff6c3da74a3d5bc3699cbabfd56d7d14e03e892c Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Wed, 2 Mar 2022 20:21:35 -0300 Subject: [PATCH 58/79] remove unused file --- .../workflows/automatically-merge-updates.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/automatically-merge-updates.yml diff --git a/.github/workflows/automatically-merge-updates.yml b/.github/workflows/automatically-merge-updates.yml deleted file mode 100644 index 6a1c2d6fbb..0000000000 --- a/.github/workflows/automatically-merge-updates.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Automatically merge version update PRs - -on: - check_suite: - types: [ completed ] - -jobs: - build: - runs-on: ubuntu-latest - if: github.repository_owner != 'nodejs' - - steps: - - run: | - echo "Completed the checks" - exit 1 - From d2dacf7ca6cdcc7f91dbfcccec8f3db724a94dad Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 3 Mar 2022 10:10:18 -0300 Subject: [PATCH 59/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index b620ae3211..ca14a4c16c 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -11,7 +11,7 @@ jobs: if: github.repository_owner == 'nodejs' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: From cc73894d5f84ff0bb94eab1e9072d7d951ea61db Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 3 Mar 2022 10:10:26 -0300 Subject: [PATCH 60/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index ca14a4c16c..087aaf1142 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/setup-node@v3 with: + # to access `--experimental-fetch` node-version: '17' - name: Run automation script From 0d254b134653b389a9c8302c2e7ad55e5bb493c8 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 3 Mar 2022 14:28:47 -0300 Subject: [PATCH 61/79] requested changes --- .github/workflows/automatic-updates.yml | 17 +++++--- CONTRIBUTING.md | 11 +++++ build-automation.js => build-automation.mjs | 47 +++++++++++---------- check-pr-status.js | 30 ------------- check-pr-status.mjs | 28 ++++++++++++ 5 files changed, 73 insertions(+), 60 deletions(-) rename build-automation.js => build-automation.mjs (78%) delete mode 100644 check-pr-status.js create mode 100644 check-pr-status.mjs diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 087aaf1142..72d30b6f00 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -7,7 +7,6 @@ on: jobs: build: runs-on: ubuntu-latest - # if the repo owner isn't nodejs and the branch isn't update-branch if: github.repository_owner == 'nodejs' steps: @@ -19,7 +18,12 @@ jobs: node-version: '17' - name: Run automation script - run: node --experimental-fetch build-automation.js + run: node --experimental-fetch build-automation.mjs + + - name: Get updated versions from updated_versions file and store in env vars + run: | + [ -f updated_versions ] && echo "UPDATED_VERSIONS=$(cat updated_versions)" >> GITHUB_ENV + rm -f updated_versions - name: Create update PR id: cpr @@ -28,19 +32,18 @@ jobs: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch base: main - commit-message: "version update" - title: "Version update" + commit-message: "Update to $UPDATED_VERSIONS" + title: "Update to $UPDATED_VERSIONS" delete-branch: "true" team-reviewers: | - owners - maintainers + @nodejs/docker - uses: actions/checkout@v2 - name: Check CI status periodically env: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} - run: node --experimental-fetch check-pr-status.js ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} + run: node --experimental-fetch check-pr-status.mjs ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} - name: Merge PR uses: juliangruber/merge-pull-request-action@v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a98969cad5..6952d37890 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,17 @@ New **NPM** releases are not tracked. We simply use the NPM version bundled in t **Yarn** is updated to the latest version only when there is a new Node.js SemVer PATCH release (unless Yarn has received a security update), and it's updated only in the branch with the new release, preferably in the same PR. The `update.sh` script does this automatically when invoked with a specific branch, e.g. `./update.sh 6.10`. +### Submitting a PR for a version update + +If you'd like to help us by submitting a PR for a version update, please do the following: + +1. [Fork this project.](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) +1. [Clone the forked repository.](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) +1. Create a branch for the update PR. For example, `git checkout main; git checkout -b version-update`. +1. Run `./update.sh`. You can see additional options by using accessing the built-in help documentation with `./update.sh -h`. This script will automatically update the appropriate files with the latest versions and checksums. +1. Commit the modified files to the `version-update` branch and push the branch to your fork. +1. [Create a PR to merge the branch from your fork into this project's default branch.](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork). + ## Adding dependencies to the base images NodeJS is a big ecosystem with a variety of different use cases. The docker images for node are designed to provide the minimum for running core node. Additional dependencies (including dependencies for npm or yarn such as git) will not be included in these base images and will need to be included in descendent image. diff --git a/build-automation.js b/build-automation.mjs similarity index 78% rename from build-automation.js rename to build-automation.mjs index f6b0962f9d..52f60d42fd 100644 --- a/build-automation.js +++ b/build-automation.mjs @@ -1,14 +1,15 @@ -const util = require("util") +import { promisify } from "util"; -const exec = util.promisify(require("child_process").exec); +import child_process from "child_process"; + +const exec = promisify(child_process.exec); // a function that queries the Node.js release website for new versions, // compare the available ones with the ones we use in this repo // and returns whether we should update or not const checkIfThereAreNewVersions = async () => { try { - const nodeWebsite = await (await fetch('https://nodejs.org/en/download/releases/')).text(); - const nodeWebsiteText = nodeWebsite.toString(); + const nodeWebsiteText = await (await fetch('https://nodejs.org/en/download/releases/')).text(); const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); @@ -79,22 +80,22 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { // if there are new versions, // check for musl builds // then run update.sh -(async () => { - const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); - if (!shouldUpdate) { - console.log("No new versions found. No update required."); - process.exit(0); - } else { - const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - for(let version of Object.keys(newVersions)) { - if (newVersions[version].muslBuildExists) { - let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); - console.log(stdout); - } else { - console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); - } - }; - let stdout = (await exec(`git diff`)).stdout; - console.log(stdout); - } -})(); +const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); + +if (!shouldUpdate) { + console.log("No new versions found. No update required."); + process.exit(0); +} else { + const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); + for(let version of Object.keys(newVersions)) { + if (newVersions[version].muslBuildExists) { + let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); + console.log(stdout); + await exec(`echo "${newVersions[version].fullVersion} " >> updated_versions`); + } else { + console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); + } + }; + let stdout = (await exec(`git diff`)).stdout; + console.log(stdout); +} diff --git a/check-pr-status.js b/check-pr-status.js deleted file mode 100644 index 7d3bbf67ba..0000000000 --- a/check-pr-status.js +++ /dev/null @@ -1,30 +0,0 @@ -// fetch /repos/{owner}/{repo}/pulls/{pull_number} -// and check its mergeable_state -// if "clean", exit with status code 0 -// else exit with error -const { setTimeout } = require('timers/promises'); - -(async () => { - const tries = 10; - const retryDelay = 30000; - - await setTimeout(retryDelay); - - for (let t = 0; t < tries; t++) { - try { - const [repo, pull_number] = process.argv.slice(2); - - const data = await (await fetch(`https://api.github.com/repos/${repo}/pulls/${pull_number}`)).json(); - - console.log(data); - if (data.mergeable_state === 'clean') { - process.exit(0); - } - await setTimeout(retryDelay); - } catch (error) { - console.log(error); - process.exit(1); - } - } - process.exit(1); -})(); diff --git a/check-pr-status.mjs b/check-pr-status.mjs new file mode 100644 index 0000000000..98354080d2 --- /dev/null +++ b/check-pr-status.mjs @@ -0,0 +1,28 @@ +// fetch /repos/{owner}/{repo}/pulls/{pull_number} +// and check its mergeable_state +// if "clean", exit with status code 0 +// else exit with error +import { setTimeout } from 'timers/promises'; + +const tries = 10; +const retryDelay = 30000; + +await setTimeout(retryDelay); + +for (let t = 0; t < tries; t++) { + try { + const [repo, pull_number] = process.argv.slice(2); + + const data = await (await fetch(`https://api.github.com/repos/${repo}/pulls/${pull_number}`)).json(); + + console.log(data); + if (data.mergeable_state === 'clean') { + process.exit(0); + } + await setTimeout(retryDelay); + } catch (error) { + console.log(error); + process.exit(1); + } +} +process.exit(1); From 67672076670be7192acdff29df1599c508211cba Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Thu, 3 Mar 2022 14:32:13 -0300 Subject: [PATCH 62/79] requested changes pt 2 --- .github/workflows/automatic-updates.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 72d30b6f00..1125e720c9 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -34,7 +34,7 @@ jobs: base: main commit-message: "Update to $UPDATED_VERSIONS" title: "Update to $UPDATED_VERSIONS" - delete-branch: "true" + delete-branch: true team-reviewers: | @nodejs/docker @@ -51,6 +51,3 @@ jobs: github-token: ${{ secrets.GH_API_TOKEN }} number: ${{ steps.cpr.outputs.pull-request-number }} method: squash - - - From ae95adfa3f6e55fb083dbf5baad6f68f12e9e0bb Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 6 Mar 2022 12:06:27 -0300 Subject: [PATCH 63/79] requested changes pt 3 --- .github/workflows/automatic-updates.yml | 10 +++------ build-automation.mjs | 28 ++++++++++++------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 1125e720c9..562c6b2927 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -18,13 +18,9 @@ jobs: node-version: '17' - name: Run automation script + id: updt run: node --experimental-fetch build-automation.mjs - - name: Get updated versions from updated_versions file and store in env vars - run: | - [ -f updated_versions ] && echo "UPDATED_VERSIONS=$(cat updated_versions)" >> GITHUB_ENV - rm -f updated_versions - - name: Create update PR id: cpr uses: peter-evans/create-pull-request@v3 @@ -32,8 +28,8 @@ jobs: token: ${{ secrets.GH_API_TOKEN }} branch: update-branch base: main - commit-message: "Update to $UPDATED_VERSIONS" - title: "Update to $UPDATED_VERSIONS" + commit-message: "Update to ${{ steps.updt.outputs.updated-versions }}" + title: "Update to ${{ steps.updt.outputs.updated-versions }}" delete-branch: true team-reviewers: | @nodejs/docker diff --git a/build-automation.mjs b/build-automation.mjs index 52f60d42fd..c714aca4a2 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -9,14 +9,10 @@ const exec = promisify(child_process.exec); // and returns whether we should update or not const checkIfThereAreNewVersions = async () => { try { - const nodeWebsiteText = await (await fetch('https://nodejs.org/en/download/releases/')).text(); - const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); const supportedVersions = versionsOutput.trim().split(" "); - const availableVersions = nodeWebsiteText.match(new RegExp("Node\\.js (" + supportedVersions.join('|') + ")\\.\\d+\\.\\d+", "g")); - let lsOutput = ""; let latestSupportedVersions = {}; @@ -30,21 +26,21 @@ const checkIfThereAreNewVersions = async () => { latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } - // filter only more recent versions of availableVersions for each major version in latestSupportedVersions' keys + const availableVersionsJson = await (await fetch('https://nodejs.org/download/release/index.json')).json(); + + // filter only more recent versions of availableVersionsJson for each major version in latestSupportedVersions' keys // e.g. if latestSupportedVersions = { "12": "12.22.10", "14": "14.19.0", "16": "16.14.0", "17": "17.5.0" } // and availableVersions = ["Node.js 12.22.10", "Node.js 12.24.0", "Node.js 14.19.0", "Node.js 14.22.0", "Node.js 16.14.0", "Node.js 16.16.0", "Node.js 17.5.0", "Node.js 17.8.0"] // return { "12": "12.24.0", "14": "14.22.0", "16": "16.16.0", "17": "17.8.0" } let filteredNewerVersions = {}; - for (let availableVersion of availableVersions) { - if (availableVersion.includes("Node.js ")) { - const [availableMajor, availableMinor, availablePatch] = availableVersion.split(" ")[1].split("."); - const [_latestMajor, latestMinor, latestPatch] = latestSupportedVersions[availableMajor].fullVersion.split("."); - if (latestSupportedVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { - filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; - continue - } + for (let availableVersion of availableVersionsJson) { + const [availableMajor, availableMinor, availablePatch] = availableVersion.version.split("v")[1].split("."); + const [_latestMajor, latestMinor, latestPatch] = latestSupportedVersions[availableMajor].fullVersion.split("."); + if (latestSupportedVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { + filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; + continue } } @@ -87,15 +83,17 @@ if (!shouldUpdate) { process.exit(0); } else { const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - for(let version of Object.keys(newVersions)) { + let updatedVersions = []; + for (let version of Object.keys(newVersions)) { if (newVersions[version].muslBuildExists) { let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); console.log(stdout); - await exec(`echo "${newVersions[version].fullVersion} " >> updated_versions`); + updatedVersions.push(newVersions[version].fullVersion); } else { console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); } }; + console.log(`::set-output name=updated-versions::${updatedVersions.join(',')}`); let stdout = (await exec(`git diff`)).stdout; console.log(stdout); } From 4ec8a7fbdd8affc5bdb82b93006aee149c56ddd7 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 17:54:13 -0300 Subject: [PATCH 64/79] Update check-pr-status.mjs Co-authored-by: Simen Bekkhus --- check-pr-status.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-pr-status.mjs b/check-pr-status.mjs index 98354080d2..de7fb73498 100644 --- a/check-pr-status.mjs +++ b/check-pr-status.mjs @@ -21,7 +21,7 @@ for (let t = 0; t < tries; t++) { } await setTimeout(retryDelay); } catch (error) { - console.log(error); + console.error(error); process.exit(1); } } From cbeb27b7377de2de6f5efd00b75df34279856364 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 17:54:22 -0300 Subject: [PATCH 65/79] Update build-automation.mjs Co-authored-by: Simen Bekkhus --- build-automation.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.mjs b/build-automation.mjs index c714aca4a2..7237811a52 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -94,6 +94,6 @@ if (!shouldUpdate) { } }; console.log(`::set-output name=updated-versions::${updatedVersions.join(',')}`); - let stdout = (await exec(`git diff`)).stdout; + const { stdout } = (await exec(`git diff`)); console.log(stdout); } From b6a6b361c51763666e52602bfb0e71b61830452b Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 17:54:33 -0300 Subject: [PATCH 66/79] Update build-automation.mjs Co-authored-by: Simen Bekkhus --- build-automation.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.mjs b/build-automation.mjs index 7237811a52..c1b41e8867 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -86,7 +86,7 @@ if (!shouldUpdate) { let updatedVersions = []; for (let version of Object.keys(newVersions)) { if (newVersions[version].muslBuildExists) { - let { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); + const { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); console.log(stdout); updatedVersions.push(newVersions[version].fullVersion); } else { From 2d8fefa18cec4365c96a1f5b9c2aac266e8d79e5 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 17:54:39 -0300 Subject: [PATCH 67/79] Update build-automation.mjs Co-authored-by: Simen Bekkhus --- build-automation.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.mjs b/build-automation.mjs index c1b41e8867..34c6b2f2ad 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -68,7 +68,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } return versions; } catch (error) { - console.log(error); + console.error(error); } }; From dcb738b200f466ad51e56faca0cb6c1fdbec0554 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 17:54:44 -0300 Subject: [PATCH 68/79] Update build-automation.mjs Co-authored-by: Simen Bekkhus --- build-automation.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-automation.mjs b/build-automation.mjs index 34c6b2f2ad..76e31dfd3d 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -49,7 +49,7 @@ const checkIfThereAreNewVersions = async () => { versions: filteredNewerVersions, } } catch (error) { - console.log(error); + console.error(error); } }; From c5df4438e28960de6efee6b79b55c00dcc94c07f Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 9 Mar 2022 18:02:31 -0300 Subject: [PATCH 69/79] requested changes pt 4 --- .github/workflows/automatic-updates.yml | 2 -- build-automation.mjs | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 562c6b2927..8034035f7b 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -34,8 +34,6 @@ jobs: team-reviewers: | @nodejs/docker - - uses: actions/checkout@v2 - - name: Check CI status periodically env: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} diff --git a/build-automation.mjs b/build-automation.mjs index 76e31dfd3d..e65f67cfee 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -50,6 +50,7 @@ const checkIfThereAreNewVersions = async () => { } } catch (error) { console.error(error); + process.exit(1); } }; @@ -69,6 +70,7 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { return versions; } catch (error) { console.error(error); + process.exit(1); } }; @@ -91,6 +93,7 @@ if (!shouldUpdate) { updatedVersions.push(newVersions[version].fullVersion); } else { console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); + process.exit(0); } }; console.log(`::set-output name=updated-versions::${updatedVersions.join(',')}`); From bc31eb8c0b9a890f73e585d3b6b00d8b6c01bf92 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 10 Mar 2022 09:14:20 +0100 Subject: [PATCH 70/79] chore: move continue statement --- 17/alpine3.14/Dockerfile | 4 ++-- 17/alpine3.15/Dockerfile | 4 ++-- 17/bullseye-slim/Dockerfile | 2 +- 17/bullseye/Dockerfile | 2 +- 17/buster-slim/Dockerfile | 2 +- 17/buster/Dockerfile | 2 +- 17/stretch-slim/Dockerfile | 2 +- 17/stretch/Dockerfile | 2 +- build-automation.mjs | 4 +++- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/17/alpine3.14/Dockerfile b/17/alpine3.14/Dockerfile index 72c6d29059..11c6dfd60e 100644 --- a/17/alpine3.14/Dockerfile +++ b/17/alpine3.14/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.14 -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN addgroup -g 1000 node \ && adduser -u 1000 -G node -s /bin/sh -D node \ @@ -12,7 +12,7 @@ RUN addgroup -g 1000 node \ && case "${alpineArch##*-}" in \ x86_64) \ ARCH='x64' \ - CHECKSUM="8f4f13abbaf553b102984dc68d2d0c66a12084fbb2a211416e1aaedaaf6eae64" \ + CHECKSUM="44f2d648b7bf14d4bc57c4e3372bcf066310d924765be6c7aa3fc993192cbec0" \ ;; \ *) ;; \ esac \ diff --git a/17/alpine3.15/Dockerfile b/17/alpine3.15/Dockerfile index ae897afffd..df57f1f778 100644 --- a/17/alpine3.15/Dockerfile +++ b/17/alpine3.15/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.15 -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN addgroup -g 1000 node \ && adduser -u 1000 -G node -s /bin/sh -D node \ @@ -12,7 +12,7 @@ RUN addgroup -g 1000 node \ && case "${alpineArch##*-}" in \ x86_64) \ ARCH='x64' \ - CHECKSUM="8f4f13abbaf553b102984dc68d2d0c66a12084fbb2a211416e1aaedaaf6eae64" \ + CHECKSUM="44f2d648b7bf14d4bc57c4e3372bcf066310d924765be6c7aa3fc993192cbec0" \ ;; \ *) ;; \ esac \ diff --git a/17/bullseye-slim/Dockerfile b/17/bullseye-slim/Dockerfile index 9e03e196df..bcf0a72e24 100644 --- a/17/bullseye-slim/Dockerfile +++ b/17/bullseye-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:bullseye-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/bullseye/Dockerfile b/17/bullseye/Dockerfile index 9ab43217ef..d3b58120fc 100644 --- a/17/bullseye/Dockerfile +++ b/17/bullseye/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:bullseye RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/buster-slim/Dockerfile b/17/buster-slim/Dockerfile index 7c56d2bedf..de6632fb6c 100644 --- a/17/buster-slim/Dockerfile +++ b/17/buster-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:buster-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/buster/Dockerfile b/17/buster/Dockerfile index af1cc90d64..868c04c2fe 100644 --- a/17/buster/Dockerfile +++ b/17/buster/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:buster RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/stretch-slim/Dockerfile b/17/stretch-slim/Dockerfile index ea14c9a502..e063376794 100644 --- a/17/stretch-slim/Dockerfile +++ b/17/stretch-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:stretch-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/stretch/Dockerfile b/17/stretch/Dockerfile index d3aeddc03b..46e79e2836 100644 --- a/17/stretch/Dockerfile +++ b/17/stretch/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:stretch RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.5.0 +ENV NODE_VERSION 17.7.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/build-automation.mjs b/build-automation.mjs index e65f67cfee..e8760dfdbd 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -37,10 +37,12 @@ const checkIfThereAreNewVersions = async () => { for (let availableVersion of availableVersionsJson) { const [availableMajor, availableMinor, availablePatch] = availableVersion.version.split("v")[1].split("."); + if (latestSupportedVersions[availableMajor] == null) { + continue; + } const [_latestMajor, latestMinor, latestPatch] = latestSupportedVersions[availableMajor].fullVersion.split("."); if (latestSupportedVersions[availableMajor] && (Number(availableMinor) > Number(latestMinor) || (availableMinor === latestMinor && Number(availablePatch) > Number(latestPatch)))) { filteredNewerVersions[availableMajor] = { fullVersion: `${availableMajor}.${availableMinor}.${availablePatch}` }; - continue } } From 9b6d362b547af842b594314eab7a431d67073b2f Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 10 Mar 2022 09:20:58 +0100 Subject: [PATCH 71/79] oops --- 17/alpine3.14/Dockerfile | 4 ++-- 17/alpine3.15/Dockerfile | 4 ++-- 17/bullseye-slim/Dockerfile | 2 +- 17/bullseye/Dockerfile | 2 +- 17/buster-slim/Dockerfile | 2 +- 17/buster/Dockerfile | 2 +- 17/stretch-slim/Dockerfile | 2 +- 17/stretch/Dockerfile | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/17/alpine3.14/Dockerfile b/17/alpine3.14/Dockerfile index 11c6dfd60e..72c6d29059 100644 --- a/17/alpine3.14/Dockerfile +++ b/17/alpine3.14/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.14 -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN addgroup -g 1000 node \ && adduser -u 1000 -G node -s /bin/sh -D node \ @@ -12,7 +12,7 @@ RUN addgroup -g 1000 node \ && case "${alpineArch##*-}" in \ x86_64) \ ARCH='x64' \ - CHECKSUM="44f2d648b7bf14d4bc57c4e3372bcf066310d924765be6c7aa3fc993192cbec0" \ + CHECKSUM="8f4f13abbaf553b102984dc68d2d0c66a12084fbb2a211416e1aaedaaf6eae64" \ ;; \ *) ;; \ esac \ diff --git a/17/alpine3.15/Dockerfile b/17/alpine3.15/Dockerfile index df57f1f778..ae897afffd 100644 --- a/17/alpine3.15/Dockerfile +++ b/17/alpine3.15/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.15 -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN addgroup -g 1000 node \ && adduser -u 1000 -G node -s /bin/sh -D node \ @@ -12,7 +12,7 @@ RUN addgroup -g 1000 node \ && case "${alpineArch##*-}" in \ x86_64) \ ARCH='x64' \ - CHECKSUM="44f2d648b7bf14d4bc57c4e3372bcf066310d924765be6c7aa3fc993192cbec0" \ + CHECKSUM="8f4f13abbaf553b102984dc68d2d0c66a12084fbb2a211416e1aaedaaf6eae64" \ ;; \ *) ;; \ esac \ diff --git a/17/bullseye-slim/Dockerfile b/17/bullseye-slim/Dockerfile index bcf0a72e24..9e03e196df 100644 --- a/17/bullseye-slim/Dockerfile +++ b/17/bullseye-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:bullseye-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/bullseye/Dockerfile b/17/bullseye/Dockerfile index d3b58120fc..9ab43217ef 100644 --- a/17/bullseye/Dockerfile +++ b/17/bullseye/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:bullseye RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/buster-slim/Dockerfile b/17/buster-slim/Dockerfile index de6632fb6c..7c56d2bedf 100644 --- a/17/buster-slim/Dockerfile +++ b/17/buster-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:buster-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/buster/Dockerfile b/17/buster/Dockerfile index 868c04c2fe..af1cc90d64 100644 --- a/17/buster/Dockerfile +++ b/17/buster/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:buster RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/stretch-slim/Dockerfile b/17/stretch-slim/Dockerfile index e063376794..ea14c9a502 100644 --- a/17/stretch-slim/Dockerfile +++ b/17/stretch-slim/Dockerfile @@ -3,7 +3,7 @@ FROM debian:stretch-slim RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ diff --git a/17/stretch/Dockerfile b/17/stretch/Dockerfile index 46e79e2836..d3aeddc03b 100644 --- a/17/stretch/Dockerfile +++ b/17/stretch/Dockerfile @@ -3,7 +3,7 @@ FROM buildpack-deps:stretch RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -ENV NODE_VERSION 17.7.0 +ENV NODE_VERSION 17.5.0 RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \ && case "${dpkgArch##*-}" in \ From 9e8edb9d6c8b18a22a5e2b2f3725ed307ca64090 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 10 Mar 2022 08:50:50 -0300 Subject: [PATCH 72/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 8034035f7b..484a0e8346 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -44,4 +44,3 @@ jobs: with: github-token: ${{ secrets.GH_API_TOKEN }} number: ${{ steps.cpr.outputs.pull-request-number }} - method: squash From a470faa104538f5f7887eab8c37f861c089776b7 Mon Sep 17 00:00:00 2001 From: Pehesi97 Date: Thu, 10 Mar 2022 09:30:33 -0300 Subject: [PATCH 73/79] auto approve PR when checks pass --- .github/workflows/automatic-updates.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 484a0e8346..8d8086cbe8 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -39,6 +39,11 @@ jobs: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} run: node --experimental-fetch check-pr-status.mjs ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} + - uses: hmarr/auto-approve-action@v2 + with: + github-token: ${{ secrets.GH_API_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + - name: Merge PR uses: juliangruber/merge-pull-request-action@v1 with: From 7b48bdad64a2fc1ee24704ac964f3501d65d00a8 Mon Sep 17 00:00:00 2001 From: Pehesi97 Date: Thu, 10 Mar 2022 09:43:01 -0300 Subject: [PATCH 74/79] juliangruber's auto-approve action --- .github/workflows/automatic-updates.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 8d8086cbe8..c128ddae7f 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -39,10 +39,11 @@ jobs: GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} run: node --experimental-fetch check-pr-status.mjs ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} - - uses: hmarr/auto-approve-action@v2 + - name: Auto-approve the PR + uses: juliangruber/approve-pull-request-action@v1 with: github-token: ${{ secrets.GH_API_TOKEN }} - pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + number: ${{ steps.cpr.outputs.pull-request-number }} - name: Merge PR uses: juliangruber/merge-pull-request-action@v1 From f17b561cc020f8f064ce192f4e0b84c46c828837 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 10 Mar 2022 10:37:51 -0300 Subject: [PATCH 75/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index c128ddae7f..a4bcf2e29c 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -25,7 +25,7 @@ jobs: id: cpr uses: peter-evans/create-pull-request@v3 with: - token: ${{ secrets.GH_API_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} branch: update-branch base: main commit-message: "Update to ${{ steps.updt.outputs.updated-versions }}" From 82f03ea61532a675a4c60ceb8b41855b74042fd0 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 10 Mar 2022 10:37:55 -0300 Subject: [PATCH 76/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index a4bcf2e29c..610bf67487 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -36,7 +36,7 @@ jobs: - name: Check CI status periodically env: - GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} + GH_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: node --experimental-fetch check-pr-status.mjs ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} - name: Auto-approve the PR From 89773e7ac1decf508005717c0b0d4ef16dc5fc20 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 10 Mar 2022 10:38:00 -0300 Subject: [PATCH 77/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index 610bf67487..e11473aa8e 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -48,5 +48,5 @@ jobs: - name: Merge PR uses: juliangruber/merge-pull-request-action@v1 with: - github-token: ${{ secrets.GH_API_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.cpr.outputs.pull-request-number }} From 31e167f576d5a3a2c1657b8f6dc5ab6a21d3d76d Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Thu, 10 Mar 2022 10:38:09 -0300 Subject: [PATCH 78/79] Update .github/workflows/automatic-updates.yml Co-authored-by: Simen Bekkhus --- .github/workflows/automatic-updates.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index e11473aa8e..a444fc89cb 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -42,6 +42,7 @@ jobs: - name: Auto-approve the PR uses: juliangruber/approve-pull-request-action@v1 with: + # Cannot use `GITHUB_TOKEN` as it's not allowed to approve own PR github-token: ${{ secrets.GH_API_TOKEN }} number: ${{ steps.cpr.outputs.pull-request-number }} From efc5719450773ab081e77c35df4419bbe049efd4 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 10 Mar 2022 22:16:06 +0100 Subject: [PATCH 79/79] tweaks --- .github/workflows/automatic-updates.yml | 19 ++++---- build-automation.mjs | 60 ++++++++++++------------- check-pr-status.mjs | 29 ++++++------ 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/.github/workflows/automatic-updates.yml b/.github/workflows/automatic-updates.yml index a444fc89cb..bbbc29bb6b 100644 --- a/.github/workflows/automatic-updates.yml +++ b/.github/workflows/automatic-updates.yml @@ -12,14 +12,13 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - # to access `--experimental-fetch` - node-version: '17' - - name: Run automation script + uses: actions/github-script@v6 id: updt - run: node --experimental-fetch build-automation.mjs + with: + script: | + const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/build-automation.mjs`); + await script(github); - name: Create update PR id: cpr @@ -35,9 +34,11 @@ jobs: @nodejs/docker - name: Check CI status periodically - env: - GH_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: node --experimental-fetch check-pr-status.mjs ${{ github.repository }} ${{ steps.cpr.outputs.pull-request-number }} + uses: actions/github-script@v6 + with: + script: | + const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/check-pr-status.mjs`); + await script(github, '${{ github.repository }}', ${{ steps.cpr.outputs.pull-request-number }}); - name: Auto-approve the PR uses: juliangruber/approve-pull-request-action@v1 diff --git a/build-automation.mjs b/build-automation.mjs index e8760dfdbd..952f3b8e9c 100644 --- a/build-automation.mjs +++ b/build-automation.mjs @@ -7,26 +7,25 @@ const exec = promisify(child_process.exec); // a function that queries the Node.js release website for new versions, // compare the available ones with the ones we use in this repo // and returns whether we should update or not -const checkIfThereAreNewVersions = async () => { +const checkIfThereAreNewVersions = async (github) => { try { const { stdout: versionsOutput } = await exec(". ./functions.sh && get_versions", { shell: "bash" }); const supportedVersions = versionsOutput.trim().split(" "); - let lsOutput = ""; let latestSupportedVersions = {}; for (let supportedVersion of supportedVersions) { - lsOutput = (await exec(`ls ${supportedVersion}`)).stdout; + const { stdout } = await exec(`ls ${supportedVersion}`); - const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${lsOutput.trim().split("\n")[0]}`, { shell: "bash" }); + const { stdout: fullVersionOutput } = await exec(`. ./functions.sh && get_full_version ./${supportedVersion}/${stdout.trim().split("\n")[0]}`, { shell: "bash" }); console.log(fullVersionOutput); latestSupportedVersions[supportedVersion] = { fullVersion: fullVersionOutput.trim() }; } - const availableVersionsJson = await (await fetch('https://nodejs.org/download/release/index.json')).json(); + const { data: availableVersionsJson } = await github.request('https://nodejs.org/download/release/index.json'); // filter only more recent versions of availableVersionsJson for each major version in latestSupportedVersions' keys // e.g. if latestSupportedVersions = { "12": "12.22.10", "14": "14.19.0", "16": "16.14.0", "17": "17.5.0" } @@ -58,15 +57,14 @@ const checkIfThereAreNewVersions = async () => { // a function that queries the Node.js unofficial release website for new musl versions and security releases, // and returns relevant information -const checkForMuslVersionsAndSecurityReleases = async (versions) => { +const checkForMuslVersionsAndSecurityReleases = async (github, versions) => { try { - let unofficialBuildsIndexText = await (await fetch('https://unofficial-builds.nodejs.org/download/release/index.json')).json(); + const { data: unofficialBuildsIndexText } = await github.request('https://unofficial-builds.nodejs.org/download/release/index.json'); - let unofficialBuildsWebsiteText = ""; for (let version of Object.keys(versions)) { - unofficialBuildsWebsiteText = await (await fetch(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`)).text(); - versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); + const { data: unofficialBuildsWebsiteText } = await github.request(`https://unofficial-builds.nodejs.org/download/release/v${versions[version].fullVersion}`); + versions[version].muslBuildExists = unofficialBuildsWebsiteText.includes("musl"); versions[version].isSecurityRelease = unofficialBuildsIndexText.find(indexVersion => indexVersion.version === `v${versions[version].fullVersion}`)?.security; } return versions; @@ -76,29 +74,31 @@ const checkForMuslVersionsAndSecurityReleases = async (versions) => { } }; +export default async function(github) { // if there are no new versions, exit gracefully // if there are new versions, // check for musl builds // then run update.sh -const { shouldUpdate, versions } = await checkIfThereAreNewVersions(); - -if (!shouldUpdate) { - console.log("No new versions found. No update required."); - process.exit(0); -} else { - const newVersions = await checkForMuslVersionsAndSecurityReleases(versions); - let updatedVersions = []; - for (let version of Object.keys(newVersions)) { - if (newVersions[version].muslBuildExists) { - const { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); - console.log(stdout); - updatedVersions.push(newVersions[version].fullVersion); - } else { - console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); - process.exit(0); + const { shouldUpdate, versions } = await checkIfThereAreNewVersions(github); + + if (!shouldUpdate) { + console.log("No new versions found. No update required."); + process.exit(0); + } else { + const newVersions = await checkForMuslVersionsAndSecurityReleases(github, versions); + let updatedVersions = []; + for (let version of Object.keys(newVersions)) { + if (newVersions[version].muslBuildExists) { + const { stdout } = await exec(`./update.sh ${newVersions[version].isSecurityRelease ? "-s " : ""}${version}`); + console.log(stdout); + updatedVersions.push(newVersions[version].fullVersion); + } else { + console.log(`There's no musl build for version ${newVersions[version].fullVersion} yet.`); + process.exit(0); + } } - }; - console.log(`::set-output name=updated-versions::${updatedVersions.join(',')}`); - const { stdout } = (await exec(`git diff`)); - console.log(stdout); + console.log(`::set-output name=updated-versions::${updatedVersions.join(',')}`); + const { stdout } = (await exec(`git diff`)); + console.log(stdout); + } } diff --git a/check-pr-status.mjs b/check-pr-status.mjs index de7fb73498..799c0e35d9 100644 --- a/check-pr-status.mjs +++ b/check-pr-status.mjs @@ -7,22 +7,23 @@ import { setTimeout } from 'timers/promises'; const tries = 10; const retryDelay = 30000; -await setTimeout(retryDelay); +export default async function(github, repository, pull_number) { + const [owner, repo] = repository.split('/'); + await setTimeout(retryDelay); -for (let t = 0; t < tries; t++) { - try { - const [repo, pull_number] = process.argv.slice(2); + for (let t = 0; t < tries; t++) { + try { + const { data } = await github.rest.pulls.get({owner, repo, pull_number}) - const data = await (await fetch(`https://api.github.com/repos/${repo}/pulls/${pull_number}`)).json(); - - console.log(data); - if (data.mergeable_state === 'clean') { - process.exit(0); + console.log(data); + if (data.mergeable_state === 'clean') { + process.exit(0); + } + await setTimeout(retryDelay); + } catch (error) { + console.error(error); + process.exit(1); } - await setTimeout(retryDelay); - } catch (error) { - console.error(error); - process.exit(1); } + process.exit(1); } -process.exit(1);