Skip to content

Commit 4f96768

Browse files
Setup PR build workflow
That way each PR is identifiable and generates artifacts that we can test locally if desired
1 parent 731c813 commit 4f96768

31 files changed

Lines changed: 741 additions & 288 deletions

.github/workflows/build-pr.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Build PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
build:
10+
name: Build firmware
11+
runs-on: ubuntu-22.04
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
17+
- name: Export build number as env variable
18+
run: echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV
19+
20+
- name: Extract current SHA
21+
run: echo "CURRENT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
22+
23+
- name: Retrieve PR number
24+
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
25+
26+
- name: Extract version
27+
run: |
28+
VERSION_FILE="include/nspm-bin-version.h"
29+
30+
# Use grep to extract the version string from the define statement
31+
VERSION=$(grep -oP '#define NSPanelManagerFirmwareVersion "\K([^"]+)' $VERSION_FILE)
32+
33+
# Store the version in an environment variable
34+
echo "VERSION=$VERSION" >> $GITHUB_ENV
35+
36+
# Optional: Print version to verify
37+
echo "Version in environment variable: ${{ env.VERSION }}"
38+
39+
- name: Replace version in nspm-bin-version.h
40+
run: |
41+
echo "FIRMWARE_IDENTIFIER=${{ env.VERSION }}-${{ env.BUILD_NUMBER }}#PR${{ env.PR_NUMBER }}" >> $GITHUB_ENV
42+
echo "This build will generate firmware identifier ${{ env.FIRMWARE_IDENTIFIER }}"
43+
44+
- name: Replace version and sha in nspm-bin-version.h
45+
run: |
46+
VERSION_FILE="include/nspm-bin-version.h"
47+
48+
# Replace the version string in the header file using sed
49+
sed -i 's/#define NSPanelManagerFirmwareVersion ".*"/#define NSPanelManagerFirmwareVersion "${{ env.VERSION }}-${{ env.BUILD_NUMBER }}#PR${{ env.PR_NUMBER }}"/' $VERSION_FILE
50+
sed -i "s/#define NSPanelManagerFirmwareCommitSha \".*\"/#define NSPanelManagerFirmwareCommitSha \"$GITHUB_SHA\"/" $VERSION_FILE
51+
52+
cat $VERSION_FILE
53+
- name: Set up Python
54+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
55+
with:
56+
python-version: '3.12'
57+
cache: "pipenv"
58+
59+
- name: Install pipenv
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install pipenv
63+
64+
- name: Install project required dependencies
65+
# i.e: platform.io
66+
run: |
67+
make install
68+
69+
- name: Perform pre-commit checks
70+
# ensure files are correctly formatted, Markdown, yaml, end of file etc.
71+
run: |
72+
make pre-commit
73+
74+
- name: Build firmware.bin
75+
run: |
76+
make build-firmware
77+
78+
- name: Build littlefs.bin
79+
run: |
80+
make build-littlefs
81+
82+
- name: Build AIO (all in one image)
83+
# includes bootloader + partitions + firmware + littlefs
84+
# used only the first time an NSPanel is flashed over serial
85+
# not for OTA updates
86+
run: |
87+
make build-aio
88+
89+
- name: Store firmware .bin as build artifact
90+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
91+
with:
92+
name: firmware-${{ env.FIRMWARE_IDENTIFIER }}
93+
path: |
94+
.pio/build/esp32dev/firmware.bin
95+
.pio/build/esp32dev/firmware.bin.md5
96+
.pio/build/esp32dev/littlefs.bin
97+
.pio/build/esp32dev/littlefs.bin.md5
98+
.pio/build/esp32dev/firmware-aio.bin
99+
.pio/build/esp32dev/firmware-aio.bin.md5
100+
retention-days: 1 # Retention policy for 1 day

.github/workflows/build.yml

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

.gitignore

Lines changed: 191 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,192 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,intellij+all,windows,macos,linux,platformio
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,intellij+all,windows,macos,linux,platformio
3+
4+
### Intellij+all ###
5+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7+
8+
# User-specific stuff
9+
.idea/**/workspace.xml
10+
.idea/**/tasks.xml
11+
.idea/**/usage.statistics.xml
12+
.idea/**/dictionaries
13+
.idea/**/shelf
14+
15+
# AWS User-specific
16+
.idea/**/aws.xml
17+
18+
# Generated files
19+
.idea/**/contentModel.xml
20+
21+
# Sensitive or high-churn files
22+
.idea/**/dataSources/
23+
.idea/**/dataSources.ids
24+
.idea/**/dataSources.local.xml
25+
.idea/**/sqlDataSources.xml
26+
.idea/**/dynamic.xml
27+
.idea/**/uiDesigner.xml
28+
.idea/**/dbnavigator.xml
29+
30+
# Gradle
31+
.idea/**/gradle.xml
32+
.idea/**/libraries
33+
34+
# Gradle and Maven with auto-import
35+
# When using Gradle or Maven with auto-import, you should exclude module files,
36+
# since they will be recreated, and may cause churn. Uncomment if using
37+
# auto-import.
38+
# .idea/artifacts
39+
# .idea/compiler.xml
40+
# .idea/jarRepositories.xml
41+
# .idea/modules.xml
42+
# .idea/*.iml
43+
# .idea/modules
44+
# *.iml
45+
# *.ipr
46+
47+
# CMake
48+
cmake-build-*/
49+
50+
# Mongo Explorer plugin
51+
.idea/**/mongoSettings.xml
52+
53+
# File-based project format
54+
*.iws
55+
56+
# IntelliJ
57+
out/
58+
59+
# mpeltonen/sbt-idea plugin
60+
.idea_modules/
61+
62+
# JIRA plugin
63+
atlassian-ide-plugin.xml
64+
65+
# Cursive Clojure plugin
66+
.idea/replstate.xml
67+
68+
# SonarLint plugin
69+
.idea/sonarlint/
70+
71+
# Crashlytics plugin (for Android Studio and IntelliJ)
72+
com_crashlytics_export_strings.xml
73+
crashlytics.properties
74+
crashlytics-build.properties
75+
fabric.properties
76+
77+
# Editor-based Rest Client
78+
.idea/httpRequests
79+
80+
# Android studio 3.1+ serialized cache file
81+
.idea/caches/build_file_checksums.ser
82+
83+
### Intellij+all Patch ###
84+
# Ignore everything but code style settings and run configurations
85+
# that are supposed to be shared within teams.
86+
87+
.idea/*
88+
89+
!.idea/codeStyles
90+
!.idea/runConfigurations
91+
92+
### Linux ###
93+
*~
94+
95+
# temporary files which can be created if a process still has a handle open of a deleted file
96+
.fuse_hidden*
97+
98+
# KDE directory preferences
99+
.directory
100+
101+
# Linux trash folder which might appear on any partition or disk
102+
.Trash-*
103+
104+
# .nfs files are created when an open file is removed but is still being accessed
105+
.nfs*
106+
107+
### macOS ###
108+
# General
109+
.DS_Store
110+
.AppleDouble
111+
.LSOverride
112+
113+
# Icon must end with two \r
114+
Icon
115+
116+
117+
# Thumbnails
118+
._*
119+
120+
# Files that might appear in the root of a volume
121+
.DocumentRevisions-V100
122+
.fseventsd
123+
.Spotlight-V100
124+
.TemporaryItems
125+
.Trashes
126+
.VolumeIcon.icns
127+
.com.apple.timemachine.donotpresent
128+
129+
# Directories potentially created on remote AFP share
130+
.AppleDB
131+
.AppleDesktop
132+
Network Trash Folder
133+
Temporary Items
134+
.apdisk
135+
136+
### macOS Patch ###
137+
# iCloud generated files
138+
*.icloud
139+
140+
### PlatformIO ###
141+
.pioenvs
142+
.piolibdeps
143+
.clang_complete
144+
.gcc-flags.json
1145
.pio
2-
.vscode/.browse.c_cpp.db*
3-
.vscode/c_cpp_properties.json
4-
.vscode/launch.json
5-
.vscode/ipch
146+
147+
### VisualStudioCode ###
148+
.vscode/*
149+
!.vscode/settings.json
150+
!.vscode/tasks.json
151+
!.vscode/launch.json
152+
!.vscode/extensions.json
153+
!.vscode/*.code-snippets
154+
155+
# Local History for Visual Studio Code
156+
.history/
157+
158+
# Built Visual Studio Code Extensions
159+
*.vsix
160+
161+
### VisualStudioCode Patch ###
162+
# Ignore all local history of files
163+
.history
164+
.ionide
165+
166+
### Windows ###
167+
# Windows thumbnail cache files
168+
Thumbs.db
169+
Thumbs.db:encryptable
170+
ehthumbs.db
171+
ehthumbs_vista.db
172+
173+
# Dump file
174+
*.stackdump
175+
176+
# Folder config file
177+
[Dd]esktop.ini
178+
179+
# Recycle Bin used on file shares
180+
$RECYCLE.BIN/
181+
182+
# Windows Installer files
183+
*.cab
184+
*.msi
185+
*.msix
186+
*.msm
187+
*.msp
188+
189+
# Windows shortcuts
190+
*.lnk
191+
192+
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,intellij+all,windows,macos,linux,platformio

0 commit comments

Comments
 (0)