Repository: electron/electron
Pull request: build: remove appveyor bake

Backport of #45073

See that PR for details.


Notes: <!-- Please add a one-line description for app developers to read in the release notes, or 'none' if no notes relevant to app developers. Examples and help on special cases: https://github.com/electron/clerk/blob/main/README.md#examples -->none


Changed files:
filename: .github/workflows/update_appveyor_image.yml
patch: @@ -1,78 +0,0 @@
-name: Update AppVeyor Image
-
-# Run chron daily Mon-Fri
-on:
-  workflow_dispatch:
-  schedule:
-    - cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru)
-
-permissions: {}
-
-jobs:
-  bake-appveyor-image:
-    name: Bake AppVeyor Image
-    runs-on: ubuntu-latest
-    steps:
-    - name: Generate GitHub App token
-      uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
-      id: generate-token
-      with:
-        creds: ${{ secrets.APPVEYOR_UPDATER_GH_APP_CREDS }}
-    - name: Checkout
-      uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
-      with:
-        fetch-depth: 0
-        token: ${{ steps.generate-token.outputs.token }}
-        ref: ${{ github.event.pull_request.head.sha }}
-    - name: Setup Node.js
-      uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
-      with:
-        node-version: 20.11.x
-    - name: Yarn install
-      run: |
-        node script/yarn.js install --frozen-lockfile
-    - name: Set Repo for Commit
-      run: git config --global --add safe.directory $GITHUB_WORKSPACE
-    - name: Check AppVeyor Image
-      env:
-        APPVEYOR_TOKEN: ${{ secrets.APPVEYOR_TOKEN }}
-      run: |
-        node ./script/prepare-appveyor
-        if [ -f ./image_version.txt ]; then
-          echo "APPVEYOR_IMAGE_VERSION="$(cat image_version.txt)"" >> $GITHUB_ENV
-          rm image_version.txt
-        fi
-    - name: (Optionally) Update Appveyor Image
-      if: ${{ env.APPVEYOR_IMAGE_VERSION }}
-      uses: mikefarah/yq@bbdd97482f2d439126582a59689eb1c855944955 # v4.44.3
-      with:
-        cmd: |
-          yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
-          yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor-woa.yml" > "appveyor-woa2.yml"
-    - name: (Optionally) Generate Commit Diff
-      if: ${{ env.APPVEYOR_IMAGE_VERSION }}
-      run: |
-        diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true
-        patch -f appveyor.yml < appveyor.diff
-        rm appveyor2.yml appveyor.diff
-        git add appveyor.yml
-    - name: (Optionally) Generate Commit Diff for WOA
-      if: ${{ env.APPVEYOR_IMAGE_VERSION }}
-      run: |
-        diff -w -B appveyor-woa.yml appveyor-woa2.yml > appveyor-woa.diff || true
-        patch -f appveyor-woa.yml < appveyor-woa.diff
-        rm appveyor-woa2.yml appveyor-woa.diff
-        git add appveyor-woa.yml
-    - name: (Optionally) Commit to Branch
-      if: ${{ env.APPVEYOR_IMAGE_VERSION }}
-      uses: dsanders11/github-app-commit-action@43de6da2f4d927e997c0784c7a0b61bd19ad6aac # v1.5.0
-      with:
-        message: 'build: update appveyor image to latest version'
-        ref: bump-appveyor-image
-        token: ${{ steps.generate-token.outputs.token }}
-    - name: (Optionally) Create Pull Request
-      if: ${{ env.APPVEYOR_IMAGE_VERSION }}
-      run: |
-        printf "This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}.\n\nNotes: none" | gh pr create --head bump-appveyor-image --label no-backport --label semver/none --title 'build: update appveyor image to latest version' --body-file=-
-      env:
-        GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

filename: script/prepare-appveyor.js
patch: @@ -1,227 +0,0 @@
-const { Octokit } = require('@octokit/rest');
-const got = require('got');
-
-const assert = require('node:assert');
-const fs = require('node:fs');
-const path = require('node:path');
-
-const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js');
-
-const octokit = new Octokit();
-
-const APPVEYOR_IMAGES_URL = 'https://ci.appveyor.com/api/build-clouds';
-const APPVEYOR_JOB_URL = 'https://ci.appveyor.com/api/builds';
-const ROLLER_BRANCH_PATTERN = /^roller\/chromium$/;
-
-const DEFAULT_BUILD_CLOUD_ID = '1598';
-const DEFAULT_BUILD_CLOUD = 'electronhq-16-core';
-const DEFAULT_BAKE_BASE_IMAGE = 'base-bake-image';
-const DEFAULT_BUILD_IMAGE = 'base-bake-image';
-
-const appveyorBakeJob = 'electron-bake-image';
-const appVeyorJobs = {
-  'electron-x64': 'electron-x64-testing',
-  'electron-woa': 'electron-woa-testing',
-  'electron-ia32': 'electron-ia32-testing'
-};
-
-async function makeRequest ({ auth, username, password, url, headers, body, method }) {
-  const clonedHeaders = {
-    ...(headers || {})
-  };
-  if (auth?.bearer) {
-    clonedHeaders.Authorization = `Bearer ${auth.bearer}`;
-  }
-
-  const options = {
-    headers: clonedHeaders,
-    body,
-    method
-  };
-
-  if (username || password) {
-    options.username = username;
-    options.password = password;
-  }
-
-  const response = await got(url, options);
-
-  if (response.statusCode < 200 || response.statusCode >= 300) {
-    console.error('Error: ', `(status ${response.statusCode})`, response.body);
-    throw new Error(`Unexpected status code ${response.statusCode} from ${url}`);
-  }
-  return JSON.parse(response.body);
-}
-
-async function checkAppVeyorImage (options) {
-  const IMAGE_URL = `${APPVEYOR_IMAGES_URL}/${options.cloudId}`;
-  const requestOpts = {
-    url: IMAGE_URL,
-    auth: {
-      bearer: process.env.APPVEYOR_TOKEN
-    },
-    headers: {
-      'Content-Type': 'application/json'
-    },
-    method: 'GET'
-  };
-
-  try {
-    const { settings } = await makeRequest(requestOpts);
-    const { cloudSettings } = settings;
-    return cloudSettings.images.find(image => image.name === `${options.imageVersion}`) || null;
-  } catch (err) {
-    if (err.response?.body) {
-      console.error('Could not call AppVeyor: ', {
-        statusCode: err.response.statusCode,
-        body: JSON.parse(err.response.body)
-      });
-    } else {
-      console.error('Error calling AppVeyor:', err);
-    }
-  }
-}
-
-async function getPullRequestId (targetBranch) {
-  const prsForBranch = await octokit.pulls.list({
-    owner: 'electron',
-    repo: 'electron',
-    state: 'open',
-    head: `electron:${targetBranch}`
-  });
-  if (prsForBranch.data.length === 1) {
-    return prsForBranch.data[0].number;
-  } else {
-    return null;
-  }
-}
-
-function useAppVeyorImage (targetBranch, options) {
-  const validJobs = Object.keys(appVeyorJobs);
-  if (options.job) {
-    assert(validJobs.includes(options.job), `Unknown AppVeyor CI job name: ${options.job}.  Valid values are: ${validJobs}.`);
-    callAppVeyorBuildJobs(targetBranch, options.job, options);
-  } else {
-    for (const job of validJobs) {
-      callAppVeyorBuildJobs(targetBranch, job, options);
-    }
-  }
-}
-
-async function callAppVeyorBuildJobs (targetBranch, job, options) {
-  console.log(`Using AppVeyor image ${options.version} for ${job}`);
-
-  const pullRequestId = await getPullRequestId(targetBranch);
-  const environmentVariables = {
-    APPVEYOR_BUILD_WORKER_CLOUD: DEFAULT_BUILD_CLOUD,
-    APPVEYOR_BUILD_WORKER_IMAGE: options.version,
-    ELECTRON_OUT_DIR: 'Default',
-    ELECTRON_ENABLE_STACK_DUMPING: 1,
-    ELECTRON_ALSO_LOG_TO_STDERR: 1,
-    DEPOT_TOOLS_WIN_TOOLCHAIN: 0,
-    PYTHONIOENCODING: 'UTF-8'
-  };
-
-  const requestOpts = {
-    url: APPVEYOR_JOB_URL,
-    auth: {
-      bearer: process.env.APPVEYOR_TOKEN
-    },
-    headers: {
-      'Content-Type': 'application/json'
-    },
-    body: JSON.stringify({
-      accountName: 'electron-bot',
-      projectSlug: appVeyorJobs[job],
-      branch: targetBranch,
-      pullRequestId: pullRequestId || undefined,
-      commitId: options.commit || undefined,
-      environmentVariables
-    }),
-    method: 'POST'
-  };
-
-  try {
-    const { version } = await makeRequest(requestOpts);
-    const buildUrl = `https://ci.appveyor.com/project/electron-bot/${appVeyorJobs[job]}/build/${version}`;
-    console.log(`AppVeyor CI request for ${job} successful.  Check status at ${buildUrl}`);
-  } catch (err) {
-    console.log('Could not call AppVeyor: ', err);
-  }
-}
-
-async function bakeAppVeyorImage (targetBranch, options) {
-  console.log(`Baking a new AppVeyor image for ${options.version}, on build cloud ${options.cloudId}`);
-
-  const environmentVariables = {
-    APPVEYOR_BUILD_WORKER_CLOUD: DEFAULT_BUILD_CLOUD,
-    APPVEYOR_BUILD_WORKER_IMAGE: DEFAULT_BAKE_BASE_IMAGE,
-    APPVEYOR_BAKE_IMAGE: options.version
-  };
-
-  const requestOpts = {
-    url: APPVEYOR_JOB_URL,
-    auth: {
-      bearer: process.env.APPVEYOR_TOKEN
-    },
-    headers: {
-      'Content-Type': 'application/json'
-    },
-    body: JSON.stringify({
-      accountName: 'electron-bot',
-      projectSlug: appveyorBakeJob,
-      branch: targetBranch,
-      commitId: options.commit || undefined,
-      environmentVariables
-    }),
-    method: 'POST'
-  };
-
-  try {
-    const { version } = await makeRequest(requestOpts);
-    const bakeUrl = `https://ci.appveyor.com/project/electron-bot/${appveyorBakeJob}/build/${version}`;
-    console.log(`AppVeyor image bake request for ${options.version} successful.  Check bake status at ${bakeUrl}`);
-  } catch (err) {
-    console.log('Could not call AppVeyor: ', err);
-  }
-}
-
-async function prepareAppVeyorImage (opts) {
-  const branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], ELECTRON_DIR);
-  if (ROLLER_BRANCH_PATTERN.test(branch)) {
-    useAppVeyorImage(branch, { ...opts, version: DEFAULT_BUILD_IMAGE, cloudId: DEFAULT_BUILD_CLOUD_ID });
-  } else {
-    const versionRegex = /chromium_version':\n +'(.+?)',/m;
-    const deps = fs.readFileSync(path.resolve(__dirname, '..', 'DEPS'), 'utf8');
-    const [, CHROMIUM_VERSION] = versionRegex.exec(deps);
-
-    const cloudId = opts.cloudId || DEFAULT_BUILD_CLOUD_ID;
-    const imageVersion = opts.imageVersion || `e-${CHROMIUM_VERSION}`;
-    const image = await checkAppVeyorImage({ cloudId, imageVersion });
-
-    if (image && image.name) {
-      console.log(`Image exists for ${image.name}. Continuing AppVeyor jobs using ${cloudId}.\n`);
-    } else {
-      console.log(`No AppVeyor image found for ${imageVersion} in ${cloudId}.
-                   Creating new image for ${imageVersion}, using Chromium ${CHROMIUM_VERSION} - job will run after image is baked.`);
-      await bakeAppVeyorImage(branch, { ...opts, version: imageVersion, cloudId });
-
-      // write image to temp file if running on CI
-      if (process.env.CI) fs.writeFileSync('./image_version.txt', imageVersion);
-    }
-  }
-}
-
-module.exports = prepareAppVeyorImage;
-
-//   Load or bake AppVeyor images for Windows CI.
-//   Usage: prepare-appveyor.js [--cloudId=CLOUD_ID] [--appveyorJobId=xxx] [--imageVersion=xxx]
-//   [--commit=sha] [--branch=branch_name]
-if (require.main === module) {
-  const args = require('minimist')(process.argv.slice(2));
-  prepareAppVeyorImage(args)
-    .catch((err) => {
-      console.error(err);
-      process.exit(1);
-    });
-}