2021-02-02 08:07:43 +03:00
|
|
|
/// GitHub workflow generator. We are using custom generator in order to re-use sub-steps. This
|
|
|
|
/// may not be needed anymore after this feature request will be resolved by GitHub:
|
|
|
|
/// https://github.community/t/support-for-yaml-anchors/16128
|
|
|
|
|
|
|
|
const fss = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const paths = require('./paths')
|
|
|
|
const yaml = require('js-yaml')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// =================
|
|
|
|
// === Constants ===
|
|
|
|
// =================
|
|
|
|
|
2021-02-05 03:44:21 +03:00
|
|
|
const NODE_VERSION = '14.15.0'
|
2021-07-20 17:50:38 +03:00
|
|
|
const RUST_VERSION = read_rust_toolchain_version()
|
2021-02-05 03:44:21 +03:00
|
|
|
const WASM_PACK_VERSION = '0.9.1'
|
|
|
|
const FLAG_NO_CHANGELOG_NEEDED = '[ci no changelog needed]'
|
|
|
|
const FLAG_FORCE_CI_BUILD = '[ci build]'
|
2021-02-02 08:07:43 +03:00
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
const LINUX_RUNNER_GITHUB_HOSTED = ["ubuntu-latest"]
|
|
|
|
const MACOS_RUNNER_GITHUB_HOSTED = ["macOS-latest"]
|
|
|
|
const WINDOWS_RUNNER_GITHUB_HOSTED = ["windows-latest"]
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
// =============
|
|
|
|
// === Utils ===
|
|
|
|
// =============
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function cached_linux_runner(cache_label) {
|
|
|
|
return ["Linux", cache_label]
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:50:38 +03:00
|
|
|
function read_rust_toolchain_version() {
|
|
|
|
return fss.readFileSync(paths.root + "/rust-toolchain").toString().trim()
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function job(runners,name,steps,cfg) {
|
2021-02-02 08:07:43 +03:00
|
|
|
if (!cfg) { cfg = {} }
|
|
|
|
return {
|
|
|
|
name: name,
|
2021-09-22 22:44:25 +03:00
|
|
|
"runs-on": "${{ matrix.runner }}",
|
2021-02-02 08:07:43 +03:00
|
|
|
strategy: {
|
|
|
|
matrix: {
|
2021-09-22 22:44:25 +03:00
|
|
|
runner: runners
|
2021-02-02 08:07:43 +03:00
|
|
|
},
|
|
|
|
"fail-fast": false
|
|
|
|
},
|
2021-02-05 03:44:21 +03:00
|
|
|
// WARNING!
|
|
|
|
// Do not update to `checkout@v2` because it is broken:
|
|
|
|
// https://github.com/actions/checkout/issues/438
|
2021-09-22 22:44:25 +03:00
|
|
|
steps : list({uses:"actions/checkout@v1", with: {clean:false}}, ...steps),
|
2021-02-02 08:07:43 +03:00
|
|
|
...cfg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function job_on_macos(...args) {
|
|
|
|
return job([MACOS_RUNNER_GITHUB_HOSTED],...args)
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function job_on_linux_cached(cache_label,...args) {
|
|
|
|
return job([cached_linux_runner(cache_label)],...args)
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function job_on_linux(...args) {
|
|
|
|
return job([LINUX_RUNNER_GITHUB_HOSTED],[],...args)
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
2021-03-05 18:22:19 +03:00
|
|
|
function job_on_ubuntu_18_04(...args) {
|
|
|
|
return job(["ubuntu-18.04"],...args)
|
|
|
|
}
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
function list(...args) {
|
|
|
|
let out = []
|
|
|
|
for (let arg of args) {
|
|
|
|
if (Array.isArray(arg)) {
|
|
|
|
out.push(...arg)
|
|
|
|
} else {
|
|
|
|
out.push(arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-05 00:21:50 +03:00
|
|
|
// ============
|
|
|
|
// === Info ===
|
|
|
|
// ============
|
|
|
|
|
|
|
|
dumpGitHubContext = {
|
|
|
|
name: 'Dump GitHub context',
|
|
|
|
env: {
|
|
|
|
GITHUB_CONTEXT: '${{ toJson(github) }}'
|
|
|
|
},
|
|
|
|
run: 'echo "$GITHUB_CONTEXT"'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
// ====================
|
|
|
|
// === Dependencies ===
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
let installRust = {
|
|
|
|
name: "Install Rust",
|
|
|
|
uses: "actions-rs/toolchain@v1",
|
|
|
|
with: {
|
|
|
|
toolchain: RUST_VERSION,
|
|
|
|
override: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let installNode = {
|
|
|
|
name: "Install Node",
|
|
|
|
uses: "actions/setup-node@v1",
|
|
|
|
with: {
|
|
|
|
"node-version": NODE_VERSION,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let installPrettier = {
|
|
|
|
name: "Install Prettier",
|
|
|
|
run: "npm install --save-dev --save-exact prettier"
|
|
|
|
}
|
|
|
|
|
|
|
|
let installClippy = {
|
|
|
|
name: "Install Clippy",
|
|
|
|
run: "rustup component add clippy"
|
|
|
|
}
|
|
|
|
|
2021-08-09 18:20:00 +03:00
|
|
|
// Install fixed version to avoid upgrading to a breaking version.
|
|
|
|
// Should be removed once this has a better solution as described here:
|
|
|
|
// https://github.com/enso-org/ide/issues/1772
|
|
|
|
let installTypeScript = {
|
|
|
|
name: "Install TypeScript",
|
|
|
|
run: "npm install -g ts-node@10.1.0"
|
|
|
|
}
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
function installWasmPackOn(name,sys,pkg) {
|
|
|
|
return {
|
|
|
|
name: `Install wasm-pack (${name})`,
|
|
|
|
env: {
|
|
|
|
WASMPACKURL: `https://github.com/rustwasm/wasm-pack/releases/download/v${WASM_PACK_VERSION}`,
|
|
|
|
WASMPACKDIR: `wasm-pack-v${WASM_PACK_VERSION}-x86_64-${pkg}`,
|
|
|
|
},
|
|
|
|
run: `
|
|
|
|
curl -L "$WASMPACKURL/$WASMPACKDIR.tar.gz" | tar -xz -C .
|
|
|
|
mv $WASMPACKDIR/wasm-pack ~/.cargo/bin
|
|
|
|
rm -r $WASMPACKDIR`,
|
|
|
|
shell: "bash",
|
2021-03-05 18:22:19 +03:00
|
|
|
if: `startsWith(matrix.os,'${sys}')`,
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let installWasmPackOnMacOS = installWasmPackOn('macOS','macOS','apple-darwin')
|
|
|
|
let installWasmPackOnWindows = installWasmPackOn('Windows','windows','pc-windows-msvc')
|
|
|
|
let installWasmPackOnLinux = installWasmPackOn('Linux','ubuntu','unknown-linux-musl')
|
|
|
|
|
|
|
|
// We could use cargo install wasm-pack, but that takes 3.5 minutes compared to few seconds.
|
|
|
|
let installWasmPack = [installWasmPackOnMacOS, installWasmPackOnWindows, installWasmPackOnLinux]
|
|
|
|
|
2021-06-10 12:56:51 +03:00
|
|
|
const installJava = {
|
|
|
|
uses: 'actions/setup-java@v2',
|
|
|
|
with: {
|
|
|
|
distribution: 'adopt',
|
|
|
|
'java-version': '11',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
// =============================
|
|
|
|
// === Build, Lint, and Test ===
|
|
|
|
// =============================
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
let buildPackage = {
|
|
|
|
name: 'Build Package',
|
|
|
|
run: 'node ./run dist --no-rust --skip-version-validation',
|
|
|
|
shell: 'bash',
|
|
|
|
env: {
|
|
|
|
CSC_LINK: '${{secrets.APPLE_CODE_SIGNING_CERT}}',
|
|
|
|
CSC_KEY_PASSWORD: '${{secrets.APPLE_CODE_SIGNING_CERT_PASSWORD}}',
|
|
|
|
CSC_IDENTITY_AUTO_DISCOVERY: true,
|
|
|
|
APPLEID: '${{secrets.APPLE_NOTARIZATION_USERNAME}}',
|
|
|
|
APPLEIDPASS: '${{secrets.APPLE_NOTARIZATION_PASSWORD}}',
|
|
|
|
FIREBASE_API_KEY: '${{secrets.FIREBASE_API_KEY}}',
|
|
|
|
WIN_CSC_LINK: '${{secrets.MICROSOFT_CODE_SIGNING_CERT}}',
|
|
|
|
WIN_CSC_KEY_PASSWORD: '${{secrets.MICROSOFT_CODE_SIGNING_CERT_PASSWORD}}',
|
|
|
|
},
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
2021-03-05 18:22:19 +03:00
|
|
|
let lintMarkdown = {
|
|
|
|
name: "Lint Markdown sources",
|
|
|
|
run: "npx prettier --check '*.md'",
|
|
|
|
}
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
let lintJavaScript = {
|
|
|
|
name: "Lint JavaScript sources",
|
|
|
|
run: "npx prettier --check 'src/**/*.js'",
|
|
|
|
}
|
|
|
|
|
|
|
|
let lintRust = {
|
|
|
|
name: "Lint Rust sources",
|
|
|
|
run: "node ./run lint --skip-version-validation",
|
|
|
|
}
|
|
|
|
|
|
|
|
let testNoWASM = {
|
|
|
|
name: "Run tests (no WASM)",
|
|
|
|
run: "node ./run test --no-wasm --skip-version-validation",
|
|
|
|
}
|
|
|
|
|
|
|
|
let testWASM = {
|
|
|
|
name: "Run tests (WASM)",
|
|
|
|
run: "node ./run test --no-native --skip-version-validation",
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
let buildWASM = {
|
|
|
|
name: "Build WASM",
|
|
|
|
run: "node ./run build --no-js --skip-version-validation",
|
|
|
|
}
|
|
|
|
|
2021-09-27 16:15:55 +03:00
|
|
|
|
|
|
|
let uploadContentLinux = {
|
|
|
|
name: `Upload Content Artifacts`,
|
|
|
|
uses: "actions/upload-artifact@v2",
|
|
|
|
with: {
|
|
|
|
name: 'content',
|
|
|
|
path: `dist/content`
|
|
|
|
},
|
|
|
|
if: `runner.os == 'Linux'`
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
let uploadWASM = {
|
|
|
|
name: `Upload IDE WASM artifacts`,
|
|
|
|
uses: "actions/upload-artifact@v2",
|
|
|
|
with: {
|
|
|
|
name: 'ide-wasm',
|
|
|
|
path: `dist/wasm`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let downloadWASM = {
|
|
|
|
name: `Download IDE WASM artifacts`,
|
|
|
|
uses: "actions/download-artifact@v2",
|
|
|
|
with: {
|
|
|
|
name: 'ide-wasm',
|
|
|
|
path: `dist/wasm`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
// =================
|
|
|
|
// === Artifacts ===
|
|
|
|
// =================
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function uploadArtifactsFor(name,ext,os) {
|
2021-02-02 08:07:43 +03:00
|
|
|
return {
|
|
|
|
name: `Upload Artifacts (${name}, ${ext})`,
|
|
|
|
uses: "actions/upload-artifact@v1",
|
|
|
|
with: {
|
2021-09-22 22:44:25 +03:00
|
|
|
name: `enso-${os}-\${{fromJson(steps.changelog.outputs.content).version}}.${ext}`,
|
|
|
|
path: `dist/client/enso-${os}-\${{fromJson(steps.changelog.outputs.content).version}}.${ext}`
|
2021-02-02 08:07:43 +03:00
|
|
|
},
|
2021-09-22 22:44:25 +03:00
|
|
|
if: `runner.os == '${name}'`,
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
function uploadBinArtifactsWithChecksumsFor(name,ext,os) {
|
2021-02-05 03:44:21 +03:00
|
|
|
return [
|
2021-09-22 22:44:25 +03:00
|
|
|
uploadArtifactsFor(name,ext,os),
|
|
|
|
uploadArtifactsFor(name,ext+'.sha256',os)
|
2021-02-05 03:44:21 +03:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-09-22 22:44:25 +03:00
|
|
|
uploadBinArtifactsForMacOS = uploadBinArtifactsWithChecksumsFor('macOS','dmg','mac')
|
|
|
|
uploadBinArtifactsForLinux = uploadBinArtifactsWithChecksumsFor('Linux','AppImage','linux')
|
|
|
|
uploadBinArtifactsForWindows = uploadBinArtifactsWithChecksumsFor('Windows','exe','win')
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
let downloadArtifacts = {
|
|
|
|
name: "Download artifacts",
|
|
|
|
uses: "actions/download-artifact@v2",
|
|
|
|
with: {
|
|
|
|
path: "artifacts"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-02-05 03:44:21 +03:00
|
|
|
// ===========
|
|
|
|
// === Git ===
|
|
|
|
// ===========
|
|
|
|
|
|
|
|
/// Gets a space-separated list of changed files between this commit and the `develop` branch.
|
|
|
|
let getListOfChangedFiles = {
|
|
|
|
name: 'Get list of changed files',
|
|
|
|
id: 'changed_files',
|
|
|
|
run: `
|
2021-03-05 01:09:14 +03:00
|
|
|
list=\`git diff --name-only origin/\${{github.base_ref}} HEAD | tr '\\n' ' '\`
|
2021-02-05 03:44:21 +03:00
|
|
|
echo $list
|
|
|
|
echo "::set-output name=list::'$list'"
|
|
|
|
`,
|
2021-03-05 01:09:14 +03:00
|
|
|
shell: 'bash',
|
|
|
|
if: `github.base_ref == 'develop' || github.base_ref == 'unstable' || github.base_ref == 'stable'`
|
2021-02-05 03:44:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// =================
|
|
|
|
// === Changelog ===
|
|
|
|
// =================
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
let getCurrentReleaseChangelogInfo = {
|
|
|
|
name: 'Read changelog info',
|
|
|
|
id: 'changelog',
|
|
|
|
run: `
|
|
|
|
node ./run ci-gen --skip-version-validation
|
|
|
|
content=\`cat CURRENT_RELEASE_CHANGELOG.json\`
|
|
|
|
echo "::set-output name=content::$content"
|
|
|
|
`,
|
|
|
|
shell: 'bash'
|
|
|
|
}
|
|
|
|
|
2021-02-05 03:44:21 +03:00
|
|
|
let assertChangelogWasUpdated = [
|
|
|
|
getListOfChangedFiles,
|
|
|
|
{
|
2021-03-05 01:09:14 +03:00
|
|
|
name: 'Assert if CHANGELOG.md was updated (on pull request)',
|
2021-05-13 09:30:19 +03:00
|
|
|
run: `if [[ \${{ contains(steps.changed_files.outputs.list,'CHANGELOG.md') || contains(github.event.head_commit.message,'${FLAG_NO_CHANGELOG_NEEDED}') || contains(github.event.pull_request.body,'${FLAG_NO_CHANGELOG_NEEDED}') }} == false ]]; then exit 1; fi`,
|
2021-03-05 01:09:14 +03:00
|
|
|
if: `github.base_ref == 'develop' || github.base_ref == 'unstable' || github.base_ref == 'stable'`
|
2021-02-05 03:44:21 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
// ======================
|
|
|
|
// === GitHub Release ===
|
|
|
|
// ======================
|
|
|
|
|
2021-03-05 18:22:19 +03:00
|
|
|
let uploadGitHubRelease = [
|
|
|
|
installPrettier,
|
|
|
|
{
|
|
|
|
name: `Pretty print changelog.`,
|
|
|
|
run: "npx prettier --prose-wrap never CHANGELOG.md --write"
|
2021-02-02 08:07:43 +03:00
|
|
|
},
|
2021-03-05 18:22:19 +03:00
|
|
|
{
|
|
|
|
name: `Upload GitHub Release`,
|
|
|
|
uses: "softprops/action-gh-release@v1",
|
|
|
|
env: {
|
|
|
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
},
|
|
|
|
with: {
|
|
|
|
files: "artifacts/**/enso-*",
|
|
|
|
name: "Enso ${{fromJson(steps.changelog.outputs.content).version}}",
|
|
|
|
tag_name: "v${{fromJson(steps.changelog.outputs.content).version}}",
|
|
|
|
body: "${{fromJson(steps.changelog.outputs.content).body}}",
|
|
|
|
prerelease: "${{fromJson(steps.changelog.outputs.content).prerelease}}",
|
2021-07-15 16:32:40 +03:00
|
|
|
draft: true,
|
2021-03-05 18:22:19 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
2021-02-02 08:07:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===================
|
|
|
|
// === CDN Release ===
|
|
|
|
// ===================
|
|
|
|
|
|
|
|
prepareAwsSessionCDN = {
|
|
|
|
shell: "bash",
|
|
|
|
run: `
|
|
|
|
aws configure --profile s3-upload <<-EOF > /dev/null 2>&1
|
|
|
|
\${{ secrets.ARTEFACT_S3_ACCESS_KEY_ID }}
|
|
|
|
\${{ secrets.ARTEFACT_S3_SECRET_ACCESS_KEY }}
|
|
|
|
us-west-1
|
|
|
|
text
|
|
|
|
EOF
|
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
function uploadToCDN(...names) {
|
2021-05-13 09:30:19 +03:00
|
|
|
const actions = []
|
2021-02-02 08:07:43 +03:00
|
|
|
for (let name of names) {
|
2021-05-13 09:30:19 +03:00
|
|
|
const action = {
|
2021-02-02 08:07:43 +03:00
|
|
|
name: `Upload '${name}' to CDN`,
|
|
|
|
shell: "bash",
|
|
|
|
run: `aws s3 cp ./artifacts/content/assets/${name} `
|
2021-09-22 22:44:25 +03:00
|
|
|
+ `s3://ensocdn/ide/\${{fromJson(steps.changelog.outputs.content).version}}/${name} --profile `
|
|
|
|
+ `s3-upload --acl public-read`
|
2021-04-23 18:22:02 +03:00
|
|
|
}
|
|
|
|
if (name.endsWith(".gz")) {
|
|
|
|
action.run += " --content-encoding gzip";
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
2021-05-13 09:30:19 +03:00
|
|
|
if (name.endsWith(".wasm")) {
|
|
|
|
action.run += " --content-type 'application/wasm'";
|
|
|
|
}
|
2021-02-02 08:07:43 +03:00
|
|
|
actions.push(action)
|
|
|
|
}
|
|
|
|
return actions
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ==================
|
|
|
|
// === Assertions ===
|
|
|
|
// ==================
|
|
|
|
|
|
|
|
let assertVersionUnstable = {
|
|
|
|
name: "Assert Version Unstable",
|
|
|
|
run: "node ./run assert-version-unstable --skip-version-validation",
|
2021-03-05 01:09:14 +03:00
|
|
|
if: `github.ref == 'refs/heads/unstable' || github.base_ref == 'unstable'`
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
let assertVersionStable = {
|
|
|
|
name: "Assert Version Stable",
|
|
|
|
run: "node ./run assert-version-stable --skip-version-validation",
|
2021-03-05 01:09:14 +03:00
|
|
|
if: `github.ref == 'refs/heads/stable' || github.base_ref == 'stable'`
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
let assertReleaseDoNotExists = [
|
|
|
|
{
|
|
|
|
id: 'checkCurrentReleaseTag',
|
|
|
|
uses: 'mukunku/tag-exists-action@v1.0.0',
|
|
|
|
env: {
|
|
|
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
},
|
|
|
|
with: {
|
|
|
|
tag: 'v${{fromJson(steps.changelog.outputs.content).version}}'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Fail if release already exists',
|
|
|
|
run: 'if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi',
|
2021-03-05 18:22:19 +03:00
|
|
|
if: `github.base_ref == 'unstable' || github.base_ref == 'stable'`
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2021-03-05 03:21:48 +03:00
|
|
|
assertNoSquashCommitForRelease = {
|
|
|
|
name: `Fail if squash commit to the 'unstable' or the 'stable' branch.`,
|
2021-03-05 03:24:16 +03:00
|
|
|
run: 'if [[ "${{ github.base_ref }}" == "unstable" || "${{ github.base_ref }}" == "stable" ]]; then exit 1; fi',
|
2021-03-05 03:21:48 +03:00
|
|
|
}
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
let assertions = list(
|
|
|
|
assertVersionUnstable,
|
|
|
|
assertVersionStable,
|
2021-02-05 03:44:21 +03:00
|
|
|
assertReleaseDoNotExists,
|
2021-03-05 03:21:48 +03:00
|
|
|
assertChangelogWasUpdated,
|
|
|
|
assertNoSquashCommitForRelease,
|
2021-02-02 08:07:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-05 01:09:14 +03:00
|
|
|
// ===============
|
2021-02-02 08:07:43 +03:00
|
|
|
// === Workflow ===
|
2021-03-05 01:09:14 +03:00
|
|
|
// ===============
|
2021-02-02 08:07:43 +03:00
|
|
|
|
2021-03-05 01:21:40 +03:00
|
|
|
/// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request
|
|
|
|
/// FROM these branches, the `github.ref` will be different.
|
|
|
|
let releaseCondition = `github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'`
|
|
|
|
|
2021-02-02 08:07:43 +03:00
|
|
|
let workflow = {
|
|
|
|
name : "GUI CI",
|
2021-03-05 01:09:14 +03:00
|
|
|
on: {
|
|
|
|
push: {
|
2021-03-11 14:01:21 +03:00
|
|
|
branches: ['develop','unstable','stable']
|
2021-03-05 01:09:14 +03:00
|
|
|
},
|
2021-09-22 22:44:25 +03:00
|
|
|
pull_request: {},
|
|
|
|
workflow_dispatch: {}
|
2021-03-05 01:09:14 +03:00
|
|
|
},
|
2021-02-02 08:07:43 +03:00
|
|
|
jobs: {
|
2021-03-05 01:09:14 +03:00
|
|
|
info: job_on_macos("Build Info", [
|
|
|
|
dumpGitHubContext
|
|
|
|
]),
|
2021-02-05 03:44:21 +03:00
|
|
|
version_assertions: job_on_macos("Assertions", [
|
2021-02-02 08:07:43 +03:00
|
|
|
getCurrentReleaseChangelogInfo,
|
|
|
|
assertions
|
|
|
|
]),
|
2021-09-22 22:44:25 +03:00
|
|
|
lint: job_on_linux_cached("linter", "Linter", [
|
2021-02-02 08:07:43 +03:00
|
|
|
installNode,
|
2021-08-09 18:20:00 +03:00
|
|
|
installTypeScript,
|
2021-02-02 08:07:43 +03:00
|
|
|
installRust,
|
|
|
|
installPrettier,
|
|
|
|
installClippy,
|
2021-03-05 18:22:19 +03:00
|
|
|
lintMarkdown,
|
2021-02-02 08:07:43 +03:00
|
|
|
lintJavaScript,
|
|
|
|
lintRust
|
|
|
|
]),
|
2021-09-22 22:44:25 +03:00
|
|
|
test: job_on_linux_cached("test_native", "Native Tests", [
|
2021-02-02 08:07:43 +03:00
|
|
|
installNode,
|
2021-08-09 18:20:00 +03:00
|
|
|
installTypeScript,
|
2021-02-02 08:07:43 +03:00
|
|
|
installRust,
|
|
|
|
testNoWASM,
|
|
|
|
]),
|
2021-09-22 22:44:25 +03:00
|
|
|
"wasm-test": job_on_linux_cached("test_wasm", "WASM Tests", [
|
2021-02-02 08:07:43 +03:00
|
|
|
installNode,
|
2021-08-09 18:20:00 +03:00
|
|
|
installTypeScript,
|
2021-02-02 08:07:43 +03:00
|
|
|
installRust,
|
|
|
|
installWasmPack,
|
|
|
|
testWASM
|
|
|
|
]),
|
2021-09-22 22:44:25 +03:00
|
|
|
build_wasm: job_on_linux_cached("build_wasm", "Build WASM", [
|
2021-02-02 08:07:43 +03:00
|
|
|
installNode,
|
2021-08-09 18:20:00 +03:00
|
|
|
installTypeScript,
|
2021-02-02 08:07:43 +03:00
|
|
|
installRust,
|
|
|
|
installWasmPack,
|
2021-06-10 12:56:51 +03:00
|
|
|
installJava,
|
2021-09-22 22:44:25 +03:00
|
|
|
buildWASM,
|
|
|
|
uploadWASM,
|
2021-06-10 12:56:51 +03:00
|
|
|
]),
|
2021-09-22 22:44:25 +03:00
|
|
|
package: job
|
|
|
|
( [MACOS_RUNNER_GITHUB_HOSTED,WINDOWS_RUNNER_GITHUB_HOSTED,cached_linux_runner("package")]
|
|
|
|
, "Build package"
|
|
|
|
, [
|
|
|
|
getCurrentReleaseChangelogInfo,
|
|
|
|
installNode,
|
|
|
|
installTypeScript,
|
|
|
|
installRust,
|
|
|
|
installWasmPack,
|
|
|
|
installJava,
|
|
|
|
|
|
|
|
downloadWASM,
|
|
|
|
buildPackage,
|
2021-09-27 16:15:55 +03:00
|
|
|
uploadContentLinux,
|
2021-09-22 22:44:25 +03:00
|
|
|
uploadBinArtifactsForMacOS,
|
|
|
|
uploadBinArtifactsForWindows,
|
|
|
|
uploadBinArtifactsForLinux,
|
|
|
|
], { needs: ['build_wasm'] }),
|
2021-02-02 08:07:43 +03:00
|
|
|
release_to_github: job_on_macos("GitHub Release", [
|
|
|
|
downloadArtifacts,
|
|
|
|
getCurrentReleaseChangelogInfo,
|
|
|
|
// This assertion is checked earlier, but we should double-check it in case several
|
|
|
|
// CI jobs wil be run on this branch and a release was created when this workflow was
|
|
|
|
// running.
|
|
|
|
assertReleaseDoNotExists,
|
|
|
|
uploadGitHubRelease,
|
|
|
|
],{ if:releaseCondition,
|
2021-09-22 22:44:25 +03:00
|
|
|
needs:['version_assertions','lint','test','package']
|
2021-02-02 08:07:43 +03:00
|
|
|
}),
|
2021-03-05 18:22:19 +03:00
|
|
|
release_to_cdn: job_on_ubuntu_18_04("CDN Release", [
|
2021-02-02 08:07:43 +03:00
|
|
|
downloadArtifacts,
|
|
|
|
getCurrentReleaseChangelogInfo,
|
|
|
|
prepareAwsSessionCDN,
|
|
|
|
uploadToCDN('index.js.gz','style.css','ide.wasm','wasm_imports.js.gz'),
|
|
|
|
],{ if:releaseCondition,
|
2021-09-22 22:44:25 +03:00
|
|
|
needs:['version_assertions','lint','test','package']
|
2021-03-05 03:21:48 +03:00
|
|
|
})
|
2021-02-02 08:07:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let header = `
|
|
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
# DO NOT CHANGE THIS FILE. IT WAS GENERATED FROM 'build/workflow.js'. READ DOCS THERE TO LEARN MORE.
|
|
|
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
`
|
|
|
|
|
|
|
|
/// Generates a new GitHub workflow file (in .github/workflow/...).
|
|
|
|
function generate() {
|
|
|
|
let workflow_script = header + '\n' + yaml.dump(workflow,{noRefs:true})
|
|
|
|
fss.writeFileSync(path.join(paths.github.workflows,'gui-ci.yml'),workflow_script)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===============
|
|
|
|
// === Exports ===
|
|
|
|
// ===============
|
|
|
|
|
|
|
|
module.exports = {generate}
|