Skip to content

Commit f590c60

Browse files
authored
Merge pull request #201 from nut-tree/maintenance/github_actions_ci
(#200) Maintenance/GitHub actions ci
2 parents 72df841 + 08be7d4 commit f590c60

File tree

10 files changed

+218
-116
lines changed

10 files changed

+218
-116
lines changed

.build/pre-release.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22
set -ex
33

4+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
5+
npm whoami
6+
47
npm ci
58
patchVersion=$(npm --no-git-tag version patch)
69
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"

.github/workflows/ci.yaml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Run CI
2+
on:
3+
push:
4+
branches-ignore:
5+
- develop
6+
- release/**
7+
pull_request:
8+
9+
jobs:
10+
sonar:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Set up Git repository
14+
uses: actions/checkout@v2
15+
- name: Set up node
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: 14
19+
- name: Setup Docker
20+
run: |
21+
docker pull s1hofmann/nut-ci:latest
22+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
23+
- name: Install
24+
run: npm ci
25+
- name: Compile
26+
run: npm run compile
27+
- name: Init e2e test subpackage
28+
run: npm --prefix e2e/tests ci
29+
- name: Clean coverage report
30+
run: npm run coverage:clean
31+
- name: Generate coverage report
32+
uses: GabrielBB/xvfb-action@v1
33+
with:
34+
run: npm run coverage -- --coverageDirectory=coverage/unit
35+
- name: Run Docker E2E tests
36+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"
37+
- name: Merge coverage reports
38+
run: |
39+
npm run coverage:merge
40+
npm run coverage:merge-report
41+
- name: Send results to SonarCloud
42+
uses: SonarSource/[email protected]
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
46+
47+
test:
48+
needs:
49+
- sonar
50+
strategy:
51+
matrix:
52+
os: [ ubuntu-latest, windows-latest, macos-latest ]
53+
node: [ 10, 12, 14 ]
54+
exclude:
55+
- os: ubuntu-latest
56+
node: 14
57+
runs-on: ${{matrix.os}}
58+
steps:
59+
- name: Set up Git repository
60+
uses: actions/checkout@v2
61+
- name: Set up node
62+
uses: actions/setup-node@v2
63+
with:
64+
node-version: ${{matrix.node}}
65+
- name: Setup Docker
66+
if: ${{matrix.os == 'ubuntu-latest'}}
67+
run: |
68+
docker pull s1hofmann/nut-ci:latest
69+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
70+
- name: Install
71+
run: npm ci
72+
- name: Compile
73+
run: npm run compile
74+
- name: Init e2e test subpackage
75+
run: npm --prefix e2e/tests ci
76+
- name: Generate coverage report
77+
uses: GabrielBB/xvfb-action@v1
78+
with:
79+
run: npm run coverage -- --coverageDirectory=coverage/unit
80+
- name: Run Docker E2E tests
81+
if: ${{matrix.os == 'ubuntu-latest'}}
82+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Create snapshot release
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
7+
jobs:
8+
test:
9+
needs:
10+
- sonar
11+
strategy:
12+
matrix:
13+
os: [ ubuntu-latest, windows-latest, macos-latest ]
14+
node: [ 10, 12, 14 ]
15+
runs-on: ${{matrix.os}}
16+
steps:
17+
- name: Set up Git repository
18+
uses: actions/checkout@v2
19+
- name: Set up node
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: ${{matrix.node}}
23+
- name: Setup Docker
24+
if: ${{matrix.os == 'ubuntu-latest'}}
25+
run: |
26+
docker pull s1hofmann/nut-ci:latest
27+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
28+
- name: Install
29+
run: npm ci
30+
- name: Compile
31+
run: npm run compile
32+
- name: Init e2e test subpackage
33+
run: npm --prefix e2e/tests ci
34+
- name: Run tests
35+
uses: GabrielBB/xvfb-action@v1
36+
with:
37+
run: npm test
38+
- name: Run Docker E2E tests
39+
if: ${{matrix.os == 'ubuntu-latest'}}
40+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"
41+
42+
deploy:
43+
needs:
44+
- sonar
45+
- test
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Set up Git repository
49+
uses: actions/checkout@v2
50+
- name: Set up node
51+
uses: actions/setup-node@v2
52+
with:
53+
node-version: 14
54+
- name: Publish snapshot release
55+
run: bash ./.build/pre-release.sh
56+
env:
57+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tagged_release.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Create tagged release
2+
on:
3+
push:
4+
tags:
5+
- v*.*.*
6+
7+
jobs:
8+
test:
9+
needs:
10+
- sonar
11+
strategy:
12+
matrix:
13+
os: [ ubuntu-latest, windows-latest, macos-latest ]
14+
node: [ 10, 12, 14 ]
15+
runs-on: ${{matrix.os}}
16+
steps:
17+
- name: Set up Git repository
18+
uses: actions/checkout@v2
19+
- name: Set up node
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: ${{matrix.node}}
23+
- name: Setup Docker
24+
if: ${{matrix.os == 'ubuntu-latest'}}
25+
run: |
26+
docker pull s1hofmann/nut-ci:latest
27+
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
28+
- name: Install
29+
run: npm ci
30+
- name: Compile
31+
run: npm run compile
32+
- name: Init e2e test subpackage
33+
run: npm --prefix e2e/tests ci
34+
- name: Generate coverage report
35+
uses: GabrielBB/xvfb-action@v1
36+
with:
37+
run: npm test
38+
- name: Run Docker E2E tests
39+
if: ${{matrix.os == 'ubuntu-latest'}}
40+
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"
41+
42+
deploy:
43+
needs:
44+
- sonar
45+
- test
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Set up Git repository
49+
uses: actions/checkout@v2
50+
- name: Set up node
51+
uses: actions/setup-node@v2
52+
with:
53+
node-version: 14
54+
- name: Publish tagged release
55+
uses: JS-DevTools/npm-publish@v1
56+
with:
57+
token: ${{ secrets.NPM_TOKEN }}

.travis.yml

-74
This file was deleted.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# nut.js (Native UI Toolkit)
22

3-
| |Travis |Appveyor |
4-
|:-: |:-: |:-: |
5-
|Master |[![Build Status](https://travis-ci.com/nut-tree/nut.js.svg?branch=master)](https://travis-ci.com/nut-tree/nut.js)|[![Build status](https://ci.appveyor.com/api/projects/status/iohwxc5t46gcuvby/branch/master?svg=true)](https://ci.appveyor.com/project/s1hofmann/nut-js/branch/master)|
6-
|Develop|[![Build Status](https://travis-ci.com/nut-tree/nut.js.svg?branch=develop)](https://travis-ci.com/nut-tree/nut.js)|[![Build status](https://ci.appveyor.com/api/projects/status/iohwxc5t46gcuvby/branch/develop?svg=true)](https://ci.appveyor.com/project/s1hofmann/nut-js/branch/develop)|
3+
| |GitHub Actions|
4+
|:-: |:-: |
5+
|Master |![Run CI](https://github.com/nut-tree/nut.js/workflows/Run%20CI/badge.svg?branch=master)|
6+
|Develop|![Run CI](https://github.com/nut-tree/nut.js/workflows/Run%20CI/badge.svg?branch=develop)|
77

88
![Supported node versions](https://img.shields.io/badge/node-v10.x%20--%20v14.x-green)
99
[![SonarCloud badge](https://sonarcloud.io/api/project_badges/measure?project=nut-tree%3Anut.js&metric=alert_status)](https://sonarcloud.io/dashboard?id=nut-tree%3Anut.js)

appveyor.yml

-31
This file was deleted.

e2e/tests/packages/window-integration-tests/constants.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const POS_X = 50;
22
const POS_Y = 100;
3-
const WIDTH = 800;
4-
const HEIGTH = 600;
3+
const WIDTH = 400;
4+
const HEIGTH = 300;
55
const TITLE = "libnut window test";
66

77
module.exports = {

e2e/tests/packages/window-integration-tests/test.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
const Application = require("spectron").Application;
22
const electronPath = require("electron");
33
const {getActiveWindow, getWindows} = require("@nut-tree/nut-js");
4-
const { POS_X, POS_Y, WIDTH, HEIGTH, TITLE } = require("./constants");
5-
const { join } = require("path");
4+
const {POS_X, POS_Y, WIDTH, HEIGTH, TITLE} = require("./constants");
5+
const {join} = require("path");
6+
7+
const sleep = async (ms) => {
8+
return new Promise(resolve => setTimeout(resolve, ms));
9+
};
610

711
let app;
812
const APP_TIMEOUT = 10000;
13+
jest.setTimeout(3 * APP_TIMEOUT)
914

10-
beforeAll(async () => {
15+
beforeEach(async () => {
1116
app = new Application({
1217
path: electronPath,
1318
args: [join(__dirname, 'main.js')],
@@ -65,6 +70,7 @@ describe("getActiveWindow", () => {
6570
const xPosition = 42;
6671
const yPosition = 23;
6772
await app.browserWindow.setPosition(xPosition, yPosition);
73+
await sleep(1000);
6874

6975
// WHEN
7076
const foregroundWindow = await getActiveWindow();
@@ -78,8 +84,9 @@ describe("getActiveWindow", () => {
7884
it("should determine correct window size for our application after resizing the window", async () => {
7985
// GIVEN
8086
const newWidth = 400;
81-
const newHeight = 250;
87+
const newHeight = 350;
8288
await app.browserWindow.setSize(newWidth, newHeight);
89+
await sleep(1000);
8390

8491
// WHEN
8592
const foregroundWindow = await getActiveWindow();
@@ -91,7 +98,7 @@ describe("getActiveWindow", () => {
9198
});
9299
});
93100

94-
afterAll(async () => {
101+
afterEach(async () => {
95102
if (app && app.isRunning()) {
96103
await app.stop();
97104
}

sonar-project.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sonar.projectKey=nut-tree:nut.js
2+
sonar.organization=nut-tree
23
sonar.sources=lib/,index.ts
34
sonar.javascript.lcov.reportPaths=coverage/merged/lcov.info
45
sonar.typescript.lcov.reportPaths=coverage/merged/lcov.info

0 commit comments

Comments
 (0)