feat: ci build/test/make (github workflows)
This commit is contained in:
64
.github/workflows/ci.yml
vendored
Normal file
64
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
name: 'CI'
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macOS-latest, ubuntu-latest, windows-latest]
|
||||
node-version: [14.x, 15.x, 16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
# npm cache files are stored in `~/.npm`
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
${{ runner.os }}-build-
|
||||
${{ runner.os }}-
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Upgrade to the latest version of npm
|
||||
run: npm install -g npm@latest
|
||||
- name: Upgrade to the latest version of Angular CLI
|
||||
run: npm install -g @angular/cli@latest
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Test Angular E2E
|
||||
uses: GabrielBB/xvfb-action@v1
|
||||
with:
|
||||
run: npm run test:angular-e2e
|
||||
- name: Test Electron E2E
|
||||
uses: GabrielBB/xvfb-action@v1
|
||||
with:
|
||||
run: npm run test:electron-e2e
|
||||
- name: Check lint
|
||||
run: npm run lint
|
||||
- name: Make app distributables
|
||||
run: npm run make
|
||||
16
.travis.yml
16
.travis.yml
@@ -1,16 +0,0 @@
|
||||
language: node_js
|
||||
dist: xenial
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
node_js:
|
||||
- "14"
|
||||
addons:
|
||||
chrome: stable
|
||||
services:
|
||||
- xvfb
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npm run test:electron-e2e
|
||||
- npm run make
|
||||
22
README.md
22
README.md
@@ -1,5 +1,5 @@
|
||||
<a href="https://github.com/sourcygen/electron-angular-quick-start/actions"><img src="https://github.com/sourcygen/electron-angular-quick-start/workflows/CI/badge.svg?branch=master" alt="CI Status"/></a>
|
||||
<a href="https://gitHub.com/sourcygen/electron-angular-quick-start/graphs/commit-activity"><img src="https://img.shields.io/badge/maintained-yes-brightgreen.svg" alt="Maintenance Status"/></a>
|
||||
<a href="https://travis-ci.org/sourcygen/electron-angular-quick-start"><img src="https://travis-ci.org/sourcygen/electron-angular-quick-start.svg?branch=master" alt="Build Status"/></a>
|
||||
<a href="https://github.com/sourcygen/electron-angular-quick-start/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="License MIT"></a>
|
||||
<a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"></a>
|
||||
<a href="https://twitter.com/share?text=Build%20cross%20platform%20desktop%20app%20with%20Electron%20and%20Angular%20%F0%9F%9A%80&url=https://github.com/sourcygen/electron-angular-quick-start"><img src="https://img.shields.io/twitter/url/https/github.com/sourcygen/electron-angular-quick-start.svg?style=social" alt="Tweet" align="right"></a>
|
||||
@@ -47,18 +47,28 @@ Depending on your need, putting up [Electron](https://www.electronjs.org/) and [
|
||||
|
||||
## Getting started
|
||||
|
||||
To clone and run this repository, you'll need [Git](https://git-scm.com), [Node.js](https://nodejs.org/en/download/) and [Angular-CLI](https://angular.io/cli) installed on your computer. And then from your command line:
|
||||
To clone and run this repository, you'll need installed on your computer at least :
|
||||
|
||||
- [Git](https://git-scm.com)
|
||||
- [Node 14](https://nodejs.org/en/download/)
|
||||
- [Npm 7](https://docs.npmjs.com/about-npm)
|
||||
- [Angular-CLI 12](https://angular.io/cli)
|
||||
|
||||
Then from your command line:
|
||||
|
||||
```bash
|
||||
# First, clone this repository
|
||||
# Upgrade to the latest version of npm (if necessary)
|
||||
npm install -g npm@latest
|
||||
|
||||
# Upgrade to the latest version of Angular CLI (if necessary)
|
||||
npm install -g @angular/cli@latest
|
||||
|
||||
# Clone this repository
|
||||
git clone https://github.com/sourcygen/electron-angular-quick-start.git
|
||||
|
||||
# Then go into the repository
|
||||
cd electron-angular-quick-start
|
||||
|
||||
# Install Angular CLI globally (if necessary)
|
||||
npm install -g @angular/cli
|
||||
|
||||
# After that, install dependencies
|
||||
npm install
|
||||
|
||||
|
||||
3
package-lock.json
generated
3
package-lock.json
generated
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "electron-angular-quick-start",
|
||||
"name": "electron-angular-app",
|
||||
"version": "2.2.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "electron-angular-app",
|
||||
"version": "2.2.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
|
||||
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron-angular-quick-start",
|
||||
"productName": "electron-angular-quick-start",
|
||||
"name": "electron-angular-app",
|
||||
"productName": "Electron Angular App",
|
||||
"version": "2.2.0",
|
||||
"description": "An Electron and Angular Quick-starter",
|
||||
"repository": "https://github.com/sourcygen/electron-angular-quick-start.git",
|
||||
@@ -30,13 +30,14 @@
|
||||
"start:electron-app": "node scripts/electron-forge-start-watch.js",
|
||||
"start:electron-app:once": "wait-on http://localhost:4200 && electron-forge start",
|
||||
"package": "npm run package:angular-app && npm run package:electron-app",
|
||||
"package:angular-app": "cd workspaces/angular-app && npm run package",
|
||||
"package:electron-app": "electron-forge package",
|
||||
"package:shared-lib": "tsc -b workspaces/shared-lib",
|
||||
"package:angular-app": "npm run package:shared-lib && cd workspaces/angular-app && npm run package",
|
||||
"package:electron-app": "npm run package:shared-lib && electron-forge package",
|
||||
"make": "npm run package:angular-app && electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "eslint --ext .ts .",
|
||||
"lint": "npm run package:shared-lib && eslint --ext .ts .",
|
||||
"test:e2e": "npm run test:angular-e2e && npm run test:electron-e2",
|
||||
"test:angular-e2e": "npm-run-all -p -r start:angular-app start:angular-e2e",
|
||||
"test:angular-e2e": "npm-run-all -p -r start start:angular-e2e",
|
||||
"start:angular-e2e": "wait-on http://localhost:4200 && cd workspaces/angular-app && npm run cypress:run",
|
||||
"test:electron-e2e": "npm run package && cross-env X_NODE_ENV=e2e-test node workspaces/electron-e2e/jasmine.js",
|
||||
"clean": "shx rm -rf .webpack out node_modules workspaces/shared-lib/.dist workspaces/angular-app/node_modules workspaces/angular-app/.dist",
|
||||
@@ -49,7 +50,8 @@
|
||||
"config": {
|
||||
"forge": {
|
||||
"packagerConfig": {
|
||||
"name": "electron-angular",
|
||||
"name": "Electron Angular App",
|
||||
"executableName": "electron-angular-app",
|
||||
"icon": "./workspaces/electron-app/main/assets/icons/icon"
|
||||
},
|
||||
"makers": [
|
||||
@@ -62,7 +64,8 @@
|
||||
"config": {}
|
||||
},
|
||||
{
|
||||
"name": "@electron-forge/maker-squirrel"
|
||||
"name": "@electron-forge/maker-squirrel",
|
||||
"config": {}
|
||||
}
|
||||
],
|
||||
"plugins": [
|
||||
|
||||
@@ -4,7 +4,6 @@ const { SpecReporter } = require('jasmine-spec-reporter');
|
||||
const jasmine = new Jasmine();
|
||||
jasmine.loadConfig({
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 15000,
|
||||
spec_dir: 'workspaces/electron-e2e',
|
||||
spec_files: ['./**/*-spec.ts'],
|
||||
helpers: ['./**/*-helper.ts'],
|
||||
|
||||
32
workspaces/electron-e2e/src/_hooks.ts
Normal file
32
workspaces/electron-e2e/src/_hooks.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as path from 'path';
|
||||
import { Application } from 'spectron';
|
||||
|
||||
export async function startApp(): Promise<Application> {
|
||||
// Path to local electron binary
|
||||
let electronPath = path.join(
|
||||
__dirname,
|
||||
'../../../node_modules/.bin/electron'
|
||||
);
|
||||
if (process.platform === 'win32') {
|
||||
electronPath += '.cmd';
|
||||
}
|
||||
|
||||
// Init local packaged app
|
||||
const app = new Application({
|
||||
path: electronPath,
|
||||
args: ['.webpack/main/index.js'],
|
||||
});
|
||||
|
||||
// Init local app and wait until window loaded
|
||||
await app.start();
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
return app;
|
||||
}
|
||||
|
||||
export async function stopApp(app: Application): Promise<void> {
|
||||
if (app && app.isRunning()) {
|
||||
// Wait 1 second and then stop local app
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
await app.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,15 @@
|
||||
import * as path from 'path';
|
||||
import { Application } from 'spectron';
|
||||
import { startApp, stopApp } from './_hooks';
|
||||
|
||||
describe('A simple test to verify a visible window is opened with a title', () => {
|
||||
// Init local app
|
||||
const app = new Application({
|
||||
path: path.join(__dirname, '../../../node_modules/.bin/electron'),
|
||||
args: [path.join(__dirname, '../../../.webpack/main/index.js')],
|
||||
});
|
||||
let app: Application;
|
||||
|
||||
beforeAll(async () => {
|
||||
// Init local app and wait until window loaded
|
||||
await app.start();
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
app = await startApp();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
// Wait 1 second and then stop local app
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
await app.stop();
|
||||
}
|
||||
await stopApp(app);
|
||||
});
|
||||
|
||||
it('shows an initial window', async () => {
|
||||
|
||||
Reference in New Issue
Block a user