Skip to content

Commit e1152ae

Browse files
Replace Travis with Github Actions (#35)
* add test workflow stub * matrix check all versions * try using giantswarm/install-binary-action * use full commit hash for install-binary-action * set tarball_binary_path in install_binary_action * add dependabot configuration * update sketch-templater * execute tests in ci * remove travis config * cleanup actions files * remove stray comment from workflow * fix package_sensebox_index.json Remove versions not available from releases * use sensors from models * validate stable packages only on master push * validate dev package * remove travis badges from readme * use sudo for dev validation preparation * show nginx status * merge setup & validate step * compile with dev package * try to explain dev + release * add/update libraries * fix Adafruit_BusIO location * Only cache arduino not sensebox packages Co-authored-by: Mario <mario.pesch@uni-muenster.de>
1 parent 98ff53b commit e1152ae

File tree

122 files changed

+9945
-6286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+9945
-6286
lines changed

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
assignees:
8+
- "ubergesundheit"
9+
- "mariopesch"
10+
11+
- package-ecosystem: "github-actions"
12+
directory: "/"
13+
schedule:
14+
interval: "daily"
15+
assignees:
16+
- "ubergesundheit"

.github/workflows/test.yaml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Test compilation with development package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
compile:
13+
name: Test compilation
14+
runs-on: ubuntu-20.04
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Copy arduino directory into /var/www/html
20+
run: |
21+
sudo cp -r arduino /var/www/html/
22+
23+
- name: Start nginx service
24+
run: |
25+
sudo systemctl start nginx.service
26+
sudo systemctl status nginx.service
27+
28+
- uses: actions/setup-node@v2
29+
with:
30+
node-version: '14'
31+
32+
- name: Cache node modules
33+
uses: actions/cache@v2
34+
env:
35+
cache-name: cache-node-modules
36+
with:
37+
# npm cache files are stored in `~/.npm` on Linux/macOS
38+
path: |
39+
~/.npm
40+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
41+
restore-keys: |
42+
${{ runner.os }}-build-${{ env.cache-name }}-
43+
${{ runner.os }}-build-
44+
${{ runner.os }}-
45+
46+
- name: Cache arduino-dir
47+
uses: actions/cache@v2
48+
env:
49+
cache-name: arduino-dir
50+
with:
51+
path: |
52+
~/.arduino15/packages/builtin
53+
~/.arduino15/packages/arduino
54+
key: ${{ runner.os }}-cache-${{ env.cache-name }}
55+
restore-keys: |
56+
${{ runner.os }}-cache-
57+
${{ runner.os }}-
58+
59+
- name: Install arduino-cli
60+
uses: giantswarm/install-binary-action@5972d5adf093d659091fa22c136a332453247b43
61+
with:
62+
binary: "arduino-cli"
63+
version: "0.16.1"
64+
download_url: "https://github.com/arduino/${binary}/releases/download/${version}/${binary}_${version}_Linux_64bit.tar.gz"
65+
tarball_binary_path: "${binary}"
66+
67+
- name: Try installing development core sensebox:samd
68+
run: arduino-cli --additional-urls "file://$(pwd)/package_sensebox-dev_index.json" core install sensebox:samd
69+
70+
- name: Install test deps
71+
run: |
72+
npm ci
73+
arduino-cli core install arduino:samd
74+
75+
- name: Compile mcu_component_test.ino
76+
run: |
77+
version=$(jq -r ".packages[0] | .platforms[0] | .version" package_sensebox-dev_index.json)
78+
arduino-cli compile --fqbn sensebox:samd:sb:power=on "/home/runner/.arduino15/packages/sensebox/hardware/samd/$version/libraries/tests/examples/mcu_component_test/mcu_component_test.ino"
79+
80+
- name: Execute test suite
81+
run: |
82+
npm run test
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Validate stable package index
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
setup:
10+
name: Setup test matrix
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Extract all versions
16+
id: set-matrix
17+
run: |
18+
echo "::set-output name=matrix::$(jq -crM '[.packages[0] | .platforms[] | .version ]' package_sensebox_index.json)"
19+
outputs:
20+
matrix: ${{ steps.set-matrix.outputs.matrix }}
21+
22+
validate:
23+
needs: setup
24+
name: Validate stable package index
25+
runs-on: ubuntu-20.04
26+
strategy:
27+
matrix:
28+
version: ${{ fromJson(needs.setup.outputs.matrix) }}
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Install arduino-cli
34+
uses: giantswarm/install-binary-action@5972d5adf093d659091fa22c136a332453247b43
35+
with:
36+
binary: "arduino-cli"
37+
version: "0.16.1"
38+
download_url: "https://github.com/arduino/${binary}/releases/download/${version}/${binary}_${version}_Linux_64bit.tar.gz"
39+
tarball_binary_path: "${binary}"
40+
41+
- name: "Try installing core sensebox:samd@${{ matrix.version }}"
42+
run: arduino-cli --additional-urls "file://$(pwd)/package_sensebox_index.json" core install "sensebox:samd@${{ matrix.version }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_store
22
arduino-test/sketches
3+
arduino-test/sensorLayouts
34
node_modules

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# senseBox MCU [![Build Status](https://travis-ci.org/sensebox/senseBoxMCU-core.svg?branch=master)](https://travis-ci.org/sensebox/senseBoxMCU-core)
1+
# senseBox MCU
22
senseBox MCU is a Microchip SAMD21 based open-source board for sensors.
33

44
![senseBox MCU](https://github.com/watterott/senseBox-MCU/raw/master/hardware/senseBox-MCU_v12.jpg)
@@ -14,3 +14,32 @@ senseBox MCU is a Microchip SAMD21 based open-source board for sensors.
1414
* Open-Source
1515
* **[Documentation on learn.watterott.com](http://learn.watterott.com/sensebox/)**
1616
* This repository is based on [Watterott's Core Package](https://github.com/watterott/senseBox-MCU)
17+
18+
## Development & Preparing a new release
19+
20+
Please work in a separate branch and create a pull requests against the master branch!
21+
22+
Each pull request is validated through checks in CI by trying to install the current dev package and compiling against known sensor and model configurations.
23+
24+
### Development
25+
26+
- Create a branch from master
27+
- Do you work, change, add or delete stuff.
28+
- Remember to update the `arduino/samd.zip` file.
29+
- After changing the `arduino/samd.zip` file, update the `size` and `checksum` properties in the `package_sensebox-dev_index.json`. (`stat -c "%s" arduino/samd.zip` and `shasum -a 256 arduino/samd.zip`)
30+
- Commit & push
31+
- If not already open, create a pull request
32+
33+
### Preparing a new release
34+
35+
Once you're satisfied with the current state of the master branch:
36+
37+
- [Create a new release](https://github.com/sensebox/senseBoxMCU-core/releases/new)
38+
- Attach the current `arduino/samd.zip`
39+
- Create a new branch
40+
- Update the `package_sensebox_index.json`
41+
- Prepend a new entry in the `packages.platforms` array
42+
- Use the version and url from your release above
43+
- Commit & push
44+
- Create a PR and merge into master
45+
- If everything was okay, no errors in CI should emerge

arduino-test/build-sketches.js

Lines changed: 30 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,67 @@
1-
'use strict';
1+
"use strict";
22

3-
const fs = require('fs');
4-
const child_process = require('child_process');
3+
const { mkdirSync, writeFileSync } = require("fs");
4+
const { execSync } = require("child_process");
55

6-
const SketchTemplater = require('@sensebox/sketch-templater');
6+
const SketchTemplater = require("@sensebox/sketch-templater");
77

8-
const sketchTemplater = new SketchTemplater('test.ingress.domain');
8+
const { getSensorsForModel } = require("./sensorLayouts");
9+
10+
const sketchTemplater = new SketchTemplater("test.ingress.domain");
11+
12+
const genId = (i) => `59479ed5a4ad5900112d8d${i.toString(16).padStart(2, "0")}`;
913

1014
const boxStub = function (model) {
1115
return {
12-
_id: '59479ed5a4ad5900112d8dec',
16+
_id: "59479ed5a4ad5900112d9d00",
1317
model: model,
14-
sensors: [
15-
{
16-
title: 'Temperatur',
17-
_id: '59479ed5a4ad5900112d8ded',
18-
sensorType: 'HDC1080'
19-
},
20-
{
21-
title: 'rel. Luftfeuchte',
22-
_id: '59479ed5a4ad5900112d8dee',
23-
sensorType: 'HDC1080'
24-
},
25-
{
26-
title: 'Luftdruck',
27-
_id: '59479ed5a4ad5900112d8def',
28-
sensorType: 'BMP280'
29-
},
30-
{
31-
title: 'Beleuchtungsstärke',
32-
_id: '59479ed5a4ad5900112d8df0',
33-
sensorType: 'TSL45315'
34-
},
35-
{
36-
title: 'UV-Intensität',
37-
_id: '59479ed5a4ad5900112d8df1',
38-
sensorType: 'VEML6070'
39-
},
40-
{
41-
title: 'PM10',
42-
_id: '59479ed5a4ad5900112d8df2',
43-
sensorType: 'SDS011'
44-
},
45-
{
46-
title: 'PM2.5',
47-
_id: '59479ed5a4ad5900112d8df3',
48-
sensorType: 'SDS011'
49-
}
50-
],
51-
serialPort: 'Serial1',
52-
ssid: 'MY-HOME-NETWORK',
53-
password: 'MY-SUPER-PASSWORD'
18+
sensors: getSensorsForModel(model).map(({ title, sensorType }, index) => ({
19+
title,
20+
sensorType,
21+
_id: genId(index),
22+
})),
23+
serialPort: "Serial1",
24+
ssid: "MY-HOME-NETWORK",
25+
password: "MY-SUPER-PASSWORD",
5426
};
5527
};
5628

5729
const buildMatrix = {
58-
'sensebox:samd:sb': []
30+
"sensebox:samd:sb": [],
5931
};
6032

6133
for (const model of Object.keys(sketchTemplater._templates)) {
62-
if (model.includes('V2')) {
63-
buildMatrix['sensebox:samd:sb'].push(model);
34+
if (model.includes("V2")) {
35+
buildMatrix["sensebox:samd:sb"].push(model);
6436
}
6537
}
6638

6739
const mkdirp = function mkdirp(path) {
6840
/* eslint-disable no-empty */
6941
try {
70-
fs.mkdirSync(path);
71-
} catch (e) { }
42+
mkdirSync(path);
43+
} catch (e) {}
7244
/* eslint-enable no-empty */
7345
};
7446

7547
const build = function build(board, model) {
7648
mkdirp(`${sketchesPath}/${model}`);
77-
fs.writeFileSync(
49+
writeFileSync(
7850
`${sketchesPath}/${model}/${model}.ino`,
7951
sketchTemplater.generateSketch(boxStub(model))
8052
);
81-
console.log(
82-
`Building model ${model} with "arduino --verbose-build --verify --board ${board} ${sketchesPath}/${model}/${model}.ino"`
83-
);
84-
child_process.execSync(
85-
`arduino --verbose-build --verify --board ${board} ${sketchesPath}/${model}/${model}.ino`,
86-
{ stdio: [0, 1, 2] }
87-
);
88-
console.log('###########################################################');
53+
const cmdWithArgs = `arduino-cli compile --fqbn ${board} ${sketchesPath}/${model}/${model}.ino`;
54+
console.log(`Building model ${model} with "${cmdWithArgs}"`);
55+
execSync(cmdWithArgs, { stdio: [0, 1, 2] });
56+
console.log("###########################################################");
8957
};
9058

91-
const sketchesPath = `${__dirname}/sketches`;
59+
const sketchesPath = `/tmp/sketches`;
9260
mkdirp(sketchesPath);
9361

9462
for (const board of Object.keys(buildMatrix)) {
9563
for (const model of buildMatrix[board]) {
9664
build(board, model);
9765
}
9866
}
99-
console.log('done');
67+
console.log("done");

arduino-test/postinstall.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# extract models version
6+
version=$(jq -r '.peerDependencies."@sensebox/opensensemap-api-models"' package.json)
7+
8+
# fetch tarball
9+
filename=$(npm pack "@sensebox/opensensemap-api-models@$version")
10+
11+
rm -rf arduino-test/sensorLayouts
12+
13+
# unarchive
14+
tar xvzf "$filename" --strip-components=3 -C arduino-test/ --wildcards '*/src/box/sensorLayouts/*'
15+
16+
rm -rf "$filename"
17+
18+
echo -e "\ninstalled sensorLayouts from @sensebox/opensensemap-api-models@$version into arduino-test/sensorLayouts"

arduino/samd.zip

54.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)