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://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="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="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>
|
<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
|
## 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
|
```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
|
git clone https://github.com/sourcygen/electron-angular-quick-start.git
|
||||||
|
|
||||||
# Then go into the repository
|
# Then go into the repository
|
||||||
cd electron-angular-quick-start
|
cd electron-angular-quick-start
|
||||||
|
|
||||||
# Install Angular CLI globally (if necessary)
|
|
||||||
npm install -g @angular/cli
|
|
||||||
|
|
||||||
# After that, install dependencies
|
# After that, install dependencies
|
||||||
npm install
|
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",
|
"version": "2.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "electron-angular-app",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "electron-angular-quick-start",
|
"name": "electron-angular-app",
|
||||||
"productName": "electron-angular-quick-start",
|
"productName": "Electron Angular App",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"description": "An Electron and Angular Quick-starter",
|
"description": "An Electron and Angular Quick-starter",
|
||||||
"repository": "https://github.com/sourcygen/electron-angular-quick-start.git",
|
"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": "node scripts/electron-forge-start-watch.js",
|
||||||
"start:electron-app:once": "wait-on http://localhost:4200 && electron-forge start",
|
"start:electron-app:once": "wait-on http://localhost:4200 && electron-forge start",
|
||||||
"package": "npm run package:angular-app && npm run package:electron-app",
|
"package": "npm run package:angular-app && npm run package:electron-app",
|
||||||
"package:angular-app": "cd workspaces/angular-app && npm run package",
|
"package:shared-lib": "tsc -b workspaces/shared-lib",
|
||||||
"package:electron-app": "electron-forge package",
|
"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",
|
"make": "npm run package:angular-app && electron-forge make",
|
||||||
"publish": "electron-forge publish",
|
"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: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",
|
"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",
|
"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",
|
"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": {
|
"config": {
|
||||||
"forge": {
|
"forge": {
|
||||||
"packagerConfig": {
|
"packagerConfig": {
|
||||||
"name": "electron-angular",
|
"name": "Electron Angular App",
|
||||||
|
"executableName": "electron-angular-app",
|
||||||
"icon": "./workspaces/electron-app/main/assets/icons/icon"
|
"icon": "./workspaces/electron-app/main/assets/icons/icon"
|
||||||
},
|
},
|
||||||
"makers": [
|
"makers": [
|
||||||
@@ -62,7 +64,8 @@
|
|||||||
"config": {}
|
"config": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "@electron-forge/maker-squirrel"
|
"name": "@electron-forge/maker-squirrel",
|
||||||
|
"config": {}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ const { SpecReporter } = require('jasmine-spec-reporter');
|
|||||||
const jasmine = new Jasmine();
|
const jasmine = new Jasmine();
|
||||||
jasmine.loadConfig({
|
jasmine.loadConfig({
|
||||||
showColors: true,
|
showColors: true,
|
||||||
defaultTimeoutInterval: 15000,
|
|
||||||
spec_dir: 'workspaces/electron-e2e',
|
spec_dir: 'workspaces/electron-e2e',
|
||||||
spec_files: ['./**/*-spec.ts'],
|
spec_files: ['./**/*-spec.ts'],
|
||||||
helpers: ['./**/*-helper.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 { Application } from 'spectron';
|
||||||
|
import { startApp, stopApp } from './_hooks';
|
||||||
|
|
||||||
describe('A simple test to verify a visible window is opened with a title', () => {
|
describe('A simple test to verify a visible window is opened with a title', () => {
|
||||||
// Init local app
|
let app: Application;
|
||||||
const app = new Application({
|
|
||||||
path: path.join(__dirname, '../../../node_modules/.bin/electron'),
|
|
||||||
args: [path.join(__dirname, '../../../.webpack/main/index.js')],
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Init local app and wait until window loaded
|
app = await startApp();
|
||||||
await app.start();
|
|
||||||
await app.client.waitUntilWindowLoaded();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (app && app.isRunning()) {
|
await stopApp(app);
|
||||||
// Wait 1 second and then stop local app
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
||||||
await app.stop();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows an initial window', async () => {
|
it('shows an initial window', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user