Skip to content

Commit f2557fa

Browse files
authored
Merge pull request #3 from lightbug-io/ci
CI LB attempt
2 parents f8312b5 + d5d6f64 commit f2557fa

File tree

10 files changed

+218
-166
lines changed

10 files changed

+218
-166
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ on:
1010

1111
jobs:
1212
build:
13+
permissions:
14+
contents: write
1315
strategy:
1416
matrix:
15-
os: [ubuntu-latest, windows-latest, macos-latest]
17+
variant:
18+
- esp32c6-standard
19+
- esp32c6-large-partitions
20+
- esp32c6-single-ota
1621

17-
runs-on: ${{ matrix.os }}
22+
runs-on: ubuntu-latest
1823

1924
steps:
2025
- uses: actions/checkout@v4
@@ -27,26 +32,21 @@ jobs:
2732
toit-dir: toit
2833
esp32: true
2934

30-
- shell: bash
31-
run: echo $PATH
32-
33-
- name: Build - Linux and macOS
34-
if: runner.os != 'Windows'
35+
- name: Build envelope
3536
shell: bash
3637
run: |
37-
make init # Can be removed once the project is set up.
38-
make
38+
make init
39+
make envelope VARIANT=${{ matrix.variant }}
3940
40-
- name: Build - Windows
41-
if: runner.os == 'Windows'
42-
shell: pwsh
43-
run: |
44-
make init # Can be removed once the project is set up.
45-
${{ github.workspace }}/toit/third_party/esp-idf/export.ps1
46-
make host
47-
cmake -E env `
48-
"IDF_PATH=$PWD/toit/third_party/esp-idf" `
49-
"IDF_TARGET=esp32" "IDF_CCACHE_ENABLE=1" `
50-
"TOIT_EXTRA_COMPONENTS=$PWD/components" `
51-
"TOIT_SDK_DIR=$PWD/build/host/sdk" `
52-
python $PWD/toit/third_party/esp-idf/tools/idf.py -B "$PWD/build/esp32" -C build-root build
41+
- name: Upload envelope artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: envelope-${{ matrix.variant }}.envelope
45+
path: dist/${{ matrix.variant }}.envelope
46+
47+
- name: Publish GitHub release asset
48+
if: github.ref_type == 'tag'
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
files: |
52+
dist/${{ matrix.variant }}.envelope

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
11
.packages/
22
/build/
3+
/dist/
4+
/build-root/sdkconfig
35
/build-root/sdkconfig.old
6+
7+
# Editor / IDE
8+
.vscode/
9+
*.swp
10+
.DS_Store
11+
12+
# Build artifacts
13+
build-root/build/
14+
build/
15+
*.o
16+
*.elf
17+
*.bin
18+
*.map
19+
20+
# Generated config / board files
21+
build-root/partitions.csv
22+
build-root/sdkconfig.defaults
23+
*.config
24+
25+
# Python
26+
__pycache__/
27+
*.pyc
28+
29+
# Environment / secrets
30+
.env
31+

Makefile

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ SHELL := bash
88

99
# Change to your configuration. See toit/toolchains for the available targets.
1010
# Then run 'make init'.
11-
IDF_TARGET := esp32
11+
IDF_TARGET := esp32c6
12+
13+
# Envelope variants.
14+
VARIANT ?= esp32c6-standard
15+
VARIANTS ?= esp32c6-standard esp32c6-large-partitions esp32c6-single-ota
1216

1317
# Set to false to avoid initializing submodules at every build.
1418
INITIALIZE_SUBMODULES := true
@@ -19,11 +23,12 @@ COMPONENTS := $(SOURCE_DIR)/components
1923
# Constants that typically don't need to be changed.
2024
BUILD_ROOT := $(SOURCE_DIR)/build-root
2125
BUILD_PATH := $(SOURCE_DIR)/build
26+
DIST_DIR := $(SOURCE_DIR)/dist
2227
TOIT_ROOT := $(SOURCE_DIR)/toit
2328
IDF_PATH := $(TOIT_ROOT)/third_party/esp-idf
2429
IDF_PY := $(IDF_PATH)/tools/idf.py
2530

26-
all: esp32
31+
all: envelope
2732

2833
define toit-make
2934
@$(MAKE) -C "$(BUILD_ROOT)" \
@@ -52,11 +57,49 @@ build-host: host
5257

5358
.PHONY: esp32
5459
esp32: initialize-submodules
55-
@if [[ ! -f $(BUILD_ROOT)/sdkconfig.defaults ]]; then \
60+
@$(MAKE) envelope VARIANT=$(VARIANT)
61+
62+
.PHONY: list-variants
63+
list-variants:
64+
@printf "%s\n" $(VARIANTS)
65+
66+
.PHONY: envelope
67+
envelope: initialize-submodules
68+
@if [[ ! -f "$(BUILD_ROOT)/sdkconfig.defaults" || ! -f "$(BUILD_ROOT)/partitions.csv" ]]; then \
5669
echo "Run 'make init' first"; \
57-
exit 1; \
70+
exit 1; \
71+
fi
72+
@if [[ ! -f "$(SOURCE_DIR)/variants/$(VARIANT)/partitions.csv" ]]; then \
73+
echo "Unknown VARIANT: $(VARIANT)"; \
74+
echo "Known variants:"; \
75+
$(MAKE) list-variants; \
76+
exit 1; \
5877
fi
59-
@$(call toit-make,esp32)
78+
@mkdir -p "$(DIST_DIR)"
79+
@tmp_part=$$(mktemp); \
80+
cp "$(BUILD_ROOT)/partitions.csv" "$$tmp_part"; \
81+
cp "$(SOURCE_DIR)/variants/$(VARIANT)/partitions.csv" "$(BUILD_ROOT)/partitions.csv"; \
82+
$(MAKE) -C "$(BUILD_ROOT)" \
83+
COMPONENTS=$(COMPONENTS) \
84+
BUILD_PATH=$(BUILD_PATH)/variants/$(VARIANT) \
85+
BASE_BUILD_PATH=$(BUILD_PATH) \
86+
TOIT_ROOT=$(TOIT_ROOT) \
87+
IDF_TARGET=$(IDF_TARGET) \
88+
IDF_PATH=$(IDF_PATH) \
89+
IDF_PY=$(IDF_PY) \
90+
esp32; \
91+
status=$$?; \
92+
if [[ $$status -eq 0 ]]; then \
93+
cp "$(BUILD_PATH)/variants/$(VARIANT)/$(IDF_TARGET)/firmware.envelope" "$(DIST_DIR)/$(VARIANT).envelope"; \
94+
fi; \
95+
mv "$$tmp_part" "$(BUILD_ROOT)/partitions.csv"; \
96+
exit $$status
97+
98+
.PHONY: envelopes
99+
envelopes: initialize-submodules
100+
@for v in $(VARIANTS); do \
101+
$(MAKE) envelope VARIANT=$$v; \
102+
done
60103

61104
.PHONY: menuconfig
62105
menuconfig: initialize-submodules

README-external-service.md

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

README.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Template repository for creating a custom Toit envelope
1+
# Lightbug custom Toit envelopes
22

3-
This repository can be used to create custom [envelopes](https://docs.toit.io/tutorials/containers)
4-
for [Toit](https://toitlang.org/).
3+
This repository creates custom [envelopes](https://docs.toit.io/tutorials/containers)
4+
for [Toit](https://toitlang.org/) use with Lightbug devices, and is based on [this template repository](https://github.com/toitlang/template-custom-envelope).
55

6-
There are already many [pre-built envelopes](https://github.com/toitlang/envelopes) available, but
7-
if you need to create a custom envelope, this repository can be used as a starting point.
6+
## Releases
87

9-
## External services
8+
You can find released envelopes under the Github releases page: https://github.com/lightbug-io/toit-envelopes/releases
109

11-
See the [README-external-service.md](README-external-service.md) file for information on how to use external services.
10+
Tags should have the format "v2.0.0-alpha.189.lb.yyymmdd".
11+
In the case that multiple releases are made on the same day, the "yyyymmdd" part can be extended with a suffix, e.g. "yyyymmdd-1", "yyyymmdd-2", etc.
1212

1313
## Setup
1414

@@ -18,8 +18,9 @@ See the [README-external-service.md](README-external-service.md) file for inform
1818
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html
1919
- A good starting point is to run `install.sh` from the `toit/third_party/esp-idf` folder.
2020

21-
The [ci.yml](.github/workflows/ci.yml) file uses Toit's setup action to install all prerequisites
22-
on a GitHub runner. You can use this as a reference for setting up your own environment.
21+
The [ci.yml](.github/workflows/ci.yml) file uses Toit's setup action to install all prerequisites on a GitHub runner.
22+
23+
This CI action will build artifacts on every push, as well as create release artifacts on every tag.
2324

2425
### Initial setup
2526

@@ -59,7 +60,7 @@ on a GitHub runner. You can use this as a reference for setting up your own envi
5960
```
6061

6162
* Change the license to your license.
62-
* Change the `TARGET` variable in the Makefile to the name of your chip. By default it is set to `esp32`.
63+
* Change the `IDF_TARGET` variable in the Makefile to the name of your chip.
6364
* Run `make init`. This will copy some of the Toit files, depending on the target, to your repository.
6465

6566
After initialization you should have the files `sdkconfig.defaults` and `partitions.csv` in the `build-root`
@@ -73,11 +74,32 @@ checked into your repository.
7374
to compile on Windows or macOS.
7475

7576
### Build
76-
* Run `make` to build the envelope. It should end up with a `build/esp32/firmware.envelope`.
77+
This repository is set up to build multiple envelope variants.
78+
79+
* Build one envelope variant:
80+
81+
``` shell
82+
make init
83+
make envelope VARIANT=esp32c6-standard
84+
```
85+
86+
The resulting envelope is written to `dist/esp32c6-standard.envelope`.
87+
88+
* Build all variants:
89+
90+
``` shell
91+
make init
92+
make envelopes
93+
```
94+
95+
All resulting envelopes are written to `dist/*.envelope`.
7796

7897
## Makefile targets
79-
- `make` or `make all` - Build the envelope.
98+
- `make` or `make all` - Build the default envelope variant.
8099
- `make init` - Initialize after cloning. See the Setup section above.
81100
- `make menuconfig` - Runs the ESP-IDF menuconfig tool in the build-root. Also creates the `sdkconfig.defaults` file.
82101
- `make diff` - Show the differences between your configuration (sdkconfig and partitions.csv) and the default Toit configuration.
83102
- `make clean` - Remove all build artifacts.
103+
- `make envelope VARIANT=<name>` - Build one variant and write `dist/<name>.envelope`.
104+
- `make envelopes` - Build all variants.
105+
- `make list-variants` - Print the known variants.

0 commit comments

Comments
 (0)