Enable Github Actions for Linux and macOS (replacing Travis CI) (#2691)

This commit is contained in:
Felix Häusler 2021-12-02 17:33:14 +01:00 committed by GitHub
parent f2aa8552b0
commit 30e8e07e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 3033 additions and 2621 deletions

View File

@ -38,7 +38,10 @@ const mainConfig = {
},
{
test: /\.node$/,
use: 'node-loader'
loader: 'node-loader',
options: {
name: '[name].[ext]'
}
}
]
},

View File

@ -91,7 +91,10 @@ const rendererConfig = {
},
{
test: /\.node$/,
use: 'node-loader'
loader: 'node-loader',
options: {
name: '[name].[ext]'
}
},
{
test: /\.vue$/,

76
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: Build
on:
push:
branches: [ main, master, develop ]
paths-ignore:
- 'docs/**'
pull_request:
branches: [ main, master, develop ]
paths-ignore:
- 'docs/**'
jobs:
release:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
matrix:
os: [macos-11, ubuntu-latest] # windows-latest
env:
DISPLAY: ":99.0"
# MARKTEXT_IS_STABLE: 1
MARKTEXT_EXIT_ON_ERROR: 1
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
cache: yarn
cache-dependency-path: yarn.lock
- name: Install build dependencies
if: runner.os == 'Linux'
# electron-builder | keyboard-layout | keytar | fontmanager
run: |
sudo apt-get -y update
sudo apt-get install -y icnsutils graphicsmagick xz-utils libx11-dev libxkbfile-dev gnome-keyring libsecret-1-dev libfontconfig-dev
- name: Cache Electron
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.cache/electron
key: ${{ runner.os }}-electron-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-electron-cache-
- name: Cache Electron-Builder
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-electron-builder-cache-
- name: Install dependencies
run: yarn install --check-files --frozen-lockfile
- name: Lint
run: |
yarn run lint
yarn run validate-licenses
- name: Run unit and E2E tests
uses: GabrielBB/xvfb-action@v1
with:
run: yarn run test
- name: Build Mark Text
run: yarn build:bin

97
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,97 @@
name: Build and upload release
on:
push:
branches:
- 'release-v*'
jobs:
release:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
matrix:
os: [macos-11, ubuntu-latest] # windows-latest
env:
DISPLAY: ":99.0"
MARKTEXT_IS_STABLE: 1
MARKTEXT_EXIT_ON_ERROR: 1
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
cache: yarn
cache-dependency-path: yarn.lock
- name: Install build dependencies
if: runner.os == 'Linux'
# electron-builder | keyboard-layout | keytar | fontmanager | RPM on Ubuntu
run: |
sudo apt-get -y update
sudo apt-get install -y icnsutils graphicsmagick xz-utils libx11-dev libxkbfile-dev gnome-keyring libsecret-1-dev libfontconfig-dev rpm
- name: Cache Electron
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.cache/electron
key: ${{ runner.os }}-electron-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-electron-cache-
- name: Cache Electron-Builder
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-electron-builder-cache-
- name: Install dependencies
run: yarn install --check-files --frozen-lockfile
- name: Lint
run: |
yarn run lint
yarn run validate-licenses
- name: Run unit and E2E tests
uses: GabrielBB/xvfb-action@v1
with:
run: yarn run test
- name: Build and release
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
yarn run release:linux --publish always
elif [ "$RUNNER_OS" == "macOS" ]; then
yarn run release:mac --publish always
else
echo "$RUNNER_OS not supported"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate checksums
if: runner.os == 'Linux'
run: |
sha256sum build/marktext-x64.tar.gz
sha256sum build/marktext-x86_64.AppImage
sha256sum build/marktext-*.deb
sha256sum build/marktext-*.rpm
shell: bash
- name: Calculate checksums
if: runner.os == 'macOS'
run: |
shasum -a 256 build/marktext-mac.zip
shasum -a 256 build/marktext.dmg
shell: bash

View File

@ -1,86 +0,0 @@
language: node_js
node_js:
- 12
jobs:
include:
- os: osx
osx_image: xcode9.4
env: CC=clang CXX=clang++ npm_config_clang=1 MARKTEXT_IS_STABLE=1 MARKTEXT_EXIT_ON_ERROR=1
compiler: clang
- os: linux
dist: bionic
env: CC=clang CXX=clang++ npm_config_clang=1 MARKTEXT_IS_STABLE=1 MARKTEXT_EXIT_ON_ERROR=1 DISPLAY=:99.0
compiler: clang
services:
- xvfb
cache:
directories:
- node_modules
- "$HOME/.electron"
- "$HOME/.cache/electron"
- "$HOME/.cache/electron-builder"
- "$HOME/.cache/yarn"
addons:
apt:
packages:
- libgnome-keyring-dev
- icnsutils
- graphicsmagick
- xz-utils
- xvfb
# atom/keyboard-layout
- libx11-dev
- libxkbfile-dev
# atom/node-keytar
- libsecret-1-dev
# fontmanager
- libfontconfig-dev
# Build RPM on Ubuntu
- rpm
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update ; fi
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- source ~/.bashrc
- $CC --version
- $CXX --version
- npm --version
- yarn --version
# Fix cache between Linux and macOS build workers.
- rm -rf node_modules/vscode-ripgrep
- yarn install --check-files --frozen-lockfile
script:
- yarn run lint
- yarn run validate-licenses
# Unit and e2e tests
- yarn run test
# Build binaries
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then yarn run release:linux --publish always ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then yarn run release:mac --publish always ; fi
# Calculate checksums
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum build/marktext-x64.tar.gz ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum build/marktext-x86_64.AppImage ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum build/marktext-*.deb ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum build/marktext-*.rpm ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then shasum -a 256 build/marktext-mac.zip ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then shasum -a 256 build/marktext.dmg ; fi
branches:
only:
- master
- develop
- /^release-v[0-9.]+(?:-[0-9a-zA-Z\.]+)?$/

View File

@ -25,7 +25,7 @@ init:
- git config --global core.autocrlf input
install:
- ps: Install-Product node 12 $env:PLATFORM
- ps: Install-Product node 14 $env:PLATFORM
- node --version
- npm --version
@ -34,9 +34,9 @@ install:
- yarn install --frozen-lockfile
cache:
- node_modules
- '%LOCALAPPDATA%\electron\Cache'
- '%LOCALAPPDATA%\electron-builder\cache'
- node_modules -> yarn.lock
- '%LOCALAPPDATA%\electron\Cache -> yarn.lock'
- '%LOCALAPPDATA%\electron-builder\cache -> yarn.lock'
- '%LOCALAPPDATA%\Yarn\cache'
build_script:

View File

@ -36,143 +36,140 @@
"@hfelix/electron-localshortcut": "^3.1.1",
"@hfelix/electron-spellchecker": "^2.0.0",
"@octokit/rest": "^16.43.2",
"arg": "^5.0.0",
"axios": "^0.21.0",
"arg": "^5.0.1",
"axios": "0.22.0",
"ced": "^1.0.0",
"chokidar": "^3.4.3",
"codemirror": "^5.59.0",
"chokidar": "^3.5.2",
"codemirror": "^5.64.0",
"command-exists": "^1.2.9",
"dayjs": "^1.9.7",
"dayjs": "^1.10.7",
"dom-autoscroller": "^2.3.4",
"dompurify": "^2.2.6",
"dompurify": "^2.3.3",
"dragula": "^3.7.3",
"electron-is-accelerator": "^0.2.0",
"electron-log": "^4.3.1",
"electron-store": "^6.0.1",
"electron-log": "^4.4.1",
"electron-store": "^8.0.1",
"electron-window-state": "^5.0.3",
"element-resize-detector": "^1.2.1",
"element-ui": "^2.14.1",
"element-resize-detector": "^1.2.3",
"element-ui": "^2.15.7",
"execall": "^2.0.0",
"file-icons-js": "1.0.3",
"flowchart.js": "^1.15.0",
"fontmanager-redux": "^1.0.0",
"fs-extra": "^9.0.1",
"flowchart.js": "^1.17.0",
"fontmanager-redux": "^1.1.0",
"fs-extra": "^10.0.0",
"fuzzaldrin": "^2.1.0",
"github-markdown-css": "^3.0.1",
"html-tags": "^3.1.0",
"iconv-lite": "^0.6.2",
"iso-639-1": "^2.1.5",
"iconv-lite": "^0.6.3",
"iso-639-1": "^2.1.10",
"joplin-turndown-plugin-gfm": "^1.0.12",
"katex": "^0.12.0",
"katex": "^0.15.1",
"keyboard-layout": "^2.0.17",
"keytar": "^7.3.0",
"mermaid": "^8.8.4",
"plist": "^3.0.1",
"keytar": "^7.7.0",
"mermaid": "8.8.4",
"plist": "^3.0.4",
"popper.js": "^1.16.1",
"prismjs": "^1.22.0",
"prismjs": "^1.25.0",
"snabbdom": "^0.7.4",
"snabbdom-to-html": "^6.0.0",
"source-map-support": "^0.5.19",
"turndown": "^7.0.0",
"underscore": "^1.12.0",
"source-map-support": "^0.5.21",
"turndown": "^7.1.1",
"underscore": "^1.13.1",
"unsplash-js": "^6.3.0",
"vega": "^5.17.3",
"vega-embed": "^6.14.2",
"vega-lite": "^4.17.0",
"vscode-ripgrep": "^1.11.1",
"vue": "^2.6.12",
"vscode-ripgrep": "^1.12.1",
"vue": "^2.6.14",
"vue-electron": "^1.0.6",
"vue-router": "^3.4.9",
"vuex": "^3.6.0",
"vue-router": "^3.5.3",
"vuex": "^3.6.2",
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-export-default-from": "^7.12.1",
"@babel/plugin-proposal-function-bind": "^7.12.1",
"@babel/plugin-syntax-class-properties": "^7.12.1",
"@babel/core": "^7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-export-default-from": "^7.16.0",
"@babel/plugin-proposal-function-bind": "^7.16.0",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/register": "^7.12.10",
"@babel/runtime": "^7.12.5",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/register": "^7.16.0",
"@babel/runtime": "^7.16.3",
"@markedjs/html-differ": "^3.0.4",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-loader": "^8.2.3",
"babel-plugin-component": "^1.1.1",
"babel-plugin-istanbul": "^6.0.0",
"cfonts": "^2.9.0",
"chai": "^4.2.0",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.3",
"babel-plugin-istanbul": "^6.1.1",
"cfonts": "^2.10.0",
"chai": "^4.3.4",
"chalk": "^4.1.2",
"cheerio": "^1.0.0-rc.10",
"copy-webpack-plugin": "^5.1.2",
"cross-env": "^7.0.3",
"css-loader": "^3.6.0",
"del": "^5.1.0",
"devtron": "^1.4.0",
"dotenv": "^8.2.0",
"dotenv": "^10.0.0",
"electron": "^13.6.1",
"electron-builder": "^22.10.4",
"electron-devtools-installer": "^3.1.1",
"electron-rebuild": "^3.2.3",
"electron-updater": "^4.3.7",
"eslint": "^7.15.0",
"electron-builder": "^22.14.8",
"electron-devtools-installer": "^3.2.0",
"electron-rebuild": "^3.2.5",
"electron-updater": "^4.6.3",
"eslint": "^7.32.0",
"eslint-config-standard": "^14.1.1",
"eslint-friendly-formatter": "^4.0.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-loader": "^4.0.2",
"eslint-plugin-html": "^6.1.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"eslint-plugin-vue": "^6.2.2",
"esm": "^3.2.25",
"file-loader": "^6.2.0",
"git-revision-webpack-plugin": "^3.0.6",
"html-webpack-plugin": "^4.5.0",
"html-webpack-plugin": "^4.5.2",
"imports-loader": "^0.8.0",
"karma": "^5.2.3",
"karma": "^6.3.9",
"karma-chai": "^0.1.0",
"karma-coverage": "^2.0.3",
"karma-electron": "6.3.1",
"karma-electron": "^7.1.0",
"karma-mocha": "^2.0.1",
"karma-sourcemap-loader": "^0.3.8",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "^4.0.2",
"karma-webpack": "^5.0.0",
"license-checker": "^25.0.1",
"marked": "^1.2.7",
"mini-css-extract-plugin": "^0.12.0",
"mocha": "^7.2.0",
"marked": "^1.2.9",
"mini-css-extract-plugin": "^1.6.2",
"mocha": "^8.4.0",
"multispinner": "^0.2.1",
"node-fetch": "^2.6.1",
"node-loader": "^0.6.0",
"node-fetch": "^2.6.6",
"node-loader": "^1.0.3",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"raw-loader": "^4.0.2",
"require-dir": "^1.2.0",
"spectron": "^13.0.0",
"style-loader": "^1.3.0",
"spectron": "^15.0.0",
"style-loader": "^2.0.0",
"svg-sprite-loader": "^4.3.0",
"svgo": "^1.3.2",
"svgo-loader": "^2.2.1",
"to-string-loader": "^1.1.6",
"svgo-loader": "^2.2.2",
"to-string-loader": "^1.2.0",
"url-loader": "^4.1.1",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.9.6",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.6.12",
"webpack": "^4.44.2",
"vue-loader": "^15.9.8",
"vue-style-loader": "^4.1.3",
"vue-template-compiler": "^2.6.14",
"webpack": "^4.46.0",
"webpack-bundle-analyzer": "^3.9.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-hot-middleware": "^2.25.0",
"webpack-dev-server": "^3.11.3",
"webpack-hot-middleware": "^2.25.1",
"webpack-merge": "^4.2.2"
},
"resolutions": {
"node-abi": "^2.26.0"
},
"repository": {
"type": "git",
"url": "git@github.com:marktext/marktext.git"

View File

@ -107,8 +107,8 @@ class App {
contents.on('will-navigate', event => {
event.preventDefault()
})
contents.on('new-window', event => {
event.preventDefault()
contents.setWindowOpenHandler(details => {
return { action: 'deny' }
})
})

View File

@ -9,10 +9,8 @@ require('dotenv').config()
// Install `vue-devtools`
require('electron').app.on('ready', () => {
let installExtension = require('electron-devtools-installer')
// WORKAROUND: Electron: 2.0.0 does not match required range
// https://github.com/MarshallOfSound/electron-devtools-installer/issues/73
installExtension.default(installExtension.VUEJS_DEVTOOLS.id)
const { default: installExtension, VUEJS_DEVTOOLS } = require('electron-devtools-installer')
installExtension(VUEJS_DEVTOOLS)
.then(() => {})
.catch(err => {
console.log('Unable to install `vue-devtools`: \n', err)

View File

@ -140,7 +140,13 @@ const actions = {
})
bus.$on('SIDEBAR::remove', () => {
const { pathname } = state.activeItem
shell.moveItemToTrash(pathname)
shell.trashItem(pathname).catch(err => {
notice.notify({
title: 'Deletion Error',
type: 'error',
message: err.message
})
})
})
bus.$on('SIDEBAR::copy-cut', type => {
const { pathname: src } = state.activeItem

View File

@ -1,5 +1,7 @@
'use strict'
const fs = require('fs')
const path = require('path')
const merge = require('webpack-merge')
const webpack = require('webpack')
@ -8,6 +10,15 @@ const baseConfig = require('../../.electron-vue/webpack.renderer.config')
// Set BABEL_ENV to use proper preset config
process.env.BABEL_ENV = 'test'
// We need to create the build directory before launching Karma.
try {
fs.mkdirSync(path.join('dist', 'electron'), { recursive: true })
} catch(e) {
if (e.code !== 'EEXIST') {
throw e
}
}
let webpackConfig = merge(baseConfig, {
devtool: '#inline-source-map',
plugins: [
@ -29,6 +40,8 @@ delete webpackConfig.output.libraryTarget
module.exports = config => {
config.set({
browserNoActivityTimeout: 120000,
browserDisconnectTimeout: 60000,
browsers: ['CustomElectron'],
customLaunchers: {
CustomElectron: {
@ -38,7 +51,9 @@ module.exports = config => {
enableRemoteModule: true,
contextIsolation: false,
spellcheck: false,
nodeIntegration: true
nodeIntegration: true,
webSecurity: false,
sandbox: false
}
}
}
@ -54,7 +69,7 @@ module.exports = config => {
{ type: 'text-summary' }
]
},
frameworks: ['mocha', 'chai'],
frameworks: ['mocha', 'chai', 'webpack'],
files: ['./index.js'],
preprocessors: {
'./index.js': ['webpack', 'sourcemap']

5197
yarn.lock

File diff suppressed because it is too large Load Diff