Skip to content

Commit 9e1301b

Browse files
integrate ESP32 E2E CI workflow
1 parent 58e4c85 commit 9e1301b

File tree

16 files changed

+156
-77
lines changed

16 files changed

+156
-77
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,43 @@ on: [push]
33
jobs:
44
build:
55
runs-on: ubuntu-latest
6-
timeout-minutes: 5
6+
timeout-minutes: 10
77
steps:
88
- name: Checkout
99
uses: actions/checkout@v1
1010
- name: Build
1111
run: |
1212
docker build -t esp32-javascript:latest -f tools/Dockerfile .
13-
docker run -t esp32-javascript:latest bash -c '. ./tools/install-node.sh; idf.py build'
13+
docker run --name esp32-javascript-build -t esp32-javascript:latest bash -c './tools/build.sh'
14+
docker cp 'esp32-javascript-build:/opt/esp32-javascript/build.tar.gz' .
15+
docker cp 'esp32-javascript-build:/opt/esp32-javascript/self-test-build.tar.gz' .
16+
- name: Extract self test build output
17+
run: tar xvzf self-test-build.tar.gz
18+
- name: Create Session
19+
run: echo SESSION=$(curl --silent -X POST https://api.e2e.kottmann.rocks/session | jq -r .id) >> $GITHUB_ENV
20+
- name: Flash artifacts to test device
21+
run: curl --silent -F session=${{ env.SESSION }} -F follow=true -F offset=0x1000 -F bin=@build/bootloader/bootloader.bin -F offset=0x8000 -F bin=@build/partition_table/partition-table.bin -F offset=0x10000 -F bin=@build/esp32-javascript.bin -F offset=0x3c0000 -F bin=@build/modules.bin https://api.e2e.kottmann.rocks/flash
22+
- name: Wait for startup
23+
run: curl --silent -F session=${{ env.SESSION }} -F 'find=Self test initialized.' https://api.e2e.kottmann.rocks/monitor | jq -e .match
24+
- name: Check Setup page
25+
run: curl --silent https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/setup | grep '<h1>Setup</h1>'
26+
- name: Self Test Pins
27+
run: |
28+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/18/0
29+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO18 == false'
30+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/18/1
31+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO18'
32+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/19/0
33+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO19 == false'
34+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/19/1
35+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO19'
36+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/21/0
37+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO21 == false'
38+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/21/1
39+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO21'
40+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/22/0
41+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO22 == false'
42+
curl https://esp32:esp32@${{ env.SESSION }}.e2e.kottmann.rocks/selftest/pins/22/1
43+
curl --silent -X POST -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/snapshot | jq -e '.GPIO22'
44+
- name: Cleanup
45+
run: curl --silent -F session=${{ env.SESSION }} https://api.e2e.kottmann.rocks/release

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ sdkconfig.old*
33
main/project.cpp
44
main/project.c
55
node_modules
6-

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
"Lightweight" JS interpreter for ESP32. Provides JS-based eventloop implementation
66
and native asynchronous network and timer functions.
7-
Because of the limited memory on ESP32-WROOM modules, the full functionality is currently only realizable on ESP32-WROVER modules, that include additional 4MB of SPIRAM memory.
7+
Because of the limited memory on ESP32-WROOM modules, the full functionality is currently only realizable on ESP32-WROVER modules, that include additional 4MB of SPIRAM memory.
88

99
## Content
10+
1011
[Getting started](#getting-started)
1112

1213
[API](#api)
@@ -16,28 +17,34 @@ Because of the limited memory on ESP32-WROOM modules, the full functionality is
1617
## Getting started
1718

1819
### Prerequisites
19-
Install [esp-idf](http://esp-idf.readthedocs.io/en/latest/get-started/index.html#setup-toolchain) on your system.
20+
21+
Install [esp-idf 4.2](https://docs.espressif.com/projects/esp-idf/en/release-v4.2/esp32/get-started/index.html) on your system.
2022

2123
### First install
24+
2225
Clone esp32-javascript inside your esp directory (normally ~/esp):
26+
2327
```shell
2428
cd ~/esp
2529
git clone https://github.com/pepe79/esp32-javascript.git
2630
```
2731

2832
Change into ~/esp/esp32-javascript.
33+
2934
```shell
3035
cd ~/esp/esp32-javascript
3136
```
3237

3338
Maybe you want to change the BOARD_VARIANT in the ./CMakeLists.txt file.
3439

3540
First build the project with
41+
3642
```shell
3743
idf.py build
3844
```
3945

4046
Connect your ESP32 Dev Board via USB and run
47+
4148
```shell
4249
idf.py flash monitor
4350
```
@@ -46,15 +53,16 @@ Use the keyboard shortcut `AltGr + ]` to leave serial monitor.
4653

4754
Now you have installed the pre-configured boot script.
4855

49-
If this is your first install, your onboard LED should blink now. Blinking signals that your board has started a soft ap with the ssid "esp32". With your mobile or desktop connect to the WLAN SSID "esp32" and open http://192.168.4.1/setup (if you have not changed the default credentials your username / password is esp32 / esp32 ). You can change the default password in `./sdkconfig` by changing the value of `CONFIG_ESP32_JS_BASIC_AUTH_PASSWORD`.
56+
If this is your first install, your onboard LED should blink now. Blinking signals that your board has started a soft ap with the ssid "esp32". With your mobile or desktop connect to the WLAN SSID "esp32" and open http://192.168.4.1/setup (if you have not changed the default credentials your username / password is esp32 / esp32 ). You can change the default password in
57+
[firmware-config.ts](./components/esp32-javascript/modules/esp32-javascript/firmware-config.ts) by changing the value of key`password`.
5058

5159
On the Setup page you can configure your WLAN settings and an URL to download your JS main script from.
5260

53-
Please note that the script, does not need to have a main function, because its evaluated entirely.
61+
Please note that the script, does not need to have a main function, because its evaluated entirely.
5462
That means, to print out "Hello World", you only have to include one line in your script on the webserver:
5563

5664
```js
57-
console.log('Hello world!');
65+
console.log("Hello world!");
5866
```
5967

6068
### C/C++bindings
@@ -63,6 +71,7 @@ If you need to create your own C/C++ bindings for your JS code, this are the ste
6371

6472
1. Create a file named `project.cpp` in the `./main` directory
6573
2. Implement the esp32_javascript_main callback function inside this `project.ccp`:
74+
6675
```c
6776
#include "esp32-javascript.h"
6877

@@ -78,15 +87,15 @@ If you need more than this, you can create your own esp-idf component below `./c
7887
Additionally you have to set your component name in the top level `./CMakeLists.txt`. Refer to the documentation next to the setting `ESP32_JS_PROJECT_NAME`.
7988
See [ESP Build System](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html) for information on how to create a component with the esp-idf build system.
8089
81-
### Clean
90+
### Clean
8291
8392
You can clean the project by executing
8493
8594
```shell
8695
idf.py fullclean
8796
```
8897

89-
### Factory reset
98+
### Factory reset
9099

91100
You can erase the persistent flash memory, which will be equivalent to a factory reset, by executing
92101

@@ -96,9 +105,10 @@ You can erase the persistent flash memory, which will be equivalent to a factory
96105

97106
## Compatibility
98107

99-
Tested with esp-idf (master branch commit hash 2e14149b).
108+
Tested with esp-idf [release/v4.2](https://github.com/espressif/esp-idf/tree/release/v4.2)
100109

101110
## API
111+
102112
[API documentation](docs/README.md)
103113

104114
### Update docs
@@ -110,4 +120,5 @@ Update documentation by executing
110120
```
111121

112122
## License
123+
113124
See source files.

components/esp32-javascript/Kconfig

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

components/esp32-javascript/esp32-javascript.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,6 @@ void loadUrlPolyfill(duk_context *ctx)
517517
loadJS(ctx, "urlparse.js", _start, _end);
518518
}
519519

520-
duk_ret_t getFirmwareDefaults(duk_context *ctx)
521-
{
522-
duk_idx_t obj_idx = duk_push_object(ctx);
523-
524-
duk_push_string(ctx, CONFIG_ESP32_JS_BASIC_AUTH_USERNAME);
525-
duk_put_prop_string(ctx, obj_idx, "basicAuthUsername");
526-
duk_push_string(ctx, CONFIG_ESP32_JS_BASIC_AUTH_PASSWORD);
527-
duk_put_prop_string(ctx, obj_idx, "basicAuthPassword");
528-
return 1;
529-
}
530-
531520
duk_ret_t btoa(duk_context *ctx)
532521
{
533522
const char *str = duk_to_string(ctx, 0);
@@ -704,9 +693,6 @@ void duktape_task(void *ignore)
704693
duk_push_c_function(ctx, setDateTimeZoneOffsetInHours, 1 /*nargs*/);
705694
duk_put_global_string(ctx, "setDateTimeZoneOffsetInHours");
706695

707-
duk_push_c_function(ctx, getFirmwareDefaults, 0 /*nargs*/);
708-
duk_put_global_string(ctx, "getFirmwareDefaults");
709-
710696
duk_push_c_function(ctx, btoa, 1 /*nargs*/);
711697
duk_put_global_string(ctx, "btoa");
712698

components/esp32-javascript/modules/esp32-javascript/config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1+
var __importDefault = (this && this.__importDefault) || function (mod) {
2+
return (mod && mod.__esModule) ? mod : { "default": mod };
3+
};
14
Object.defineProperty(exports, "__esModule", { value: true });
25
exports.saveConfig = exports.reloadConfig = exports.config = void 0;
6+
var firmware_config_1 = __importDefault(require("./firmware-config"));
37
var CONFIG_PATH = "/data/config.js";
48
function reloadConfig() {
59
try {
610
exports.config = JSON.parse(readFile(CONFIG_PATH));
711
}
812
catch (error) {
9-
var dc = getFirmwareDefaults();
10-
exports.config = {
11-
access: {
12-
username: dc.basicAuthUsername,
13-
password: dc.basicAuthPassword,
14-
},
15-
};
13+
exports.config = firmware_config_1.default;
1614
console.error("An error ocurred while accessing config. Maybe it does not exist.");
1715
}
1816
}

components/esp32-javascript/modules/esp32-javascript/config.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
interface Esp32JsConfig {
1+
import firmwareConfig from "./firmware-config";
2+
export interface Esp32JsConfig {
23
access: {
34
username: string;
45
password: string;
@@ -22,13 +23,7 @@ export function reloadConfig(): void {
2223
try {
2324
config = JSON.parse(readFile(CONFIG_PATH));
2425
} catch (error) {
25-
const dc = getFirmwareDefaults();
26-
config = {
27-
access: {
28-
username: dc.basicAuthUsername,
29-
password: dc.basicAuthPassword,
30-
},
31-
};
26+
config = firmwareConfig;
3227
console.error(
3328
"An error ocurred while accessing config. Maybe it does not exist."
3429
);

components/esp32-javascript/modules/esp32-javascript/esp32-javascript.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ interface Esp32JsFirmwareDefaults {
2222
basicAuthPassword: string;
2323
}
2424

25-
declare function getFirmwareDefaults(): Esp32JsFirmwareDefaults;
2625
declare function restart(): void;
2726

2827
interface Esp32JsEventloopEvent {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Object.defineProperty(exports, "__esModule", { value: true });
2+
var firmwareConfig = {
3+
access: {
4+
username: "esp32",
5+
password: "esp32",
6+
},
7+
};
8+
exports.default = firmwareConfig;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Esp32JsConfig } from "./config";
2+
3+
const firmwareConfig: Esp32JsConfig = {
4+
access: {
5+
username: "esp32",
6+
password: "esp32",
7+
},
8+
};
9+
10+
export default firmwareConfig;

0 commit comments

Comments
 (0)