mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 21:32:00 +03:00
* The bash entry point was renamed `run.sh` -> `run`. Thanks to that `./run` works both on Linux and Windows with PowerShell (sadly not on CMD). * Everyone's favorite checks for WASM size and program versions are back. These can be disabled through `--wasm-size-limit=0` and `--skip-version-check` respectively. WASM size limit is stored in `build-config.yaml`. * Improved diagnostics for case when downloaded CI run artifact archive cannot be extracted. * Added GH API authentication to the build script calls on CI. This should fix the macOS build failures that were occurring from time to time. (Actually they were due to runner being GitHub-hosted, not really an OS-specific issue by itself.) * If the GH API Personal Access Token is provided, it will be validated. Later on it is difficult to say, whether fail was caused by wrong PAT or other issue. * Renamed `clean` to `git-clean` as per suggestion to reduce risk of user accidently deleting unstaged work. * Whitelisting dependabot from changelog checks, so PRs created by it are mergeable. * Fixing issue where wasm-pack-action (third party) randomly failed to recognize the latest version of wasm-pack (macOS runners), leading to failed builds. * Build logs can be filtered using `ENSO_BUILD_LOG` environment variable. See https://docs.rs/tracing-subscriber/0.3.11/tracing_subscriber/struct.EnvFilter.html#directives for the supported syntax. * Improve help for ci-run source, to make clear that PAT token is required and what scope is expected there. Also, JS parts were updated with some cleanups and fixes following the changes made when introducing the build script.
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
const crypto = require('crypto')
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
// =================
|
|
// === Constants ===
|
|
// =================
|
|
|
|
const CHECKSUM_TYPE = 'sha256'
|
|
|
|
// ================
|
|
// === Checksum ===
|
|
// ================
|
|
|
|
/// The `type` argument can be one of `md5`, `sha1`, or `sha256`.
|
|
function getChecksum(path, type) {
|
|
return new Promise(function (resolve, reject) {
|
|
const hash = crypto.createHash(type)
|
|
const input = fs.createReadStream(path)
|
|
input.on('error', reject)
|
|
input.on('data', function (chunk) {
|
|
hash.update(chunk)
|
|
})
|
|
input.on('close', function () {
|
|
resolve(hash.digest('hex'))
|
|
})
|
|
})
|
|
}
|
|
|
|
// Based on https://stackoverflow.com/a/57371333
|
|
function changeExtension(file, extension) {
|
|
const basename = path.basename(file, path.extname(file))
|
|
return path.join(path.dirname(file), `${basename}.${extension}`)
|
|
}
|
|
|
|
async function writeFileChecksum(path, type) {
|
|
let checksum = await getChecksum(path, type)
|
|
let targetPath = changeExtension(path, type)
|
|
console.log(`Writing ${targetPath}.`)
|
|
fs.writeFile(targetPath, checksum, 'utf8', err => {
|
|
if (err) {
|
|
throw err
|
|
}
|
|
})
|
|
}
|
|
|
|
// ================
|
|
// === Callback ===
|
|
// ================
|
|
|
|
exports.default = async function (context) {
|
|
// `context` is BuildResult, see https://www.electron.build/configuration/configuration.html#buildresult
|
|
for (let file of context.artifactPaths) {
|
|
console.log(`Generating ${CHECKSUM_TYPE} checksum for ${file}.`)
|
|
await writeFileChecksum(file, CHECKSUM_TYPE)
|
|
}
|
|
return []
|
|
}
|