Skip to content

Commit

Permalink
Fix and finish setup of CI
Browse files Browse the repository at this point in the history
- Use apt erlang instead of setup-beam in esp-idf container
- Remove unnecessary git configuration
- Add missing app src file to help generate documentation
- Add missing dependencies
- Fix paths
- Add publish doc workflow

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
  • Loading branch information
pguyot committed May 7, 2024
1 parent 3b9b836 commit 3d022bb
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 37 deletions.
55 changes: 23 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,35 @@ jobs:
idf-version:
- 'v5.1.3'
- 'v5.2.1'
otp:
- "26"
elixir_version:
- "1.16"

container: espressif/idf:release-v5.2
steps:
- name: Checkout AtomVM
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: atomvm/AtomVM
path: AtomVM

- name: Checkout atomvm_esp_adf
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: AtomVM/src/platform/esp32/components/
path: AtomVM/src/platforms/esp32/components/atomvm_esp_adf/

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir_version }}
- name: Checkout atomvm_esp_adf submodules
shell: bash
working-directory: AtomVM/src/platforms/esp32/components/atomvm_esp_adf/
run: |
git submodule update --init components/esp-adf
cd components/esp-adf
git submodule update --init components/esp-adf-libs/
- name: Install dependencies to build host AtomVM
run: |
set -eu
apt update
DEBIAN_FRONTEND=noninteractive apt install -y -q \
doxygen \
libglib2.0-0 libpixman-1-0 \
gcc g++ zlib1g-dev libsdl2-2.0-0 libslirp0 libmbedtls-dev
# needed for generating AtomVM version when running in a docker container
- name: Configure Git
run: |
git config --global --add safe.directory /__w/AtomVM/AtomVM
echo -n "git rev-parse: "
git rev-parse --short HEAD
doxygen erlang-base erlang-dialyzer elixir \
gcc g++ zlib1g-dev libmbedtls-dev make cmake
- name: Build AtomVM libraries
shell: bash
Expand All @@ -72,43 +63,43 @@ jobs:
rm -rf build
. $IDF_PATH/export.sh
idf.py set-target ${{ matrix.soc }}
idf.py reconfigure
idf.py build
echo CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y >> sdkconfig
idf.py build -DCONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
- name: "Create a ${{ matrix.soc }} image"
working-directory: ./src/platforms/esp32/build
working-directory: AtomVM/src/platforms/esp32/build
run: |
./mkimage.sh
ls -l *.img
mv atomvm-${{ matrix.soc }}.img atomvm-esp-adf-${{ matrix.soc }}-${{ matrix.idf-version }}.img
- name: "Upload ${{ matrix.soc }} artifacts"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: atomvm-${{ matrix.soc }}-image
path: ./src/platforms/esp32/build/atomvm-${{ matrix.soc }}.img
path: AtomVM/src/platforms/esp32/build/atomvm-esp-adf-${{ matrix.soc }}-${{ matrix.idf-version }}.img
if-no-files-found: error

build-doc:
runs-on: ubuntu-latest
container: erlang:26
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4
- name: Build edoc
run: |
rebar3 edoc
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: doc

clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
Expand All @@ -125,7 +116,7 @@ jobs:
container: erlang:26
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout erlfmt
run: |
cd ..
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and deploy documentation

on:
push:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
doc:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
container: erlang:26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Build edoc
run: |
rebar3 edoc
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: doc
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
# AtomVM driver for Espressif Audio Framework

This component ports [Espressif Audio Framework](https://github.com/espressif/esp-adf)
to AtomVM, thus enabling audio processing to esp32-based systems powered by
AtomVM.

[![Build](https://github.com/pguyot/atomvm_esp_adf/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/pguyot/atomvm_esp_adf/actions/workflows/build.yml)

## Usage:

1. Clone this repository into atomvm/src/platforms/esp32/components with submodules
1. Clone this repository into atomvm/src/platforms/esp32/components with
the required submodules. You can clone with recursive submodules but most
submodules are not used and the following commands will save disk space.

```bash
cd AtomVM/src/platforms/esp32/components/
git clone --recurse-submodules https://github.com/pguyot/atomvm_esp_adf.git
git clone https://github.com/pguyot/atomvm_esp_adf.git
cd atomvm_esp_adf/
git submodule update --init components/esp-adf
cd components/esp-adf/
git submodule update --init components/esp-adf-libs/
```

2. Build and flash AtomVM

Use a command sequence such as: (port name depends on OS)
Espressif Audio Framework requires `CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY`
which you can set using the configuration menu or editing sdkconfig file.

You can use a command sequence such as: (port name depends on OS)

```bash
cd AtomVM/src/platforms/esp32/
idf.py set-target esp32
echo CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y >> sdkconfig
idf.py build
idf.py -p /dev/cu.usbmodem14401 flash
```

3. Use `atomvm_esp_adf_*` modules in your code.
You will also need to flash AtomVM core libraries.

Alternatively, you can flash an image generated by the [CI of this project](https://github.com/pguyot/atomvm_esp_adf/actions/workflows/build.yml).

3. Use `esp_adf_*` modules in your code.

You can refer to [API documentation](https://pguyot.github.io/atomvm_esp_adf/).

```erlang
AudioPipeline = esp_adf_audio_pipeline:init([]),
Expand Down
12 changes: 12 additions & 0 deletions src/atomvm_esp_adf.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
application, atomvm_esp_adf, [
{description, "Port of ESP ADF for the AtomVM platform"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},
{env,[]},
{modules, []},
{licenses, ["MIT"]},
{links, []}
]
}.
2 changes: 1 addition & 1 deletion src/esp_adf_audio_pipeline.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ register(_AudioPipeline, _AudioElement, _Name) ->
%% @param AudioElement element to unregister
%% @return ok
-spec unregister(audio_pipeline(), audio_element:audio_element()) -> ok.
unregister(_AudioPipeline, _AudioElement, _Name) ->
unregister(_AudioPipeline, _AudioElement) ->
erlang:nif_error(undefined).

%% @doc Link audio elements, i.e. define the pipeline order.
Expand Down

0 comments on commit 3d022bb

Please sign in to comment.