diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..35ca5bf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: Build ESP32 Application + +on: + workflow_dispatch: + inputs: + board: + description: 'Board to build for (all or specific board name)' + required: true + default: 'all' + prefix: + description: 'Prefix for binary name' + required: true + default: 'esp32-c3-lua-test' + flash_size: + description: 'Size of the Flash storage' + required: true + default: '4MB' + data_partition: + description: 'Name of data partition' + required: true + default: 'assets' + + + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + board: [esp32c3-devkit, esp32c2-devkit] + fail-fast: false + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set Target for ESP-IDF + run: | + echo "TARGET=$(case ${{ matrix.board }} in + esp32c3-devkit) echo 'esp32c3';; + esp32c3-devkit) echo 'esp32c2';; + *) echo 'Unknown target'; exit 1;; + esac)" >> $GITHUB_ENV + + - name: esp-idf build and merge binaries + uses: espressif/esp-idf-ci-action@v1.1.0 + with: + esp_idf_version: latest + target: ${{ env.TARGET }} + path: '.' + command: | + idf.py build && + cd build.${{ matrix.board }} && + esptool.py --chip ${{ env.TARGET }} merge_bin -o ${{ github.event.inputs.prefix }}-${{ matrix.board }}.bin "@flash_args" + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.inputs.prefix }}-${{ matrix.board }}.bin + path: build.${{ matrix.board }}/${{ github.event.inputs.prefix }}-${{ matrix.board }}.bin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ce57e05 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: Create GitHub Release + +on: + workflow_dispatch: + inputs: + release_name: + description: 'Name of the GitHub Release' + required: true + default: 'v1.0.0' + release_tag: + description: 'Tag for the GitHub Release' + required: true + default: 'v1.0.0' + prefix: + description: 'Prefix for binary name' + required: true + default: 'esp32-c3-lua-test' + +jobs: + create-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install GitHub CLI + run: sudo apt-get install gh + + - name: Authenticate GitHub CLI + run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" + + - name: Check if Release Exists + id: check_release + run: | + set +e + gh release view ${{ github.event.inputs.release_tag }} > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Release already exists." + echo "release_exists=true" >> $GITHUB_ENV + else + echo "Release does not exist." + echo "release_exists=false" >> $GITHUB_ENV + fi + set -e + + - name: Create Release + if: env.release_exists == 'false' + run: | + gh release create ${{ github.event.inputs.release_tag }} --title "${{ github.event.inputs.release_name }}" --prerelease + + - name: Download Build Artifacts + uses: dawidd6/action-download-artifact@v6 + with: + workflow: build.yml + path: artifacts + + - name: List Downloaded Files + run: | + echo "Listing all files in the artifacts directory:" + find artifacts -type f + + - name: Rename and Upload Assets to Release + run: | + # List all binary files in the artifacts directory + for file in $(find artifacts -type f -name "*.bin"); do + # Extract board name from the directory structure + board_name=$(basename "$file" | sed -n "s/${{ github.event.inputs.prefix }}-\(.*\)\.bin/\1/p") + # Define the versioned asset name + asset_name="${{ github.event.inputs.prefix }}-${{ github.event.inputs.release_tag }}-${board_name}.bin" + # Upload the artifact to the release + gh release upload "${{ github.event.inputs.release_tag }}" "$file#${asset_name}" --clobber + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..16534a5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,46 @@ +name: Test ESP32 Application + +on: + workflow_dispatch: + inputs: + prefix: + description: 'Prefix for binary name' + required: true + default: 'esp32-c3-lua-test' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + board: [esp32c3-devkit] + fail-fast: false + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v6 + with: + workflow: build.yml + name: ${{ github.event.inputs.prefix }}-${{ matrix.board }}.bin + path: build.${{ matrix.board }} + + - name: Setup Wokwi CLI + uses: wokwi/wokwi-ci-action@v1 + with: + token: ${{ secrets.WOKWI_CLI_TOKEN }} + path: boards/${{ matrix.board }} + elf: build.${{ matrix.board }}/${{ github.event.inputs.prefix }}-${{ matrix.board }}.bin + timeout: 30000 + expect_text: 'Closing Lua' + fail_text: 'Error' + serial_log_file: 'wokwi-logs-${{ matrix.board }}.txt' + + - name: Upload Wokwi Logs + uses: actions/upload-artifact@v4 + with: + name: wokwi-logs-${{ matrix.board }} + path: wokwi-logs-${{ matrix.board }}.txt diff --git a/.gitignore b/.gitignore index a2e6e6e..c1f943a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ build/ +managed_components/ +dependencies.lock +sdkconfig diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..976fee5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Wokwi GDB", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/esp32-c3-lua-test.elf", + "cwd": "${workspaceFolder}", + "MIMode": "gdb", + "miDebuggerPath": "${command:espIdf.getToolchainGdb}", + "miDebuggerServerAddress": "localhost:3333" + } + ] +} \ No newline at end of file diff --git a/diagram.json b/diagram.json new file mode 100644 index 0000000..954a8b9 --- /dev/null +++ b/diagram.json @@ -0,0 +1,23 @@ +{ + "version": 1, + "author": "Uri Shaked", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-c3-devkitm-1", + "id": "esp" + } + ], + "connections": [ + [ + "esp:TX", + "$serialMonitor:RX", + "" + ], + [ + "esp:RX", + "$serialMonitor:TX", + "" + ] + ] +} \ No newline at end of file diff --git a/wokwi.toml b/wokwi.toml new file mode 100644 index 0000000..fac58dd --- /dev/null +++ b/wokwi.toml @@ -0,0 +1,7 @@ +# Wokwi Configuration File +# Reference: https://docs.wokwi.com/vscode/project-config +[wokwi] +version = 1 +firmware = 'build/flasher_args.json' +elf = 'build/esp32-c3-lua-test.elf' +gdbServerPort=3333