mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
clean up depshash logic
This commit is contained in:
4
.github/actions/checkout/action.yml
vendored
4
.github/actions/checkout/action.yml
vendored
@@ -44,8 +44,8 @@ runs:
|
||||
- name: Generate DEPS Hash
|
||||
shell: bash
|
||||
run: |
|
||||
node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash && cat src/electron/.depshash-target
|
||||
echo "DEPSHASH=v1-src-cache-$(sha1sum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
- name: Generate SAS Key
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
shell: bash
|
||||
|
||||
@@ -149,12 +149,8 @@ jobs:
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Generate DEPS Hash
|
||||
run: |
|
||||
if ! command -v sha1sum 2>&1 >/dev/null
|
||||
then
|
||||
alias sha1sum=shasum
|
||||
fi
|
||||
node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash && cat src/electron/.depshash-target
|
||||
DEPSHASH=v1-src-cache-$(sha1sum src/electron/.depshash | cut -f1 -d' ')
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)
|
||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||
- name: Restore src cache via AZCopy
|
||||
@@ -183,12 +179,8 @@ jobs:
|
||||
e d gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
|
||||
- name: Regenerate DEPS Hash
|
||||
run: |
|
||||
if ! command -v sha1sum 2>&1 >/dev/null
|
||||
then
|
||||
alias sha1sum=shasum
|
||||
fi
|
||||
(cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash && cat src/electron/.depshash-target
|
||||
echo "DEPSHASH=$(sha1sum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV
|
||||
(cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
|
||||
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||
- name: Fix Sync (macOS)
|
||||
|
||||
@@ -120,12 +120,8 @@ jobs:
|
||||
echo "ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN=1" >> $GITHUB_ENV
|
||||
- name: Generate DEPS Hash
|
||||
run: |
|
||||
if ! command -v sha1sum 2>&1 >/dev/null
|
||||
then
|
||||
alias sha1sum=shasum
|
||||
fi
|
||||
node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash && cat src/electron/.depshash-target
|
||||
DEPSHASH=v1-src-cache-$(sha1sum src/electron/.depshash | cut -f1 -d' ')
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)
|
||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||
- name: Restore src cache via AZCopy
|
||||
@@ -150,12 +146,8 @@ jobs:
|
||||
fi
|
||||
- name: Regenerate DEPS Hash
|
||||
run: |
|
||||
if ! command -v sha1sum 2>&1 >/dev/null
|
||||
then
|
||||
alias sha1sum=shasum
|
||||
fi
|
||||
(cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target
|
||||
echo "DEPSHASH=$(sha1sum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV
|
||||
(cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
|
||||
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||
- name: Checkout Electron
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -48,7 +48,6 @@ ts-gen
|
||||
|
||||
# Used to accelerate CI builds
|
||||
.depshash
|
||||
.depshash-target
|
||||
|
||||
# Used to accelerate builds after sync
|
||||
patches/mtime-cache.json
|
||||
|
||||
@@ -2,14 +2,11 @@ const crypto = require('node:crypto');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
// Fallback to blow away old cache keys
|
||||
const FALLBACK_HASH_VERSION = 3;
|
||||
|
||||
// Per platform hash versions to bust the cache on different platforms
|
||||
const HASH_VERSIONS = {
|
||||
darwin: 3,
|
||||
win32: 3,
|
||||
linux: 3
|
||||
darwin: 4,
|
||||
win32: 4,
|
||||
linux: 4
|
||||
};
|
||||
|
||||
// Base files to hash
|
||||
@@ -39,7 +36,7 @@ const hasher = crypto.createHash('SHA256');
|
||||
const addToHashAndLog = (s) => {
|
||||
return hasher.update(s);
|
||||
};
|
||||
addToHashAndLog(`HASH_VERSION:${HASH_VERSIONS[process.platform] || FALLBACK_HASH_VERSION}`);
|
||||
addToHashAndLog(`HASH_VERSION:${HASH_VERSIONS[process.platform]}`);
|
||||
for (const file of filesToHash) {
|
||||
hasher.update(fs.readFileSync(file));
|
||||
}
|
||||
@@ -48,15 +45,5 @@ for (const file of filesToHash) {
|
||||
const extraArgs = process.env.GCLIENT_EXTRA_ARGS || 'no_extra_args';
|
||||
addToHashAndLog(extraArgs);
|
||||
|
||||
const effectivePlatform = extraArgs.includes('host_os=mac') ? 'darwin' : (process.env.TARGET_OS === 'win' ? 'win32' : process.platform);
|
||||
|
||||
// Write the hash to disk
|
||||
fs.writeFileSync(path.resolve(__dirname, '../.depshash'), hasher.digest('hex'));
|
||||
|
||||
let targetContent = `${effectivePlatform}\n${process.env.TARGET_ARCH}\n${process.env.GN_CONFIG}\n${undefined}\n${process.env.GN_EXTRA_ARGS}\n${process.env.GN_BUILDFLAG_ARGS}`;
|
||||
const argsDir = path.resolve(__dirname, '../build/args');
|
||||
for (const argFile of fs.readdirSync(argsDir).sort()) {
|
||||
targetContent += `\n${argFile}--${crypto.createHash('SHA1').update(fs.readFileSync(path.resolve(argsDir, argFile))).digest('hex')}`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.resolve(__dirname, '../.depshash-target'), targetContent);
|
||||
|
||||
Reference in New Issue
Block a user