Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#200) Maintenance/GitHub actions ci #201

Merged
merged 25 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e73fc7b
Started working on snapshot workflow
s1hofmann Dec 30, 2020
b8f57de
Started working on snapshot workflow
s1hofmann Dec 30, 2020
2230084
Started working on snapshot workflow
s1hofmann Dec 30, 2020
f8c85b7
Renamed coverage steps
s1hofmann Dec 30, 2020
cc201f8
Updated Docker test run
s1hofmann Dec 30, 2020
491cf79
Updated window integration test to reflect limited default screen siz…
s1hofmann Dec 30, 2020
8322c10
Updated Sonar project key
s1hofmann Dec 30, 2020
538c8a6
Enabled matrix build and release jobs
s1hofmann Dec 30, 2020
611124f
Limit Docker tests to Linux
s1hofmann Dec 30, 2020
56df049
Limit Docker tests to Linux
s1hofmann Dec 30, 2020
fe8bea8
Limit Docker tests to Linux
s1hofmann Dec 30, 2020
260abc8
Remove macOS from test job for debugging
s1hofmann Jan 2, 2021
f837d94
Only run macOS for further debugging
s1hofmann Jan 5, 2021
f759400
Enabled big sur
s1hofmann Jan 5, 2021
adbe092
Added tmate step for debugging
s1hofmann Jan 6, 2021
5138843
Modify resize test to verify consistent failure
s1hofmann Jan 6, 2021
c5db847
Updated window integration tests to restart the test app before each run
s1hofmann Jan 6, 2021
1309463
Added small timeouts to account for possibly slow window movement
s1hofmann Jan 6, 2021
760c0bd
Added small timeouts to account for possibly slow window movement
s1hofmann Jan 6, 2021
96d122c
Working cross-platform setup for CI, snapshot releases as well as tag…
s1hofmann Jan 6, 2021
2c71266
Increased Jest timeout for window tests to account for possible slowd…
s1hofmann Jan 6, 2021
6924262
(#200) Delete Travis and Appveyor configs
s1hofmann Jan 6, 2021
1a57269
(#200) Applied review remarks
s1hofmann Jan 7, 2021
18d4784
(#200) Added missing sonar organization to config
s1hofmann Jan 7, 2021
08be7d4
(#200) Updated build status badges in README.md
s1hofmann Jan 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .build/pre-release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -ex

echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm whoami

npm ci
patchVersion=$(npm --no-git-tag version patch)
nextVersion=${patchVersion}-next."$(date +%Y%m%d%H%M%S)"
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Run CI
on:
push:
branches-ignore:
- develop
- release/**
pull_request:

jobs:
sonar:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Setup Docker
run: |
docker pull s1hofmann/nut-ci:latest
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
- name: Install
run: npm ci
- name: Compile
run: npm run compile
- name: Init e2e test subpackage
run: npm --prefix e2e/tests ci
- name: Clean coverage report
run: npm run coverage:clean
- name: Generate coverage report
uses: GabrielBB/xvfb-action@v1
with:
run: npm run coverage -- --coverageDirectory=coverage/unit
- name: Run Docker E2E tests
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} 14"
- name: Merge coverage reports
run: |
npm run coverage:merge
npm run coverage:merge-report
- name: Send results to SonarCloud
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

test:
needs:
- sonar
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
node: [ 10, 12, 14 ]
exclude:
- os: ubuntu-latest
node: 14
runs-on: ${{matrix.os}}
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node}}
- name: Setup Docker
if: ${{matrix.os == 'ubuntu-latest'}}
run: |
docker pull s1hofmann/nut-ci:latest
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
- name: Install
run: npm ci
- name: Compile
run: npm run compile
- name: Init e2e test subpackage
run: npm --prefix e2e/tests ci
- name: Generate coverage report
uses: GabrielBB/xvfb-action@v1
with:
run: npm run coverage -- --coverageDirectory=coverage/unit
Comment on lines +76 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to create a coverage report again here? Sonar analysis is already done as far as I can see.

- name: Run Docker E2E tests
if: ${{matrix.os == 'ubuntu-latest'}}
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"
57 changes: 57 additions & 0 deletions .github/workflows/snapshot_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create snapshot release
on:
push:
branches:
- develop

jobs:
test:
needs:
- sonar
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
node: [ 10, 12, 14 ]
runs-on: ${{matrix.os}}
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node}}
- name: Setup Docker
if: ${{matrix.os == 'ubuntu-latest'}}
run: |
docker pull s1hofmann/nut-ci:latest
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
- name: Install
run: npm ci
- name: Compile
run: npm run compile
- name: Init e2e test subpackage
run: npm --prefix e2e/tests ci
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: npm test
- name: Run Docker E2E tests
if: ${{matrix.os == 'ubuntu-latest'}}
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"

deploy:
needs:
- sonar
- test
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Publish snapshot release
run: bash ./.build/pre-release.sh
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/tagged_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create tagged release
on:
push:
tags:
- v*.*.*

jobs:
test:
needs:
- sonar
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
node: [ 10, 12, 14 ]
runs-on: ${{matrix.os}}
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node}}
- name: Setup Docker
if: ${{matrix.os == 'ubuntu-latest'}}
run: |
docker pull s1hofmann/nut-ci:latest
docker run -it -d --name nut-ci --shm-size 4gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
- name: Install
run: npm ci
- name: Compile
run: npm run compile
- name: Init e2e test subpackage
run: npm --prefix e2e/tests ci
- name: Generate coverage report
uses: GabrielBB/xvfb-action@v1
with:
run: npm test
- name: Run Docker E2E tests
if: ${{matrix.os == 'ubuntu-latest'}}
run: docker exec nut-ci bash -c "bash $PWD/.build/build.sh ${PWD} ${{matrix.node}}"

deploy:
needs:
- sonar
- test
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Publish tagged release
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# nut.js (Native UI Toolkit)

| |Travis |Appveyor |
|:-: |:-: |:-: |
|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)|
|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)|
| |GitHub Actions|
|:-: |:-: |
|Master |![Run CI](https://github.com/nut-tree/nut.js/workflows/Run%20CI/badge.svg?branch=master)|
|Develop|![Run CI](https://github.com/nut-tree/nut.js/workflows/Run%20CI/badge.svg?branch=develop)|

![Supported node versions](https://img.shields.io/badge/node-v10.x%20--%20v14.x-green)
[![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)
Expand Down
31 changes: 0 additions & 31 deletions appveyor.yml

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/tests/packages/window-integration-tests/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const POS_X = 50;
const POS_Y = 100;
const WIDTH = 800;
const HEIGTH = 600;
const WIDTH = 400;
const HEIGTH = 300;
const TITLE = "libnut window test";

module.exports = {
Expand Down
17 changes: 12 additions & 5 deletions e2e/tests/packages/window-integration-tests/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const Application = require("spectron").Application;
const electronPath = require("electron");
const {getActiveWindow, getWindows} = require("@nut-tree/nut-js");
const { POS_X, POS_Y, WIDTH, HEIGTH, TITLE } = require("./constants");
const { join } = require("path");
const {POS_X, POS_Y, WIDTH, HEIGTH, TITLE} = require("./constants");
const {join} = require("path");

const sleep = async (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
};

let app;
const APP_TIMEOUT = 10000;
jest.setTimeout(3 * APP_TIMEOUT)

beforeAll(async () => {
beforeEach(async () => {
app = new Application({
path: electronPath,
args: [join(__dirname, 'main.js')],
Expand Down Expand Up @@ -65,6 +70,7 @@ describe("getActiveWindow", () => {
const xPosition = 42;
const yPosition = 23;
await app.browserWindow.setPosition(xPosition, yPosition);
await sleep(1000);

// WHEN
const foregroundWindow = await getActiveWindow();
Expand All @@ -78,8 +84,9 @@ describe("getActiveWindow", () => {
it("should determine correct window size for our application after resizing the window", async () => {
// GIVEN
const newWidth = 400;
const newHeight = 250;
const newHeight = 350;
await app.browserWindow.setSize(newWidth, newHeight);
await sleep(1000);

// WHEN
const foregroundWindow = await getActiveWindow();
Expand All @@ -91,7 +98,7 @@ describe("getActiveWindow", () => {
});
});

afterAll(async () => {
afterEach(async () => {
if (app && app.isRunning()) {
await app.stop();
}
Expand Down
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sonar.projectKey=nut-tree:nut.js
sonar.organization=nut-tree
sonar.sources=lib/,index.ts
sonar.javascript.lcov.reportPaths=coverage/merged/lcov.info
sonar.typescript.lcov.reportPaths=coverage/merged/lcov.info
Expand Down