Skip to content

Commit 3018ac3

Browse files
author
Ivan Efimov
authored
Merge pull request #2735 from mathiasvr/pr-github-actions-ci
Use GitHub Actions for CI
2 parents c4f7a8f + 55d27c6 commit 3018ac3

File tree

5 files changed

+184
-1
lines changed

5 files changed

+184
-1
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Builds Betaflight Configurator on Windows, Android, Linux and macOS platforms.
2+
#
3+
# After building, artifacts are released to a seperate repository.
4+
5+
env:
6+
debugBuild: true
7+
8+
name: CI
9+
10+
on:
11+
push:
12+
branches:
13+
- master
14+
- '*-maintenance'
15+
pull_request:
16+
branches:
17+
- master
18+
- '*-maintenance'
19+
20+
jobs:
21+
test:
22+
name: Test
23+
runs-on: ubuntu-20.04
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- name: Install Node.js
29+
uses: actions/setup-node@v2
30+
with:
31+
node-version-file: '.nvmrc'
32+
cache: yarn
33+
34+
- run: yarn install --immutable --immutable-cache --check-cache
35+
36+
- name: Run unit tests
37+
run: yarn test
38+
39+
- name: Publish Unit Test Results
40+
uses: EnricoMi/publish-unit-test-result-action@043296c976c53f4536194ebe3841ed720e04d496 # v1.26
41+
if: always()
42+
with:
43+
files: test-results-junit/**/*.xml
44+
comment_mode: 'off'
45+
46+
build:
47+
name: Build (${{ matrix.name }})
48+
needs: test
49+
runs-on: ${{ matrix.os }}
50+
strategy:
51+
matrix:
52+
include:
53+
- name: Android
54+
os: ubuntu-20.04
55+
releaseArgs: --android
56+
57+
- name: Linux
58+
os: ubuntu-20.04
59+
releaseArgs: --linux64
60+
61+
- name: macOS
62+
os: macos-11
63+
releaseArgs: --osx64
64+
65+
- name: Windows
66+
os: windows-2022
67+
releaseArgs: --win64
68+
steps:
69+
- uses: actions/checkout@v2
70+
71+
- name: Cache NW.js
72+
uses: actions/cache@v2
73+
with:
74+
path: cache/
75+
key: ${{ runner.os }}-${{ hashFiles('gulpfile.js') }}
76+
77+
- name: Install Node.js
78+
uses: actions/setup-node@v2
79+
with:
80+
node-version-file: '.nvmrc'
81+
cache: yarn
82+
83+
- name: Install Java JDK 8
84+
uses: actions/setup-java@v2
85+
if: ${{ matrix.name == 'Android' }}
86+
with:
87+
distribution: temurin
88+
java-version: '8'
89+
90+
- run: yarn install --immutable --immutable-cache --check-cache
91+
92+
- run: yarn gulp release ${{ matrix.releaseArgs }}
93+
if: ${{ !env.debugBuild }}
94+
95+
- run: yarn gulp debug-release ${{ matrix.releaseArgs }}
96+
if: ${{ env.debugBuild }}
97+
98+
- name: Publish build artifacts
99+
uses: actions/upload-artifact@v2
100+
with:
101+
name: Betaflight-Configurator${{ env.debugBuild == 'true' && '-Debug' || '' }}-${{ matrix.name }}
102+
path: release/
103+
retention-days: 10

.github/workflows/nightly.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# You'll need to setup the follwing environment variables:
2+
# env.repoNightly - The repository to release nightly builds to e.g. betaflight-configurator-nightly
3+
# env.releaseNotes - The release notes to be published as part of the github release
4+
# secrets.REPO_TOKEN - A GitHub token with permissions to push and publish releases to the nightly repo
5+
6+
env:
7+
repoNightly: betaflight/betaflight-configurator-nightlies
8+
debugReleaseNotes: >
9+
This is an automated development build.
10+
It may be unstable and result in corrupted configurations or data loss.
11+
**Use only for testing.**
12+
releaseNotes: This is a release build. It does not contain the debug console.
13+
14+
name: Nightly Build
15+
16+
on:
17+
workflow_run:
18+
workflows: [CI]
19+
types: [completed]
20+
21+
jobs:
22+
release-nightly:
23+
name: Release Nightly
24+
runs-on: ubuntu-20.04
25+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
26+
steps:
27+
- name: Fetch release assets
28+
uses: dawidd6/action-download-artifact@09385b76de790122f4da9c82b17bccf858b9557c # v2.16.0
29+
with:
30+
path: release-assets/
31+
workflow: ${{ github.event.workflow_run.workflow_id }}
32+
33+
- name: Select release notes
34+
id: notes
35+
run: |
36+
set -- release-assets/Betaflight-Configurator-Debug-*
37+
echo "::set-output name=notes::$(test -e "$1" && echo '${{ env.debugReleaseNotes }}' || echo '${{ env.releaseNotes }}')"
38+
39+
- name: Release
40+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
41+
with:
42+
token: ${{ secrets.REPO_TOKEN }}
43+
repository: ${{ env.repoNightly }}
44+
tag_name: build-${{ github.run_number }}
45+
files: release-assets/Betaflight-Configurator-*/**
46+
draft: false
47+
prerelease: false
48+
fail_on_unmatched_files: true
49+
name: '${{ github.repository }}: ${{ github.ref_name }}'
50+
body: |
51+
${{ steps.notes.outputs.notes }}
52+
53+
### Repository:
54+
${{ github.repository }} ([link](${{ github.event.repository.html_url }}))
55+
56+
### Branch:
57+
${{ github.ref_name }} ([link](${{ github.event.repository.html_url }}/tree/${{ github.ref_name }}))
58+
59+
### Latest changeset:
60+
${{ github.sha }} ([link](https://github.com/${{ github.repository }}/commit/${{ github.sha }}))
61+
62+
### Changes:
63+
${{ github.event.workflow_run.head_commit.message }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"karma": "^4.0.1",
107107
"karma-chai": "^0.1.0",
108108
"karma-chrome-launcher": "^3.0.0",
109+
"karma-junit-reporter": "^2.0.1",
109110
"karma-mocha": "^1.3.0",
110111
"karma-rollup-preprocessor": "^7.0.5",
111112
"karma-sinon": "^1.0.5",

test/karma.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const NODE_ENV = process.env.NODE_ENV || 'test';
66

77
module.exports = function(config) {
88
config.set({
9-
reporters: ['tfs', 'spec'],
9+
reporters: ['tfs', 'spec','junit'],
1010
basePath: '../',
1111
frameworks: ['mocha', 'chai', 'sinon-chai'],
1212
files: [
@@ -34,6 +34,9 @@ module.exports = function(config) {
3434
outputDir: 'testresults',
3535
outputFile: 'test_results.xml',
3636
},
37+
junitReporter: {
38+
outputDir: 'test-results-junit',
39+
},
3740
singleRun: true,
3841
preprocessors: {
3942
'./src/js/localization.js': ['rollup'],

yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5453,6 +5453,14 @@ karma-chrome-launcher@^3.0.0:
54535453
dependencies:
54545454
which "^1.2.1"
54555455

5456+
karma-junit-reporter@^2.0.1:
5457+
version "2.0.1"
5458+
resolved "https://registry.yarnpkg.com/karma-junit-reporter/-/karma-junit-reporter-2.0.1.tgz#d34eef7f0b2fd064e0896954e8851a90cf14c8f3"
5459+
integrity sha512-VtcGfE0JE4OE1wn0LK8xxDKaTP7slN8DO3I+4xg6gAi1IoAHAXOJ1V9G/y45Xg6sxdxPOR3THCFtDlAfBo9Afw==
5460+
dependencies:
5461+
path-is-absolute "^1.0.0"
5462+
xmlbuilder "12.0.0"
5463+
54565464
karma-mocha@^1.3.0:
54575465
version "1.3.0"
54585466
resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-1.3.0.tgz#eeaac7ffc0e201eb63c467440d2b69c7cf3778bf"
@@ -10131,6 +10139,11 @@ xdg-basedir@^3.0.0:
1013110139
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
1013210140
integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=
1013310141

10142+
10143+
version "12.0.0"
10144+
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-12.0.0.tgz#e2ed675e06834a089ddfb84db96e2c2b03f78c1a"
10145+
integrity sha512-lMo8DJ8u6JRWp0/Y4XLa/atVDr75H9litKlb2E5j3V3MesoL50EBgZDWoLT3F/LztVnG67GjPXLZpqcky/UMnQ==
10146+
1013410147
xmlbuilder@^9.0.0, xmlbuilder@^9.0.7:
1013510148
version "9.0.7"
1013610149
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"

0 commit comments

Comments
 (0)