From 3b4f29abc4ef5cfa14954c01ba408cfdd3592d27 Mon Sep 17 00:00:00 2001 From: Peter M Date: Tue, 8 Oct 2024 10:43:36 +0200 Subject: [PATCH] Add Wokwi CI - esp32-simtest.yaml runs the esp32 tests across 7 targets/models and 3 esp-idf versions. Includes the wifi_example test. A limited test scope is the default unless the PR title contains "full_sim_test" or the last commit message contains it in title or body. Signed-off-by: Peter M --- .github/workflows/build-and-test-macos.yaml | 134 ------ .../workflows/build-and-test-on-freebsd.yaml | 133 ------ .github/workflows/build-and-test-other.yaml | 183 -------- .github/workflows/build-and-test.yaml | 391 ------------------ .github/workflows/build-docs.yaml | 118 ------ .github/workflows/build-libraries.yaml | 101 ----- .github/workflows/build-linux-artifacts.yaml | 254 ------------ .github/workflows/check-formatting.yaml | 79 ---- .github/workflows/codeql-analysis.yaml | 77 ---- .github/workflows/esp32-build.yaml | 150 ------- .github/workflows/esp32-mkimage.yaml | 175 -------- .github/workflows/esp32-simtest.yaml | 118 ++++++ .github/workflows/pico-build.yaml | 124 ------ .github/workflows/publish-docs.yaml | 143 ------- .github/workflows/reuse-lint.yaml | 19 - .github/workflows/run-tests-with-beam.yaml | 145 ------- .github/workflows/stm32-build.yaml | 89 ---- .github/workflows/wasm-build.yaml | 248 ----------- src/platforms/esp32/test/CMakeLists.txt | 4 +- src/platforms/esp32/test/README.md | 81 ++++ src/platforms/esp32/test/diagram.esp32.json | 32 ++ .../esp32/test/diagram.esp32.json.license | 2 + .../test/main/test_erl_sources/CMakeLists.txt | 3 + .../test_erl_sources/test_wifi_example.erl | 114 +++++ src/platforms/esp32/test/main/test_main.c | 94 ++++- src/platforms/esp32/test/sdkconfig.ci.wokwi | 7 + .../esp32/test/sdkconfig.ci.wokwi.license | 2 + src/platforms/esp32/test/test_atomvm.py | 7 + src/platforms/esp32/test/wokwi.toml | 5 + src/platforms/esp32/test/wokwi.toml.license | 2 + 30 files changed, 464 insertions(+), 2570 deletions(-) delete mode 100644 .github/workflows/build-and-test-macos.yaml delete mode 100644 .github/workflows/build-and-test-on-freebsd.yaml delete mode 100644 .github/workflows/build-and-test-other.yaml delete mode 100644 .github/workflows/build-and-test.yaml delete mode 100644 .github/workflows/build-docs.yaml delete mode 100644 .github/workflows/build-libraries.yaml delete mode 100644 .github/workflows/build-linux-artifacts.yaml delete mode 100644 .github/workflows/check-formatting.yaml delete mode 100644 .github/workflows/codeql-analysis.yaml delete mode 100644 .github/workflows/esp32-build.yaml delete mode 100644 .github/workflows/esp32-mkimage.yaml create mode 100644 .github/workflows/esp32-simtest.yaml delete mode 100644 .github/workflows/pico-build.yaml delete mode 100644 .github/workflows/publish-docs.yaml delete mode 100644 .github/workflows/reuse-lint.yaml delete mode 100644 .github/workflows/run-tests-with-beam.yaml delete mode 100644 .github/workflows/stm32-build.yaml delete mode 100644 .github/workflows/wasm-build.yaml create mode 100644 src/platforms/esp32/test/README.md create mode 100644 src/platforms/esp32/test/diagram.esp32.json create mode 100644 src/platforms/esp32/test/diagram.esp32.json.license create mode 100644 src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl create mode 100644 src/platforms/esp32/test/sdkconfig.ci.wokwi create mode 100644 src/platforms/esp32/test/sdkconfig.ci.wokwi.license create mode 100644 src/platforms/esp32/test/wokwi.toml create mode 100644 src/platforms/esp32/test/wokwi.toml.license diff --git a/.github/workflows/build-and-test-macos.yaml b/.github/workflows/build-and-test-macos.yaml deleted file mode 100644 index a02d28acc..000000000 --- a/.github/workflows/build-and-test-macos.yaml +++ /dev/null @@ -1,134 +0,0 @@ -# -# Copyright 2017-2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Build and Test on macOS - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-and-test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["macos-13", "macos-14"] - otp: ["24", "25", "26"] - - steps: - # Setup - - name: "Checkout repo" - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: "Install deps" - run: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install gperf doxygen erlang@${{ matrix.otp }} ninja mbedtls - - # Builder info - - name: "System info" - run: | - echo "**uname:**" - uname -a - echo "**C Compiler version:**" - clang --version - clang++ --version - echo "**CMake version:**" - cmake --version - - # Build - - name: "Build: create build dir" - run: mkdir build - - - name: "Build: run cmake" - working-directory: build - run: | - export PATH="/usr/local/opt/erlang@${{ matrix.otp }}/bin:/opt/homebrew/opt/erlang@${{ matrix.otp }}/bin:$PATH" - cmake -DAVM_WARNINGS_ARE_ERRORS=ON -G Ninja .. - - - name: "Build: run ninja" - working-directory: build - run: | - export PATH="/usr/local/opt/erlang@${{ matrix.otp }}/bin:/opt/homebrew/opt/erlang@${{ matrix.otp }}/bin:$PATH" - ninja - - - name: "Build: run dialyzer" - working-directory: build - run: | - export PATH="/usr/local/opt/erlang@${{ matrix.otp }}/bin:/opt/homebrew/opt/erlang@${{ matrix.otp }}/bin:$PATH" - ninja dialyzer - - # Test - - name: "Test: test-erlang" - timeout-minutes: 10 - working-directory: build - run: | - ./tests/test-erlang - - - name: "Test: test-enif" - working-directory: build - run: | - ./tests/test-enif - - - name: "Test: test-mailbox" - working-directory: build - run: | - ./tests/test-mailbox - - - name: "Test: test-structs" - timeout-minutes: 10 - working-directory: build - run: | - ./tests/test-structs - - - name: "Test: test_estdlib.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm - - - name: "Test: test_eavmlib.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm - - - name: "Test: test_alisp.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/alisp/test_alisp.avm - - - name: "Install and smoke test" - working-directory: build - run: | - export PATH="/usr/local/opt/erlang@${{ matrix.otp }}/bin:/opt/homebrew/opt/erlang@${{ matrix.otp }}/bin:$PATH" - sudo ninja install - atomvm examples/erlang/hello_world.avm - atomvm -v - atomvm -h diff --git a/.github/workflows/build-and-test-on-freebsd.yaml b/.github/workflows/build-and-test-on-freebsd.yaml deleted file mode 100644 index adaa6bd2f..000000000 --- a/.github/workflows/build-and-test-on-freebsd.yaml +++ /dev/null @@ -1,133 +0,0 @@ -# -# Copyright 2023 Fred Dushin -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: build-and-test-on-freebsd - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-and-test-on-freebsd: - runs-on: ubuntu-22.04 - name: Build and test AtomVM on FreeBSD - env: - ATOMVM_EXAMPLE: "atomvm-example" - steps: - - - uses: actions/checkout@v4 - - - name: Build and Test on FreeBSD - id: build-and-test-on-freebsd - uses: vmactions/freebsd-vm@v1 - timeout-minutes: 20 - with: - release: 13.2 - envs: 'ATOMVM_EXAMPLE' - usesh: true - sync: rsync - copyback: false - - prepare: | - pkg install -y curl cmake gperf erlang elixir mbedtls - - run: | - - echo "%%" - echo "%% System Info" - echo "%%" - echo "**freebsd-version:**" - freebsd-version - echo "**uname:**" - uname -a - echo "**C Compiler version:**" - clang --version - clang++ --version - echo "**CMake version:**" - cmake --version - echo "**hw.ncpu:**" - sysctl -n hw.ncpu - - echo "%%" - echo "%% Running CMake ..." - echo "%%" - mkdir build - cd build - cmake .. -DMBEDTLS_ROOT_DIR=/usr/local -DAVM_WARNINGS_ARE_ERRORS=ON - - echo "%%" - echo "%% Building AtomVM ..." - echo "%%" - make -j `sysctl -n hw.ncpu` - - echo "%%" - echo "%% Running test-erlang ..." - echo "%%" - ./tests/test-erlang - - echo "%%" - echo "%% Running test-enif ..." - echo "%%" - ./tests/test-enif - - echo "%%" - echo "%% Running test-mailbox ..." - echo "%%" - ./tests/test-mailbox - - echo "%%" - echo "%% Running test-structs ..." - echo "%%" - ./tests/test-structs - - echo "%%" - echo "%% Running estdlib tests ..." - echo "%%" - ./src/AtomVM tests/libs/estdlib/test_estdlib.avm - - echo "%%" - echo "%% Running eavmlib tests ..." - echo "%%" - ./src/AtomVM tests/libs/eavmlib/test_eavmlib.avm - - echo "%%" - echo "%% Running alisp tests ..." - echo "%%" - ./src/AtomVM tests/libs/alisp/test_alisp.avm - - echo "%%" - echo "%% Running install ..." - echo "%%" - make install - atomvm examples/erlang/hello_world.avm - atomvm -v - atomvm -h - - echo "%%" - echo "%% Done!" - echo "%%" diff --git a/.github/workflows/build-and-test-other.yaml b/.github/workflows/build-and-test-other.yaml deleted file mode 100644 index 98502a79d..000000000 --- a/.github/workflows/build-and-test-other.yaml +++ /dev/null @@ -1,183 +0,0 @@ -# -# Copyright 2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Build and Test on Other Architectures - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - compile_tests: - runs-on: ubuntu-24.04 - container: erlang:27 - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Install required packages - run: apt update && apt install -y gperf zlib1g-dev cmake ninja-build - - - name: Compile test modules - run: | - set -e - mkdir build_tests - cd build_tests - cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON - ninja erlang_test_modules test_estdlib test_eavmlib test_alisp - - - name: Upload test modules - uses: actions/upload-artifact@v4 - with: - name: test-modules - path: | - build_tests/**/*.avm - build_tests/**/*.beam - build_tests/**/*.hrl - retention-days: 1 - - build-and-test-other: - needs: compile_tests - runs-on: ubuntu-24.04 - - strategy: - fail-fast: false - matrix: - arch: ["arm32v5", "arm32v7", "arm64v8"] - - include: - - arch: "arm32v5" - platform: "arm/v5" - cflags: "-O2 -mthumb -mthumb-interwork -march=armv4t" - cmake_opts: "-DAVM_DISABLE_SMP=On -DAVM_DISABLE_TASK_DRIVER=On" - tag: "stretch" - sources: | - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports main - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports-sloppy main - deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb-src [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb [trusted=yes] http://archive.debian.org/debian/ stretch main - deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main - # Workaround from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954852 - install_deps: | - apt update && - apt install -y -t stretch-backports-sloppy libarchive13 && - apt install -y -t stretch-backports cmake && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev - - - arch: "arm32v7" - platform: "arm/v7" - tag: "bullseye" - # -D_FILE_OFFSET_BITS=64 is required for making atomvm:posix_readdir/1 test work - # otherwise readdir will fail due to 64 bits inode numbers with 32 bit ino_t - cflags: "-mcpu=cortex-a7 -mfloat-abi=hard -O2 -mthumb -mthumb-interwork -D_FILE_OFFSET_BITS=64" - cmake_opts: "-DAVM_WARNINGS_ARE_ERRORS=ON" - - - arch: "arm64v8" - platform: "arm64/v8" - tag: "bullseye" - cflags: "-O2" - cmake_opts: "-DAVM_WARNINGS_ARE_ERRORS=ON" - - # Required for testing big endian archs - - arch: "s390x" - platform: "s390x" - tag: "bullseye" - cflags: "-O2" - cmake_opts: "-DAVM_WARNINGS_ARE_ERRORS=ON" - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: apt update - run: sudo apt update - - - name: Install required packages - run: sudo apt install -y debootstrap - - - name: Download test modules - uses: actions/download-artifact@v4 - with: - name: test-modules - path: build_tests - - - name: Set up QEMU - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - - name: "Build and Test: AtomVM on foreign arch" - timeout-minutes: 15 - run: | - docker run --platform linux/${{ matrix.platform }} --rm -v $PWD:/atomvm -w /atomvm \ - -e CFLAGS="${{ matrix.cflags }}" -e CXXFLAGS="${{ matrix.cflags }}" \ - ${{ matrix.arch }}/debian:${{ matrix.tag }} /bin/bash -c ' - ([ -n "${{ matrix.sources }}" ] && echo "${{ matrix.sources }}" > /etc/apt/sources.list || true) && - cat /etc/apt/sources.list && - if test -n "${{ matrix.install_deps }}"; then - echo - ${{ matrix.install_deps }} - else - apt update && - apt install -y file gcc g++ binutils cmake make doxygen gperf zlib1g-dev libmbedtls-dev - fi && - file /bin/bash && - uname -a && - cc --version && - ld --version && - ldd --version && - echo $CFLAGS && - echo $CXXFLAGS && - cmake --version && - mkdir -p build && - cd build && - cmake .. ${{ matrix.cmake_opts }} && - cp ../build_tests/tests/erlang_tests/*.beam tests/erlang_tests/ && - cp ../build_tests/tests/erlang_tests/code_load/*.{avm,beam,hrl} tests/erlang_tests/code_load/ && - mkdir -p tests/erlang_tests/code_load/beams/ && - cp ../build_tests/tests/erlang_tests/code_load/beams/*.beam tests/erlang_tests/code_load/beams/ && - cp ../build_tests/tests/libs/estdlib/*.avm tests/libs/estdlib/ && - cp ../build_tests/tests/libs/eavmlib/*.avm tests/libs/eavmlib/ && - cp ../build_tests/tests/libs/alisp/*.avm tests/libs/alisp/ && - make AtomVM && - make test-erlang && - make test-enif && - make test-mailbox && - make test-structs && - file ./tests/test-erlang && - ./tests/test-erlang -s prime_smp && - file ./tests/test-enif && - ./tests/test-enif && - file ./tests/test-mailbox && - ./tests/test-mailbox && - file ./tests/test-structs && - ./tests/test-structs && - file ./src/AtomVM && - ./src/AtomVM tests/libs/estdlib/test_estdlib.avm && - ./src/AtomVM tests/libs/eavmlib/test_eavmlib.avm && - ./src/AtomVM tests/libs/alisp/test_alisp.avm - ' diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml deleted file mode 100644 index 74047161e..000000000 --- a/.github/workflows/build-and-test.yaml +++ /dev/null @@ -1,391 +0,0 @@ -# -# Copyright 2017-2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Build and Test - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-and-test: - runs-on: ${{ matrix.os }} - strategy: - - fail-fast: false - - matrix: - # Ubuntu 20.04 has gcc from 7 to 10 ("gcc" is gcc-9) - # Ubuntu 22.04 has gcc from 9 to 12 ("gcc" is gcc-11) - # Ubuntu 24.04 has gcc from 9 to 14 ("gcc" is gcc-13) - # Ubuntu 20.04 has clang 10 and 12 to ("clang" is 10) - # Ubuntu 22.04 has clang from 12 to 15 ("clang" is 14) - # Ubuntu 24.04 has clang from 14 to 18 ("clang" is 18) - # We want to test every compiler but don't need to test every OS - # We only test several OTP versions with default compilers (gcc-9, 11, 13, clang-10, 14, 18) - cc: ["gcc-9", "gcc-11", "gcc-13", "clang-10", "clang-14", "clang-18"] - cflags: ["-O3"] - otp: ["25", "26", "27"] - - include: - - cc: "gcc-7" - cxx: "g++-7" - compiler_pkgs: "gcc-7 g++-7" - os: "ubuntu-20.04" - otp: "27" - - cc: "gcc-8" - cxx: "g++-8" - compiler_pkgs: "gcc-8 g++-8" - os: "ubuntu-20.04" - otp: "27" - - cc: "gcc-9" - cxx: "g++-9" - compiler_pkgs: "gcc-9 g++-9" - os: "ubuntu-20.04" - # otp: all - - cc: "gcc-10" - cxx: "g++-10" - compiler_pkgs: "gcc-10 g++-10" - # Use Werror for recent GCC versions that have better diagnostics - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-22.04" - otp: "27" - - cc: "gcc-11" - cxx: "g++-11" - compiler_pkgs: "gcc-11 g++-11" - # Use Werror for recent GCC versions that have better diagnostics - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-22.04" - # otp: all - - cc: "gcc-12" - cxx: "g++-12" - compiler_pkgs: "gcc-12 g++-12" - # Use Werror for recent GCC versions that have better diagnostics - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - otp: "27" - - cc: "gcc-13" - cxx: "g++-13" - compiler_pkgs: "gcc-13 g++-13" - # Use Werror for recent GCC versions that have better diagnostics - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - # otp: all - - cc: "gcc-14" - cxx: "g++-14" - compiler_pkgs: "gcc-14 g++-14" - # Use Werror for recent GCC versions that have better diagnostics - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - otp: "27" - - - cc: "clang-10" - cxx: "clang++-10" - compiler_pkgs: "clang-10" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-20.04" - # otp: all - - cc: "clang-11" - cxx: "clang++-11" - compiler_pkgs: "clang-11" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-20.04" - otp: "27" - - cc: "clang-12" - cxx: "clang++-12" - compiler_pkgs: "clang-12" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-22.04" - otp: "27" - - cc: "clang-13" - cxx: "clang++-13" - compiler_pkgs: "clang-13" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-22.04" - otp: "27" - - cc: "clang-14" - cxx: "clang++-14" - compiler_pkgs: "clang-14" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-22.04" - # otp: all - - cc: "clang-15" - cxx: "clang++-15" - compiler_pkgs: "clang-15" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - otp: "27" - - cc: "clang-16" - cxx: "clang++-16" - compiler_pkgs: "clang-16" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - otp: "27" - - cc: "clang-17" - cxx: "clang++-17" - compiler_pkgs: "clang-17" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - otp: "27" - - cc: "clang-18" - cxx: "clang++-18" - compiler_pkgs: "clang-18" - cmake_opts_other: "-DAVM_WARNINGS_ARE_ERRORS=ON" - os: "ubuntu-24.04" - # otp: all - - - otp: "25" - elixir_version: "1.14" - - - otp: "26" - elixir_version: "1.17" - - - otp: "27" - elixir_version: "1.17" - - # Old versions of OTP/Elixir - - os: "ubuntu-20.04" - cc: "cc" - cxx: "c++" - otp: "21" - cflags: "" - elixir_version: "1.7" - - - os: "ubuntu-20.04" - cc: "cc" - cxx: "c++" - otp: "22" - cflags: "" - elixir_version: "1.8" - - - os: "ubuntu-20.04" - cc: "cc" - cxx: "c++" - otp: "23" - cflags: "" - elixir_version: "1.11" - - - os: "ubuntu-22.04" - cc: "cc" - cxx: "c++" - otp: "24" - cflags: "" - elixir_version: "1.14" - - # master/main version of OTP/Elixir - - os: "ubuntu-24.04" - cc: "cc" - cxx: "c++" - otp: "master" - elixir_version: "main" - - # Additional default compiler builds - - os: "ubuntu-20.04" - cc: "cc" - cxx: "c++" - otp: "27" - cflags: "" - elixir_version: "1.17" - - - os: "ubuntu-22.04" - cc: "cc" - cxx: "c++" - otp: "27" - cflags: "" - elixir_version: "1.17" - - # Additional latest & -Os compiler builds - - os: "ubuntu-24.04" - cc: "gcc-14" - cxx: "g++-14" - otp: "27" - cflags: "-Os" - elixir_version: "1.17" - compiler_pkgs: "gcc-14 g++-14" - - - os: "ubuntu-24.04" - cc: "clang-18" - cxx: "clang++-18" - otp: "27" - cflags: "-Os" - elixir_version: "1.17" - compiler_pkgs: "clang-18" - - # Additional 32 bits build - - os: "ubuntu-20.04" - cc: "gcc-10" - cxx: "g++-10" - cflags: "-m32 -O3" - otp: "23" - elixir_version: "1.11" - # Use Werror so we get an error with 32 bit specific warnings - cmake_opts_other: "-DAVM_CREATE_STACKTRACES=off -DAVM_WARNINGS_ARE_ERRORS=ON" - arch: "i386" - compiler_pkgs: "gcc-10 g++-10 gcc-10-multilib g++-10-multilib libc6-dev-i386 - libc6-dbg:i386 zlib1g-dev:i386 libmbedtls-dev:i386" - - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - CFLAGS: ${{ matrix.cflags }} - CXXFLAGS: ${{ matrix.cflags }} - - steps: - # Setup - - name: "Checkout repo" - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.otp }} - elixir-version: ${{ matrix.elixir_version }} - hexpm-mirrors: | - https://builds.hex.pm - https://repo.hex.pm - https://cdn.jsdelivr.net/hex - - - name: "Add i386 architecture" - if: matrix.arch == 'i386' - run: sudo dpkg --add-architecture i386 - - - name: "APT update" - run: sudo apt update -y - - - name: "Install deps" - run: sudo apt install -y ${{ matrix.compiler_pkgs}} cmake gperf zlib1g-dev doxygen valgrind libmbedtls-dev - - # Builder info - - name: "System info" - run: | - echo "**uname:**" - uname -a - echo "**libc version:**" - ldd --version - echo "**C Compiler version:**" - $CC --version - $CXX --version - echo "**Linker version:**" - ld --version - echo "**CMake version:**" - cmake --version - echo "**OTP version:**" - cat $(dirname $(which erlc))/../releases/RELEASES || true - - # Build - - name: "Build: create build dir" - run: mkdir build - - - uses: actions/cache@v4 - id: cache - with: - path: 'build/tests/**/*.beam' - key: ${{ matrix.otp }}-${{ hashFiles('**/build-and-test.yaml', 'tests/**/*.erl') }} - - - name: "Build: run cmake" - working-directory: build - run: | - cmake ${{ matrix.cmake_opts_fp }} ${{ matrix.cmake_opts_smp }} ${{ matrix.cmake_opts_other }} .. - # git clone will use more recent timestamps than cached beam files - # touch them so we can benefit from the cache and avoid costly beam file rebuild. - find . -name '*.beam' -exec touch {} \; - - - name: "Build: run make" - working-directory: build - run: make - - - name: "Build: run dialyzer" - working-directory: build - run: make dialyzer - - # Test - - name: "Test: test-erlang" - timeout-minutes: 15 - working-directory: build - run: | - ./tests/test-erlang -s prime_smp - valgrind ./tests/test-erlang -s prime_smp - - - name: "Test: test-enif" - working-directory: build - run: | - ./tests/test-enif - valgrind ./tests/test-enif - - - name: "Test: test-mailbox" - working-directory: build - run: | - ./tests/test-mailbox - valgrind ./tests/test-mailbox - - - name: "Test: test-structs" - timeout-minutes: 10 - working-directory: build - run: | - ./tests/test-structs - valgrind ./tests/test-structs - - - name: "Test: test_estdlib.avm" - timeout-minutes: 5 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm - valgrind ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm - - - name: "Test: test_eavmlib.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm - valgrind ./src/AtomVM ./tests/libs/eavmlib/test_eavmlib.avm - - - name: "Test: test_alisp.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/alisp/test_alisp.avm - valgrind ./src/AtomVM ./tests/libs/alisp/test_alisp.avm - - - name: "Test: Tests.avm (Elixir)" - timeout-minutes: 10 - working-directory: build - run: | - if command -v elixirc &> /dev/null - then - ./src/AtomVM ./tests/libs/exavmlib/Tests.avm - valgrind ./src/AtomVM ./tests/libs/exavmlib/Tests.avm - fi - - - name: "Install and smoke test" - working-directory: build - run: | - sudo PATH=${PATH} make install - atomvm examples/erlang/hello_world.avm - atomvm -v - atomvm -h diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml deleted file mode 100644 index 499eaa72c..000000000 --- a/.github/workflows/build-docs.yaml +++ /dev/null @@ -1,118 +0,0 @@ -# -# Copyright 2023 Winford (Uncle Grumpy) -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# -# This is a workflow for atomvm/AtomVM to Publish API documentation and other content from the `doc` directory to -# atomvm.net hosted on GitHub Pages - -name: Build Docs - -# Controls when the workflow will run -on: - # Triggers the workflow on push request and tag events on main branch - pull_request: - tags: - - '**' - branches: - - 'main' - - 'release-**' - paths: - - '.github/workflows/**' - - 'CMakeLists.txt' - - 'doc/**' - - 'libs/**' - - 'src/libAtomVM/**' - push: - repositories: - - '!atomvm/AtomVM' - paths: - - '.github/workflows/**' - - 'CMakeLists.txt' - - 'doc/**' - - 'libs/**' - - 'src/libAtomVM/**' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - - strategy: - fail-fast: false - ## don't add more than one OS to matrix, this is only to retrieve the full os-name for keeping cache in sync - matrix: - os: [ ubuntu-24.04 ] - # The type of runner that the job will run on - runs-on: ${{ matrix.os }} - # Documentation currently fails to build with OTP-27 - container: erlang:26 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Install Deps - run: | - apt update -y - DEBIAN_FRONTEND=noninteractive apt install -y git cmake doxygen graphviz python3-pip python3-virtualenv python3.11-venv python3-setuptools python3-stemmer wget - - - uses: actions/cache@v4 - id: sphinx-cache - with: - path: /home/runner/python-env/sphinx - key: ${{ matrix.os }}-${{ job.container.id }}-sphinx-install - - - name: Install Sphinx - if: ${{ steps.sphinx-cache.outputs.cache-hit != 'true' }} - run: | - python3 -m venv /home/runner/python-env/sphinx - . /home/runner/python-env/sphinx/bin/activate - python3 -m pip install sphinx - python3 -m pip install myst-parser - python3 -m pip install sphinx-rtd-theme - python3 -m pip install rinohtype - python3 -m pip install pillow - python3 -m pip install gitpython - python3 -m pip install breathe - python3 -m pip install pygments - - - name: Set docs target name - shell: bash - run: | - if [[ ${{ github.ref_name }} == *"/merge" ]]; then - echo "AVM_DOCS_NAME=${{github.event.pull_request.base.ref}}" >> "$GITHUB_ENV"; - else - echo "AVM_DOCS_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"; - fi - - - uses: actions/checkout@v4 - with: - repository: ${{ vars.GITHUB_REPOSITORY }} - fetch-depth: 0 - - - name: Track all branches - shell: bash - run: | - git config --global --add safe.directory /__w/AtomVM/AtomVM - for branch in `git branch -a | grep "remotes/origin" | grep -v HEAD | grep -v "${{ github.ref_name }}"`; do - git branch --track ${branch#remotes/origin/} $branch - done - - - name: Build Site - id: build - shell: bash - run: | - . /home/runner/python-env/sphinx/bin/activate - git config --global --add safe.directory ${PWD} - mkdir build - cd build - cmake .. - cd doc - make GitHub_CI_Publish_Docs diff --git a/.github/workflows/build-libraries.yaml b/.github/workflows/build-libraries.yaml deleted file mode 100644 index 1eec21986..000000000 --- a/.github/workflows/build-libraries.yaml +++ /dev/null @@ -1,101 +0,0 @@ -# -# Copyright 2017-2023 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Build Libraries - -on: - push: - tags: - - '**' - -permissions: - contents: write - -jobs: - build-libraries: - runs-on: "ubuntu-22.04" - strategy: - fail-fast: false - - steps: - - name: "Checkout repo" - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - uses: erlef/setup-beam@v1 - with: - otp-version: "24" - elixir-version: "1.11" - - - name: "APT update" - run: sudo apt update -y - - - name: "Install deps" - run: sudo apt install -y build-essential cmake gperf zlib1g-dev libmbedtls-dev valgrind - - # Builder info - - name: "System info" - run: | - echo "**uname:**" - uname -a - echo "**libc version:**" - ldd --version - echo "**C Compiler version:**" - cc --version - c++ --version - echo "**Linker version:**" - ld --version - echo "**CMake version:**" - cmake --version - echo "**OTP version:**" - cat $(dirname $(which erlc))/../releases/RELEASES || true - - # Build - - name: "Build: create build dir" - run: mkdir build - - - name: "Build: run cmake" - working-directory: build - run: | - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. - - - name: "Build: run make" - working-directory: build - run: make - - - name: "Build: run dialyzer" - working-directory: build - run: make dialyzer - - - name: "Test: test_estdlib.avm" - timeout-minutes: 10 - working-directory: build - run: | - ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm - valgrind ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm - - - name: "Rename and write sha256sum" - working-directory: build - run: | - ATOMVMLIB_FILE=atomvmlib-${{ github.ref_name }}.avm - mv libs/atomvmlib.avm "libs/${ATOMVMLIB_FILE}" && - sha256sum "libs/${ATOMVMLIB_FILE}" > "libs/${ATOMVMLIB_FILE}.sha256" - HELLO_WORLD_FILE=hello_world-${{ github.ref_name }}.avm - mv examples/erlang/hello_world.avm "examples/erlang/${HELLO_WORLD_FILE}" - sha256sum "examples/erlang/${HELLO_WORLD_FILE}" > "examples/erlang/${HELLO_WORLD_FILE}.sha256" - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - build/libs/atomvmlib-${{ github.ref_name }}.avm - build/libs/atomvmlib-${{ github.ref_name }}.avm.sha256 - build/examples/erlang/hello_world-${{ github.ref_name }}.avm - build/examples/erlang/hello_world-${{ github.ref_name }}.avm.sha256 diff --git a/.github/workflows/build-linux-artifacts.yaml b/.github/workflows/build-linux-artifacts.yaml deleted file mode 100644 index e45c781bc..000000000 --- a/.github/workflows/build-linux-artifacts.yaml +++ /dev/null @@ -1,254 +0,0 @@ -# -# Copyright 2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Build Linux Artifacts - -on: - push: - tags: - - '**' - -permissions: - contents: write - -env: - otp_version: 24 - elixir_version: 1.14 - -jobs: - compile_tests: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ env.otp_version }} - elixir-version: ${{ env.elixir_version }} - - - name: apt update - run: sudo apt update - - - name: Install required packages - run: sudo apt install -y gperf - - - name: Compile test modules - run: | - set -e - mkdir build_tests - cd build_tests - cmake .. - make erlang_test_modules - make test_estdlib - make test_eavmlib - make test_alisp - - - name: Upload test modules - uses: actions/upload-artifact@v4 - with: - name: test-modules - path: | - build_tests/**/*.avm - build_tests/**/*.beam - build_tests/**/*.hrl - retention-days: 1 - - build-and-test-other: - needs: compile_tests - runs-on: ubuntu-22.04 - - strategy: - fail-fast: false - matrix: - include: - - arch: "arm32v5" - build_name: "linux-arm32v5" - docker_image: "arm32v5/debian" - platform: "arm/v5" - cflags: "-mthumb -mthumb-interwork -march=armv4t" - cmake_opts: "-DAVM_DISABLE_SMP=On -DAVM_DISABLE_TASK_DRIVER=On" - tag: "stretch" - sources: | - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports main - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports-sloppy main - deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb-src [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb [trusted=yes] http://archive.debian.org/debian/ stretch main - deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main - # Workaround from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954852 - install_deps: | - apt update && - apt install -y -t stretch-backports-sloppy libarchive13 && - apt install -y -t stretch-backports cmake && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev tzdata - - - arch: "arm32v7" - build_name: "linux-arm32v7thl" - docker_image: "arm32v7/debian" - platform: "arm/v7" - tag: "stretch" - cflags: "-mfloat-abi=hard -mthumb -mthumb-interwork" - sources: | - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports main - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports-sloppy main - deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb-src [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb [trusted=yes] http://archive.debian.org/debian/ stretch main - deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main - # Workaround from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954852 - install_deps: | - apt update && - apt install -y -t stretch-backports-sloppy libarchive13 && - apt install -y -t stretch-backports cmake && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev tzdata - - - arch: "arm64v8" - build_name: "linux-arm64v8" - docker_image: "arm64v8/ubuntu" - platform: "arm64/v8" - tag: "22.04" - cflags: "" - - - arch: "riscv64" - build_name: "linux-riscv64" - docker_image: "riscv64/ubuntu" - platform: "riscv64" - tag: "22.04" - cflags: "" - - - arch: "x86_64" - build_name: "linux-x86_64-static-mbedtls" - docker_image: "ubuntu" - platform: "amd64" - tag: "18.04" - cflags: "" - cmake_opts: "-DAVM_STATIC_MBEDTLS=ON" - install_deps: | - apt update && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev wget tzdata && - apt purge -y cmake && - wget https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.tar.gz && - tar xf cmake-3.13.5-Linux-x86_64.tar.gz && - mv cmake-3.13.5-Linux-x86_64 /opt/cmake-3.13.5 && - ln -sf /opt/cmake-3.13.5/bin/* /usr/bin/ - - - arch: "x86_64" - build_name: "linux-x86_64" - docker_image: "ubuntu" - platform: "amd64" - tag: "18.04" - cflags: "" - install_deps: | - apt update && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev wget tzdata && - apt purge -y cmake && - wget https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.tar.gz && - tar xf cmake-3.13.5-Linux-x86_64.tar.gz && - mv cmake-3.13.5-Linux-x86_64 /opt/cmake-3.13.5 && - ln -sf /opt/cmake-3.13.5/bin/* /usr/bin/ - - - arch: "i386" - build_name: "linux-i386" - docker_image: "i386/debian" - platform: "386" - cflags: "" - tag: "stretch" - sources: | - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports main - deb [trusted=yes] http://archive.debian.org/debian/ stretch-backports-sloppy main - deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb-src [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main - deb [trusted=yes] http://archive.debian.org/debian/ stretch main - deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main - # Workaround from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954852 - install_deps: | - apt update && - apt install -y -t stretch-backports-sloppy libarchive13 && - apt install -y -t stretch-backports cmake && - apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libmbedtls-dev - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: apt update - run: sudo apt update - - - name: Install required packages - run: sudo apt install -y debootstrap - - - name: Download test modules - uses: actions/download-artifact@v4 - with: - name: test-modules - path: build_tests - - - name: Set up QEMU - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - - name: Build AtomVM using docker - timeout-minutes: 15 - run: | - docker run --platform linux/${{ matrix.platform }} --rm -v $PWD:/atomvm -w /atomvm \ - -e CFLAGS="${{ matrix.cflags }}" -e CXXFLAGS="${{ matrix.cflags }}" \ - ${{ matrix.docker_image }}:${{ matrix.tag }} /bin/bash -c ' - ([ -n "${{ matrix.sources }}" ] && echo "${{ matrix.sources }}" > /etc/apt/sources.list || true) && - cat /etc/apt/sources.list && - if test -n "${{ matrix.install_deps }}"; then - echo - ${{ matrix.install_deps }} - else - apt update && - apt install -y file gcc g++ binutils cmake make doxygen gperf zlib1g-dev libmbedtls-dev tzdata - fi && - file /bin/bash && - uname -a && - cc --version && - ld --version && - ldd --version && - echo $CFLAGS && - echo $CXXFLAGS && - cmake --version && - mkdir -p build && - cd build && - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo ${{ matrix.cmake_opts }} && - cp ../build_tests/tests/erlang_tests/*.beam tests/erlang_tests/ && - cp ../build_tests/tests/erlang_tests/code_load/*.{avm,beam,hrl} tests/erlang_tests/code_load/ && - mkdir -p tests/erlang_tests/code_load/beams/ && - cp ../build_tests/tests/erlang_tests/code_load/beams/*.beam tests/erlang_tests/code_load/beams/ && - cp ../build_tests/tests/libs/estdlib/*.avm tests/libs/estdlib/ && - cp ../build_tests/tests/libs/eavmlib/*.avm tests/libs/eavmlib/ && - cp ../build_tests/tests/libs/alisp/*.avm tests/libs/alisp/ && - VERBOSE=1 make AtomVM && - make test-erlang && - make test-enif && - make test-mailbox && - make test-structs && - file ./tests/test-erlang && - ./tests/test-erlang -s prime_smp && - file ./tests/test-enif && - ./tests/test-enif && - file ./tests/test-mailbox && - ./tests/test-mailbox && - file ./tests/test-structs && - ./tests/test-structs && - file ./src/AtomVM && - ./src/AtomVM tests/libs/estdlib/test_estdlib.avm && - ./src/AtomVM tests/libs/eavmlib/test_eavmlib.avm && - ./src/AtomVM tests/libs/alisp/test_alisp.avm && - cp ./src/AtomVM ./AtomVM-${{ matrix.build_name }}-${{ github.ref_name }} && - sha256sum ./src/AtomVM > ./AtomVM-${{ matrix.build_name }}-${{ github.ref_name }}.sha256 - ' - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - build/AtomVM* diff --git a/.github/workflows/check-formatting.yaml b/.github/workflows/check-formatting.yaml deleted file mode 100644 index 18a1b62e7..000000000 --- a/.github/workflows/check-formatting.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright 2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: "Check formatting" - -on: - push: - paths: - - '.github/workflows/**' - - 'CMakeLists.txt' - - 'src/**' - - 'tests/**' - - '**/*.erl' - pull_request: - paths: - - '.github/workflows/**' - - 'CMakeLists.txt' - - 'src/**' - - 'tests/**' - - '**/*.erl' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - clang-format-prettier-check: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - - name: "Install run-clang-format" - run: | - wget -q -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main" | sudo tee -a /etc/apt/sources.list - echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y clang-format-16 - curl -sSfL https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py -o run-clang-format - chmod +x run-clang-format - - - name: "Check formatting with clang-format" - run: | - ./run-clang-format --style=file --clang-format-executable=clang-format-16 -r src/ tests/ - - - name: "Check formatting with prettier" - if: success() || failure() - run: | - npm install prettier - find ../src/platforms/emscripten/ ../examples/emscripten/ -name "*.js" -o -name "*.html" | xargs npx prettier -c - - erlfmt-check: - runs-on: ubuntu-24.04 - container: erlang:27 - steps: - - uses: actions/checkout@v4 - - - name: "Check formatting with Erlang fmt" - run: | - cd .. - git clone --depth 1 -b v1.1.0 https://github.com/WhatsApp/erlfmt.git - cd erlfmt - rebar3 as release escriptize - cd ../AtomVM - find . -name *.erl | xargs ../erlfmt/_build/release/bin/erlfmt -c - - mix-format-check: - runs-on: ubuntu-24.04 - container: elixir:1.17.1 - steps: - - uses: actions/checkout@v4 - - - name: "Check formatting with Elixir mix format" - run: | - cd libs/exavmlib/ - mix format --check-formatted diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml deleted file mode 100644 index f8e9ae190..000000000 --- a/.github/workflows/codeql-analysis.yaml +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright 2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: "CodeQL" - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'libs/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'libs/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - schedule: - - cron: '45 18 * * 5' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - - steps: - - name: "APT update" - run: sudo apt update -y - - - name: "Install deps" - run: sudo apt install -y cmake gperf zlib1g-dev ninja-build erlang - - - name: "Checkout repository" - uses: actions/checkout@v4 - - - name: "Initialize CodeQL" - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - queries: +./code-queries/term-to-non-term-func.ql,./code-queries/non-term-to-term-func.ql - - - name: "Build" - run: | - mkdir build - cd build - cmake .. -G Ninja - ninja - - - name: "Perform CodeQL Analysis" - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/esp32-build.yaml b/.github/workflows/esp32-build.yaml deleted file mode 100644 index 1536cda20..000000000 --- a/.github/workflows/esp32-build.yaml +++ /dev/null @@ -1,150 +0,0 @@ -# -# Copyright 2022 Davide Bettio -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: ESP32 Builds - -on: - push: - paths: - - '.github/workflows/esp32-build.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/esp32/**' - - 'src/platforms/esp32/**/**' - - 'src/libAtomVM/**' - - 'tools/packbeam/**' - pull_request: - paths: - - '.github/workflows/esp32-build.yaml' - - 'src/platforms/esp32/**' - - 'src/platforms/esp32/**/**' - - 'src/libAtomVM/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - esp-idf: - runs-on: ubuntu-latest - container: espressif/idf:${{ matrix.idf-version }} - - strategy: - fail-fast: false - - matrix: - esp-idf-target: ["esp32", "esp32c3"] - idf-version: - - 'v5.0.7' - - 'v5.1.4' - - 'v5.2.2' - - 'v5.3.1' - - exclude: - - esp-idf-target: "esp32c3" - idf-version: 'v5.0.7' - - esp-idf-target: "esp32c3" - idf-version: 'v5.1.4' - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Build with idf.py - shell: bash - working-directory: ./src/platforms/esp32/ - run: | - . $IDF_PATH/export.sh - export IDF_TARGET=${{matrix.esp-idf-target}} - idf.py set-target ${{matrix.esp-idf-target}} - idf.py build - idf.py size - - name: Print component size info with idf.py - shell: bash - working-directory: ./src/platforms/esp32/ - run: | - . $IDF_PATH/export.sh - idf.py size-components - - - name: Install dependencies to build host AtomVM and run qemu - run: | - set -eu - apt update - DEBIAN_FRONTEND=noninteractive apt install -y -q \ - doxygen erlang-base erlang-dialyzer \ - libglib2.0-0 libpixman-1-0 \ - gcc g++ zlib1g-dev libsdl2-2.0-0 libslirp0 libmbedtls-dev - - - name: Install qemu binary from espressif/qemu esp32 - if: runner.arch != 'ARM64' && runner.os == 'Linux' && matrix.esp-idf-target == 'esp32' - run: | - set -eu - QEMU_VER=esp-develop-9.0.0-20240606 - QEMU_XTENSA_DIST=qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz - QEMU_XTENSA_SHA256=071d117c44a6e9a1bc8664ab63b592d3e17ceb779119dcb46c59571a4a7a88c9 - wget --no-verbose https://github.com/espressif/qemu/releases/download/${QEMU_VER}/${QEMU_XTENSA_DIST} - echo "${QEMU_XTENSA_SHA256} *${QEMU_XTENSA_DIST}" | sha256sum --check --strict - - tar -xf ${QEMU_XTENSA_DIST} -C /opt && rm ${QEMU_XTENSA_DIST} - - - name: Install qemu binary from espressif/qemu esp32c3 - if: runner.arch != 'ARM64' && runner.os == 'Linux' && matrix.esp-idf-target == 'esp32c3' - run: | - set -eu - QEMU_VER=esp-develop-9.0.0-20240606 - QEMU_RISCV32_DIST=qemu-riscv32-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz - QEMU_RISCV32_SHA256=47120e826cfec7180db8cb611a7a4aed2e9b2191c2a739194f8ce085e63cdd8d - wget --no-verbose https://github.com/espressif/qemu/releases/download/${QEMU_VER}/${QEMU_RISCV32_DIST} - echo "${QEMU_RISCV32_SHA256} *${QEMU_RISCV32_DIST}" | sha256sum --check --strict - - tar -xf ${QEMU_RISCV32_DIST} -C /opt && rm ${QEMU_RISCV32_DIST} - - - name: Install qemu binary from espressif/qemu ARM64 esp32 - if: runner.arch == 'ARM64' && runner.os == 'Linux' && matrix.esp-idf-target == 'esp32' - run: | - set -eu - QEMU_VER=esp-develop-9.0.0-20240606 - QEMU_XTENSA_DIST=qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-aarch64-linux-gnu.tar.xz - QEMU_XTENSA_SHA256=43552f32b303a6820d0d9551903e54fc221aca98ccbd04e5cbccbca881548008 - wget --no-verbose https://github.com/espressif/qemu/releases/download/${QEMU_VER}/${QEMU_XTENSA_DIST} - echo "${QEMU_XTENSA_SHA256} *${QEMU_XTENSA_DIST}" | sha256sum --check --strict - - tar -xf ${QEMU_XTENSA_DIST} -C /opt && rm ${QEMU_XTENSA_DIST} - - - name: Install qemu binary from espressif/qemu ARM64 esp32c3 - if: runner.arch == 'ARM64' && runner.os == 'Linux' && matrix.esp-idf-target == 'esp32c3' - run: | - set -eu - QEMU_VER=esp-develop-9.0.0-20240606 - QEMU_RISCV32_DIST=qemu-riscv32-softmmu-esp_develop_9.0.0_20240606-aarch64-linux-gnu.tar.xz - QEMU_RISCV32_SHA256=3b6221a8b1881d2c9b9fa0b0bf8d7065c84153d2a54e429307bde9feae235c27 - wget --no-verbose https://github.com/espressif/qemu/releases/download/${QEMU_VER}/${QEMU_RISCV32_DIST} - echo "${QEMU_RISCV32_SHA256} *${QEMU_RISCV32_DIST}" | sha256sum --check --strict - - tar -xf ${QEMU_RISCV32_DIST} -C /opt && rm ${QEMU_RISCV32_DIST} - - - name: Install pytest and pytest-embedded plugins - run: | - set -e - . $IDF_PATH/export.sh - pip install pytest==8.2.2 \ - pytest-embedded==1.10.3 \ - pytest-embedded-serial-esp==1.10.3 \ - pytest-embedded-idf==1.10.3 \ - pytest-embedded-qemu==1.10.3 - - - name: Build ESP32 tests using idf.py - working-directory: ./src/platforms/esp32/test/ - run: | - set -e - . $IDF_PATH/export.sh - export IDF_TARGET=${{matrix.esp-idf-target}} - idf.py set-target ${{matrix.esp-idf-target}} - idf.py build - - - name: Run ESP32 tests using qemu - working-directory: ./src/platforms/esp32/test/ - timeout-minutes: 10 - run: | - set -e - . $IDF_PATH/export.sh - export PATH=/opt/qemu/bin:${PATH} - pytest --target=${{matrix.esp-idf-target}} --embedded-services=idf,qemu -s diff --git a/.github/workflows/esp32-mkimage.yaml b/.github/workflows/esp32-mkimage.yaml deleted file mode 100644 index ff59d0e2f..000000000 --- a/.github/workflows/esp32-mkimage.yaml +++ /dev/null @@ -1,175 +0,0 @@ -# -# Copyright 2022 Fred Dushin -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: esp32-mkimage - -on: - push: - paths: - - '.github/workflows/esp32-mkimage.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/esp32/**' - - 'src/platforms/esp32/**/**' - - 'src/libAtomVM/**' - - 'tools/packbeam/**' - pull_request: - paths: - - '.github/workflows/esp32-mkimage.yaml' - - 'src/platforms/esp32/**' - - 'src/platforms/esp32/**/**' - - 'src/libAtomVM/**' - -permissions: - contents: write - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - esp32-release: - runs-on: ubuntu-22.04 - container: espressif/idf:v${{ matrix.idf-version }} - - strategy: - matrix: - idf-version: ["5.3.1"] - cc: ["clang-14"] - cxx: ["clang++-14"] - cflags: ["-O3"] - otp: ["27"] - elixir_version: ["1.17"] - compiler_pkgs: ["clang-14"] - soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2"] - flavor: ["", "-elixir"] - - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - CFLAGS: ${{ matrix.cflags }} - CXXFLAGS: ${{ matrix.cflags }} - ImageOS: "ubuntu22" - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.otp }} - elixir-version: ${{ matrix.elixir_version }} - hexpm-mirrors: | - https://builds.hex.pm - https://repo.hex.pm - https://cdn.jsdelivr.net/hex - - - name: "APT update" - run: apt update -y - - - name: "Install deps" - run: DEBIAN_FRONTEND=noninteractive apt install -y ${{ matrix.compiler_pkgs}} git cmake gperf zlib1g-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 - - # Builder info - - name: "System info" - run: | - echo "**uname:**" - uname -a - echo "**libc version:**" - ldd --version - echo "**C Compiler version:**" - $CC --version - $CXX --version - echo "**Linker version:**" - ld --version - echo "**CMake version:**" - cmake --version - echo "**OTP version:**" - cat $(dirname $(which erlc))/../releases/RELEASES || true - - - name: "Build: create build dir" - run: mkdir build - - - name: "Build: run cmake" - working-directory: build - run: | - cmake .. - # git clone will use more recent timestamps than cached beam files - # touch them so we can benefit from the cache and avoid costly beam file rebuild. - find . -name '*.beam' -exec touch {} \; - - - name: "Build erlang and Elixir libs" - working-directory: build/libs - run: | - make - - - name: "Use release defaults" - if: startsWith(github.ref, 'refs/tags/') - shell: bash - working-directory: ./src/platforms/esp32/ - run: | - cp sdkconfig.release-defaults sdkconfig.defaults - - - name: "Build ${{ matrix.soc }}${{ matrix.flavor }} with idf.py" - shell: bash - working-directory: ./src/platforms/esp32/ - run: | - rm -rf build - . $IDF_PATH/export.sh - if [ ! -z "${{ matrix.flavor }}" ] - then - mv partitions${{ matrix.flavor }}.csv partitions.csv - fi - idf.py set-target ${{ matrix.soc }} - idf.py reconfigure - idf.py build - - - name: "Create a ${{ matrix.soc }}${{ matrix.flavor }} image" - working-directory: ./src/platforms/esp32/build - run: | - if [ -z "${{ matrix.flavor }}" ] - then - ./mkimage.sh - else - FLAVOR_SUFFIX=$(echo "${{ matrix.flavor }}" | sed 's/-//g') - BOOT_FILE="build/libs/esp32boot/${FLAVOR_SUFFIX}_esp32boot.avm" - ./mkimage.sh --boot="$BOOT_FILE" - mv atomvm-${{ matrix.soc }}.img atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img - fi - ls -l *.img - - - name: "Upload ${{ matrix.soc }} artifacts" - uses: actions/upload-artifact@v4 - with: - name: atomvm-${{ matrix.soc }}${{ matrix.flavor }}-image - path: ./src/platforms/esp32/build/atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img - if-no-files-found: error - - - name: "Rename and write sha256sum" - if: startsWith(github.ref, 'refs/tags/') - shell: bash - working-directory: src/platforms/esp32/build - run: | - ATOMVM_IMG="AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img" - mv atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img "${ATOMVM_IMG}" - sha256sum "${ATOMVM_IMG}" > "${ATOMVM_IMG}.sha256" - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - src/platforms/esp32/build/AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img - src/platforms/esp32/build/AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img.sha256 diff --git a/.github/workflows/esp32-simtest.yaml b/.github/workflows/esp32-simtest.yaml new file mode 100644 index 000000000..57d9a6b66 --- /dev/null +++ b/.github/workflows/esp32-simtest.yaml @@ -0,0 +1,118 @@ +# +# Copyright 2024 Davide Bettio +# +# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later +# + +name: ESP32 Sim test + +on: + push: + paths: + - ".github/workflows/esp32-simtest.yaml" + - "CMakeLists.txt" + - "libs/**" + - "src/platforms/esp32/**" + - "src/platforms/esp32/**/**" + - "src/libAtomVM/**" + - "tools/packbeam/**" + pull_request: + paths: + - ".github/workflows/esp32-simtest.yaml" + - "src/platforms/esp32/**" + - "src/platforms/esp32/**/**" + - "src/libAtomVM/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + cli_token: + name: WOKWI_CLI_TOKEN presence + runs-on: ubuntu-latest + outputs: + token_check: ${{ steps.token_check.outputs.should-run }} + + steps: + - name: Mark esp-sim-test job as 'to be run' + id: token_check + env: + wokwi_secret: ${{ secrets.WOKWI_CLI_TOKEN }} + run: | + if [${{ env.wokwi_secret }} == '']; + then + echo "WOKWI_CLI_TOKEN not found" + + else + echo "WOKWI_CLI_TOKEN found continuing" + echo "should-run=true" >> $GITHUB_OUTPUT + + fi + esp-sim-test: + needs: cli_token + runs-on: ubuntu-latest + if: needs.cli_token.outputs.token_check == 'true' + container: espressif/idf:${{ matrix.idf-version }} + strategy: + fail-fast: false + # focus on device diversity. + matrix: + esp-idf-target: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6"] + idf-version: ${{ ((contains(github.event.head_commit.message, 'full_sim_test')||contains(github.event.pull_request.title, 'full_sim_test')) && fromJSON('["v5.1.4", "v5.2.3", "v5.3.1"]')) || fromJSON('["v5.3.1"]') }} + include: + - esp-idf-target: "esp32p4" + idf-version: "v5.3.1" + - esp-idf-target: "esp32h2" + idf-version: "v5.3.1" + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install dependencies to build host AtomVM + run: | + set -eu + apt update + DEBIAN_FRONTEND=noninteractive apt install -y -q \ + doxygen erlang-base erlang-dialyzer \ + libglib2.0-0 libpixman-1-0 \ + gcc g++ zlib1g-dev libsdl2-2.0-0 libslirp0 libmbedtls-dev + + - name: Install the Wokwi CLI + run: curl -L https://wokwi.com/ci/install.sh | sh + + - name: Install pytest and pytest-embedded plugins + run: | + set -e + . $IDF_PATH/export.sh + pip install pytest==8.3.3 \ + pytest-embedded==1.11.5 \ + pytest-embedded-idf==1.11.5 \ + pytest-embedded-qemu==1.11.5 \ + pytest-embedded-wokwi==1.11.5 + + - name: "On Esp32 use board with sd card" + if: matrix.esp-idf-target == 'esp32' + shell: bash + working-directory: ./src/platforms/esp32/test/ + run: | + cp diagram.esp32.json diagram.json + + - name: Set SDKCONFIG_DEFAULTS and Build ESP32-sim tests using idf.py + working-directory: ./src/platforms/esp32/test/ + run: | + set -e + . $IDF_PATH/export.sh + idf.py -DSDKCONFIG_DEFAULTS='sdkconfig.ci.wokwi' set-target ${{matrix.esp-idf-target}} + idf.py build + + - name: Run ESP32-sim tests using Wokwi CI + working-directory: ./src/platforms/esp32/test/ + env: + WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }} + timeout-minutes: 10 + run: | + set -e + . $IDF_PATH/export.sh + pytest -k 'test_atomvm_sim' --embedded-services=idf,wokwi --wokwi-timeout=240000 --target=${{ matrix.esp-idf-target }} -s diff --git a/.github/workflows/pico-build.yaml b/.github/workflows/pico-build.yaml deleted file mode 100644 index 0d1fec96b..000000000 --- a/.github/workflows/pico-build.yaml +++ /dev/null @@ -1,124 +0,0 @@ -# -# Copyright 2022 Paul Guyot -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Pico Build - -on: - push: - paths: - - '.github/workflows/pico-build.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/esp32/test/main/test_erl_sources/test_crypto.erl' - - 'src/libAtomVM/**' - pull_request: - paths: - - '.github/workflows/pico-build.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/esp32/test/main/test_erl_sources/test_crypto.erl' - - 'src/libAtomVM/**' - -permissions: - contents: write - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - pico: - runs-on: ubuntu-22.04 - strategy: - matrix: - board: ["pico", "pico_w"] - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: "apt update" - run: sudo apt update - - - name: "Install deps" - run: sudo apt install -y cmake gperf ninja-build gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib erlang-base erlang-dialyzer - - - name: Build - shell: bash - working-directory: ./src/platforms/rp2040/ - run: | - set -euo pipefail - mkdir build - cd build - cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }} - ninja - - - name: Install nvm and nodejs 20 - run: | - set -euo pipefail - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash - source $HOME/.nvm/nvm.sh - nvm install 20 - - - name: Build tests (without SMP) - shell: bash - working-directory: ./src/platforms/rp2040/ - run: | - set -euo pipefail - mkdir build.nosmp - cd build.nosmp - # TODO: fix all warnings and enable -DAVM_WARNINGS_ARE_ERRORS=ON - cmake .. -G Ninja -DPICO_BOARD=${{ matrix.board }} -DAVM_DISABLE_SMP=1 - cmake --build . --target=rp2040_tests - - - name: Run tests with rp2040js - shell: bash - working-directory: ./src/platforms/rp2040/tests - run: | - set -euo pipefail - source $HOME/.nvm/nvm.sh - nvm use node - npm install - npx tsx run-tests.ts ../build.nosmp/tests/rp2040_tests.uf2 ../build.nosmp/tests/test_erl_sources/rp2040_test_modules.uf2 - - - name: Build atomvmlib.uf2 - if: startsWith(github.ref, 'refs/tags/') - shell: bash - run: | - set -euo pipefail - mkdir build - cd build - cmake .. - make atomvmlib.uf2 - - - name: Rename and write sha256sum - if: startsWith(github.ref, 'refs/tags/') - shell: bash - run: | - pushd src/platforms/rp2040/build - ATOMVM_UF2=AtomVM-${{ matrix.board }}-${{ github.ref_name }}.uf2 - mv src/AtomVM.uf2 "src/${ATOMVM_UF2}" - sha256sum "src/${ATOMVM_UF2}" > "src/${ATOMVM_UF2}.sha256" - popd - pushd build/libs - ATOMVMLIB_FILE=atomvmlib-${{ github.ref_name }}.uf2 - mv atomvmlib.uf2 "${ATOMVMLIB_FILE}" - sha256sum "${ATOMVMLIB_FILE}" > "${ATOMVMLIB_FILE}.sha256" - popd - - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - src/platforms/rp2040/build/src/AtomVM-${{ matrix.board }}-${{ github.ref_name }}.uf2 - src/platforms/rp2040/build/src/AtomVM-${{ matrix.board }}-${{ github.ref_name }}.uf2.sha256 - build/libs/atomvmlib-${{ github.ref_name }}.uf2 - build/libs/atomvmlib-${{ github.ref_name }}.uf2.sha256 diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml deleted file mode 100644 index e64a7293a..000000000 --- a/.github/workflows/publish-docs.yaml +++ /dev/null @@ -1,143 +0,0 @@ -# -# Copyright 2023 Winford (Uncle Grumpy) -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# -# This is a workflow for atomvm/AtomVM to Publish API documentation and other content from the `doc` directory to -# atomvm.net hosted on GitHub Pages - -name: Publish Docs - -# Controls when the workflow will run -on: - # Triggers the workflow on pull request, tag events and pushes on main - push: - tags: - - '**' - branches: - - 'main' - - 'release-**' - paths: - - '.github/workflows/publish-docs.yaml' - - 'CMakeLists.txt' - - 'doc/**' - - 'libs/**' - - 'src/libAtomVM/**' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref_name }} - cancel-in-progress: true - -env: - AVM_DOCS_NAME: ${{ github.ref_name }} - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - strategy: - ## don't add more than one OS to matrix, this is only to retrieve the full os-name for keeping cache in sync - matrix: - os: [ ubuntu-24.04 ] - # The type of runner that the job will run on - runs-on: ${{ matrix.os }} - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - - name: Install Deps - run: | - sudo apt update -y - DEBIAN_FRONTEND=noninteractive sudo apt install -y git cmake doxygen graphviz python3-pip python3-virtualenv python3-setuptools python3-stemmer wget - - - uses: actions/cache@v4 - id: sphinx-cache - with: - path: /home/runner/python-env/sphinx - key: ${{ matrix.os }}-sphinx-install - - - name: Install Sphinx - if: ${{ steps.sphinx-cache.outputs.cache-hit != 'true' }} - run: | - python3 -m venv /home/runner/python-env/sphinx - . /home/runner/python-env/sphinx/bin/activate - python3 -m pip install sphinx - python3 -m pip install myst-parser - python3 -m pip install sphinx-rtd-theme - python3 -m pip install rinohtype - python3 -m pip install pillow - python3 -m pip install gitpython - python3 -m pip install breathe - python3 -m pip install pygments - - - uses: erlef/setup-beam@v1 - with: - otp-version: "26" - elixir-version: "1.17" - hexpm-mirrors: | - https://builds.hex.pm - https://repo.hex.pm - https://cdn.jsdelivr.net/hex - - - name: Install rebar3 - working-directory: /tmp - run: | - wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 - ./rebar3 local install - echo "/home/runner/.cache/rebar3/bin" >> ${GITHUB_PATH} - - - uses: actions/checkout@v4 - with: - repository: ${{ vars.GITHUB_REPOSITORY }} - fetch-depth: 0 - - - uses: actions/checkout@v4 - id: checkout-production - with: - repository: atomvm/atomvm_www - ref: Production - path: /home/runner/work/AtomVM/AtomVM/www - - - name: Track all branches - shell: bash - run: | - git config --global --add safe.directory /__w/AtomVM/AtomVM - for branch in `git branch -a | grep "remotes/origin" | grep -v HEAD | grep -v "${{ github.ref_name }}" `; do - git branch --track ${branch#remotes/origin/} $branch - done - - - name: Build Site - shell: bash - run: | - . /home/runner/python-env/sphinx/bin/activate - mkdir build - cd build - cmake .. - cd doc - make GitHub_CI_Publish_Docs - - - name: Commit files - if: github.repository == 'atomvm/AtomVM' - working-directory: /home/runner/work/AtomVM/AtomVM/www - run: | - git checkout Production - git config --local user.email "atomvm-doc-bot@users.noreply.github.com" - git config --local user.name "AtomVM Doc Bot" - git add . - git commit -m "Update Documentation" - - name: Push changes - if: github.repository == 'atomvm/AtomVM' - working-directory: /home/runner/work/AtomVM/AtomVM/www - run: | - eval `ssh-agent -t 60 -s` - echo "${{ secrets.PUBLISH_ACTION_KEY }}" | ssh-add - - mkdir -p ~/.ssh/ - ssh-keyscan github.com >> ~/.ssh/known_hosts - git remote add push_dest "git@github.com:atomvm/atomvm_www.git" - git fetch push_dest - git push --set-upstream push_dest Production - diff --git a/.github/workflows/reuse-lint.yaml b/.github/workflows/reuse-lint.yaml deleted file mode 100644 index ed63ea86a..000000000 --- a/.github/workflows/reuse-lint.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. -# -# SPDX-License-Identifier: CC0-1.0 - -name: REUSE Compliance Check - -on: [push, pull_request] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: REUSE Compliance Check - uses: fsfe/reuse-action@v1 diff --git a/.github/workflows/run-tests-with-beam.yaml b/.github/workflows/run-tests-with-beam.yaml deleted file mode 100644 index b53fabfec..000000000 --- a/.github/workflows/run-tests-with-beam.yaml +++ /dev/null @@ -1,145 +0,0 @@ -# -# Copyright 2022 Paul Guyot -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Run tests with BEAM - -on: - push: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - pull_request: - paths-ignore: - - 'src/platforms/emscripten/**' - - 'src/platforms/esp32/**' - - 'src/platforms/rp2040/**' - - 'src/platforms/stm32/**' - - 'doc/**' - - 'LICENSES/**' - - '*.Md' - - '*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - run-tests: - runs-on: ${{ matrix.os }} - container: ${{ matrix.container }} - strategy: - fail-fast: false - matrix: - include: - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - container: erlang:21 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - container: erlang:22 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - container: erlang:23 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - container: erlang:24 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - container: erlang:25 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - otp: "26" - container: erlang:26 - - - os: "ubuntu-24.04" - test_erlang_opts: "-s prime_smp" - otp: "27" - container: erlang:27 - - # This is ARM64 - - os: "macos-14" - otp: "24" - path_prefix: "/opt/homebrew/opt/erlang@24/bin:" - - - os: "macos-14" - otp: "25" - path_prefix: "/opt/homebrew/opt/erlang@25/bin:" - - - os: "macos-14" - otp: "26" - path_prefix: "/opt/homebrew/opt/erlang@26/bin:" - steps: - # Setup - - name: "Checkout repo" - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: "Install deps (container)" - if: runner.os == 'Linux' - run: | - apt update -y - apt install -y cmake gperf zlib1g-dev ninja-build - - - name: "Install deps (macOS)" - if: runner.os == 'macOS' - run: brew install gperf erlang@${{ matrix.otp }} ninja mbedtls - - # Build - - name: "Build: create build dir" - run: mkdir build - - - uses: actions/cache@v4 - id: cache - with: - path: 'build/tests/**/*.beam' - key: ${{ matrix.otp }}-${{ hashFiles('**/run-tests-with-beam.yaml', 'tests/**/*.erl') }} - - - name: "Build: run cmake" - working-directory: build - run: | - export PATH="${{ matrix.path_prefix }}$PATH" - cmake -G Ninja ${{ matrix.cmake_opts }} .. - - - name: "Touch files to benefit from cache" - working-directory: build - run: | - # git clone will use more recent timestamps than cached beam files - # touch them so we can benefit from the cache and avoid costly beam file rebuild. - find . -name '*.beam' -exec touch {} \; - - - name: "Build: run ninja" - working-directory: build - run: | - export PATH="${{ matrix.path_prefix }}$PATH" - ninja - - # Test - - name: "Test: test-erlang with BEAM" - timeout-minutes: 10 - working-directory: build - run: | - export PATH="${{ matrix.path_prefix }}$PATH" - ./tests/test-erlang -b ${{ matrix.test_erlang_opts }} - - # Test - - name: "Test: estdlib/ with BEAM" - timeout-minutes: 10 - working-directory: build - run: | - export PATH="${{ matrix.path_prefix }}$PATH" - erl -pa tests/libs/estdlib/ -pa tests/libs/estdlib/beams/ -pa libs/etest/src/beams -s tests -s init stop -noshell diff --git a/.github/workflows/stm32-build.yaml b/.github/workflows/stm32-build.yaml deleted file mode 100644 index b33fcccb0..000000000 --- a/.github/workflows/stm32-build.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright 2022 Paul Guyot -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: STM32 Build - -on: - push: - paths: - - '.github/workflows/stm32-build.yaml' - - 'CMakeLists.txt' - - 'src/platforms/stm32/**' - - 'src/libAtomVM/**' - pull_request: - paths: - - '.github/workflows/stm32-build.yaml' - - 'CMakeLists.txt' - - 'src/platforms/stm32/**' - - 'src/libAtomVM/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - stm32: - runs-on: ubuntu-24.04 - steps: - - uses: actions/cache@v4 - id: builddeps-cache - with: - path: | - /home/runner/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi - /home/runner/libopencm3 - key: ${{ runner.os }}-build-deps - - - uses: erlef/setup-beam@v1 - with: - otp-version: "27" - hexpm-mirrors: | - https://builds.hex.pm - https://repo.hex.pm - https://cdn.jsdelivr.net/hex - - - name: Install arm-embedded toolchain - if: ${{ steps.builddeps-cache.outputs.cache-hit != 'true' }} - working-directory: /home/runner - run: | - set -euo pipefail - cd /home/runner - wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz \ - --output-document=$RUNNER_TEMP/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz - tar xJf $RUNNER_TEMP/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz - pwd && ls - - - name: Checkout and build libopencm3 - if: ${{ steps.builddeps-cache.outputs.cache-hit != 'true' }} - working-directory: /home/runner - run: | - set -euo pipefail - cd /home/runner - test -d libopencm3 && rm -fr libopencm3 - export PATH=/home/runner/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin:${PATH} - git clone https://github.com/libopencm3/libopencm3.git -b v0.8.0 - cd libopencm3 - make - - - name: "apt update" - run: sudo apt update - - - name: "Install deps" - run: sudo apt install -y cmake gperf - - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Build - shell: bash - working-directory: ./src/platforms/stm32/ - run: | - set -euo pipefail - export PATH=/home/runner/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin:${PATH} - mkdir build - cd build - # -DAVM_WARNINGS_ARE_ERRORS=ON - cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/arm-toolchain.cmake -DLIBOPENCM3_DIR=/home/runner/libopencm3 - make -j diff --git a/.github/workflows/wasm-build.yaml b/.github/workflows/wasm-build.yaml deleted file mode 100644 index 8de03e7f1..000000000 --- a/.github/workflows/wasm-build.yaml +++ /dev/null @@ -1,248 +0,0 @@ -# -# Copyright 2023 Paul Guyot -# -# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later -# - -name: Wasm Build - -on: - push: - paths: - - '.github/workflows/wasm-build.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/emscripten/**' - - 'src/libAtomVM/**' - pull_request: - paths: - - '.github/workflows/wasm-build.yaml' - - 'CMakeLists.txt' - - 'libs/**' - - 'src/platforms/emscripten/**' - - 'src/libAtomVM/**' - -permissions: - contents: write - -concurrency: - group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - compile_tests: - runs-on: ubuntu-24.04 - container: erlang:27 - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Install required packages - run: apt update && apt install -y gperf zlib1g-dev cmake ninja-build - - - name: Compile AtomVM and test modules - run: | - set -e - mkdir build - cd build - cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON - # test_eavmlib does not work with wasm due to http + ssl test - ninja AtomVM atomvmlib test_alisp hello_world run_script call_cast html5_events wasm_webserver - - - name: Upload AtomVM and test modules - uses: actions/upload-artifact@v4 - with: - name: atomvm-and-test-modules - path: | - build/**/*.avm - build/**/*.beam - build/src/AtomVM - retention-days: 1 - - - name: Compile emscripten test modules - run: | - set -e - cd src/platforms/emscripten - mkdir -p build/tests/src/ - cd build/tests/src - cmake ../../../tests/src -G Ninja - ninja emscripten_erlang_test_modules - - - name: Upload emscripten test modules - uses: actions/upload-artifact@v4 - with: - name: emscripten-test-modules - path: | - src/platforms/emscripten/build/**/*.beam - retention-days: 1 - - wasm_build_and_test_node: - needs: compile_tests - runs-on: ubuntu-latest - container: emscripten/emsdk - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: "Install deps" - run: sudo apt update -y && sudo apt install -y cmake gperf - - - name: Build - shell: bash - working-directory: ./src/platforms/emscripten/ - run: | - set -euo pipefail - mkdir build - cd build - emcmake cmake .. - emmake make -j - - - name: Download AtomVM and test modules - uses: actions/download-artifact@v4 - with: - name: atomvm-and-test-modules - path: build - - - name: Test - shell: bash - working-directory: ./src/platforms/emscripten/build - run: | - set -euxo pipefail - # Test compressed beams - node src/AtomVM.js ../../../../build/examples/erlang/hello_world.beam ../../../../build/libs/eavmlib/src/eavmlib.avm - # Run tests that pass - node src/AtomVM.js ../../../../build/tests/libs/alisp/test_alisp.avm - # test_eavmlib does not work with wasm due to http + ssl test - # node src/AtomVM.js ../../../../build/tests/libs/eavmlib/test_eavmlib.avm - - - name: "Rename and write sha256sum (node)" - if: startsWith(github.ref, 'refs/tags/') - shell: bash - working-directory: src/platforms/emscripten/build/src - run: | - ATOMVM_JS=AtomVM-node-${{ github.ref_name }}.js - mv AtomVM.js "${ATOMVM_JS}" - sha256sum "${ATOMVM_JS}" > "${ATOMVM_JS}.sha256" - ATOMVM_WORKER_JS=AtomVM.worker-node-${{ github.ref_name }}.js - mv AtomVM.worker.js "${ATOMVM_WORKER_JS}" - sha256sum "${ATOMVM_WORKER_JS}" > "${ATOMVM_WORKER_JS}.sha256" - ATOMVM_WASM=AtomVM-node-${{ github.ref_name }}.wasm - mv AtomVM.wasm "${ATOMVM_WASM}" - sha256sum "${ATOMVM_WASM}" > "${ATOMVM_WASM}.sha256" - - - name: "Release (node)" - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.js - src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.js.sha256 - src/platforms/emscripten/build/src/AtomVM.worker-node-${{ github.ref_name }}.js - src/platforms/emscripten/build/src/AtomVM.worker-node-${{ github.ref_name }}.js.sha256 - src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.wasm - src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.wasm.sha256 - - wasm_build_web: - runs-on: ubuntu-latest - container: emscripten/emsdk - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: "Install deps" - run: sudo apt update -y && sudo apt install -y cmake gperf - - - name: Build wasm build for web - shell: bash - working-directory: ./src/platforms/emscripten/ - run: | - set -euo pipefail - mkdir build - cd build - emcmake cmake .. -DAVM_EMSCRIPTEN_ENV=web - emmake make -j - - - name: Upload wasm build for web - uses: actions/upload-artifact@v4 - with: - name: atomvm-js-web - path: | - src/platforms/emscripten/build/**/*.wasm - src/platforms/emscripten/build/**/*.js - retention-days: 1 - - wasm_test_web: - needs: [compile_tests, wasm_build_web] - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Download AtomVM and test modules - uses: actions/download-artifact@v4 - with: - name: atomvm-and-test-modules - path: build - - - name: Download wasm build for web - uses: actions/download-artifact@v4 - with: - name: atomvm-js-web - path: src/platforms/emscripten/build - - - name: Download emscripten test modules - uses: actions/download-artifact@v4 - with: - name: emscripten-test-modules - path: src/platforms/emscripten/build - - - name: Test using cypress - shell: bash - run: | - set -euxo pipefail - cd build - chmod +x ./src/AtomVM - ./src/AtomVM examples/emscripten/wasm_webserver.avm & - cd ../src/platforms/emscripten/tests/ - docker run --network host -v $PWD:/mnt -w /mnt cypress/included:12.17.1 --browser chrome - killall AtomVM - - - name: "Publish screenshots of failures" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: cypress-screenshots - path: | - src/platforms/emscripten/tests/cypress/screenshots/**/*.png - retention-days: 7 - - - name: "Rename and write sha256sum (web)" - if: startsWith(github.ref, 'refs/tags/') - shell: bash - working-directory: src/platforms/emscripten/build/src - run: | - ATOMVM_JS=AtomVM-web-${{ github.ref_name }}.js - mv AtomVM.js "${ATOMVM_JS}" - sha256sum "${ATOMVM_JS}" > "${ATOMVM_JS}.sha256" - ATOMVM_WORKER_JS=AtomVM.worker-web-${{ github.ref_name }}.js - mv AtomVM.worker.js "${ATOMVM_WORKER_JS}" - sha256sum "${ATOMVM_WORKER_JS}" > "${ATOMVM_WORKER_JS}.sha256" - ATOMVM_WASM=AtomVM-web-${{ github.ref_name }}.wasm - mv AtomVM.wasm "${ATOMVM_WASM}" - sha256sum "${ATOMVM_WASM}" > "${ATOMVM_WASM}.sha256" - - - name: "Release (web)" - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - fail_on_unmatched_files: true - files: | - src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.js - src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.js.sha256 - src/platforms/emscripten/build/src/AtomVM.worker-web-${{ github.ref_name }}.js - src/platforms/emscripten/build/src/AtomVM.worker-web-${{ github.ref_name }}.js.sha256 - src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.wasm - src/platforms/emscripten/build/src/AtomVM-web-${{ github.ref_name }}.wasm.sha256 diff --git a/src/platforms/esp32/test/CMakeLists.txt b/src/platforms/esp32/test/CMakeLists.txt index 14a2221f8..fa67dd77c 100644 --- a/src/platforms/esp32/test/CMakeLists.txt +++ b/src/platforms/esp32/test/CMakeLists.txt @@ -37,12 +37,10 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") # mkfifo is defined in newlib header but not implemented -set(HAVE_MKFIFO NO) set(HAVE_MKFIFO "" CACHE INTERNAL "Have symbol mkfifo" FORCE) # Force HAVE_SOCKET # Automatically detecting it requires to put too many components include dirs # in CMAKE_REQUIRED_INCLUDES as lwip includes freetos and many esp system components -set(HAVE_SOCKET ON) set(HAVE_SOCKET 1 CACHE INTERNAL "Have symbol socket" FORCE) # Disable SMP with esp32 socs that have only one core @@ -65,4 +63,4 @@ if (-std=gnu99 IN_LIST c_compile_options ) list(REMOVE_ITEM c_compile_options -std=gnu99) list(APPEND c_compile_options -std=gnu11) idf_build_set_property(C_COMPILE_OPTIONS ${c_compile_options}) -endif() +endif() \ No newline at end of file diff --git a/src/platforms/esp32/test/README.md b/src/platforms/esp32/test/README.md new file mode 100644 index 000000000..59c541381 --- /dev/null +++ b/src/platforms/esp32/test/README.md @@ -0,0 +1,81 @@ + + +# AtomVM emulator/simulator tests + +AtomVM provides two paths for testing "on device", the locally run QEMU emulator or the remote Wokwi CI simulator. + +# QEMU emulator testing + +Instructions for running the tests [on QEMU are documented here](https://www.atomvm.net/doc/main/build-instructions.html#running-tests-for-esp32). + +# Wokwi CI simulator testing + +Wokwi CI is a commercial cloud CI, see [wokwi-ci/getting-started](https://docs.wokwi.com/wokwi-ci/getting-started), running it locally requires you to obtain a `WOKWI_CLI_TOKEN` and usage fees may apply in the future - AtomVM uses it through the [pytest-embedded-wokwi](https://github.com/espressif/pytest-embedded/tree/main/pytest-embedded-wokwi) integration. + +## Github CI/Actions + +The `WOKWI_CLI_TOKEN` needs to be set in your `Repository secrets` Settings -> Actions secrets and variables. + +## Installing prerequisites + +1. The Wokwi CLI needs to be installed: + + ```shell + curl -L https://wokwi.com/ci/install.sh | sh + ``` + + Or [alternative installation methods here](https://docs.wokwi.com/wokwi-ci/getting-started#cli-installation). + +2. `WOKWI_CLI_TOKEN` needs to be set in your enviroment variables: + + ```shell + export WOKWI_CLI_TOKEN="your-api-key" + ``` + +3. A recent pytest, and pytest-embedded must be installed: + + ```shell + $ pip install pytest==8.2.2 \ + pytest-embedded==1.10.3 \ + pytest-embedded-serial-esp==1.10.3 \ + pytest-embedded-idf==1.10.3 \ + pytest-embedded-wokwi==1.10.3 + ``` + +4. The ESP-IDF build environment must be installed and available: + + ```shell + $ get_idf + ``` + +## Compiling for and running Wokwi CI + +1. We need to use a special sdkconfig (`sdkconfig.ci.wokwi`) different from the QEMU one. So we set `IDF_TARGET`, and run `idf.py -DSDKCONFIG_DEFAULTS=sdkconfig.ci.wokwi set-target ${IDF_TARGET}`: + ```shell + $ export IDF_TARGET=esp32 && idf.py -DSDKCONFIG_DEFAULTS=sdkconfig.ci.wokwi set-target ${IDF_TARGET} + ``` +2. Wokwi CI uses a `diagram.json`, to describe the device used (specific board, pin connections, sensors, sd card etc). When changing `IDF_TARGET`, we need to delete it, as it will otherwise mismatch: + + ```shell + # only when changing IDF_TARGET + $ rm diagram.json + ``` + + _NB!_ - on the `esp32` target, the SD card tests are enabled, so we need to use a special diagram.json, where a SD card is wired up: + + ```shell + # when using esp32 target + $ cp diagram.esp32.json diagram.json + ``` + + For all other targets we run without diagram.json. + +3. Now we run `idf.py build` and run the CI: + + ```shell + $ idf.py build -DSDKCONFIG_DEFAULTS='sdkconfig.ci.wokwi' && pytest -k 'test_atomvm_sim' --embedded-services=idf,wokwi --wokwi-timeout=90000 --target=${IDF_TARGET} -s -W ignore::DeprecationWarning + ``` diff --git a/src/platforms/esp32/test/diagram.esp32.json b/src/platforms/esp32/test/diagram.esp32.json new file mode 100644 index 000000000..f2845de2a --- /dev/null +++ b/src/platforms/esp32/test/diagram.esp32.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "author": "peter", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-devkit-c-v4", + "id": "esp", + "top": 0, + "left": 0, + "attrs": { "cpuFrequency": "80" } + }, + { + "type": "wokwi-microsd-card", + "id": "sd1", + "top": 0, + "left": 140, + "attrs": {} + } + ], + "connections": [ + ["esp:TX", "$serialMonitor:RX", "", []], + ["esp:RX", "$serialMonitor:TX", "", []], + ["sd1:CS", "esp:5", "blue", ["h38.4", "v48.29", "h-134.37"]], + ["sd1:VCC", "esp:3V3", "red", ["h76.8", "v182.77", "h-312.73", "v-201.6"]], + ["sd1:GND", "esp:GND.2", "black", ["h67.2", "v-76.46", "h-183.17"]], + ["sd1:SCK", "esp:18", "yellow", ["h57.6", "v67.19", "h-120.73", "v0.23"]], + ["sd1:DO", "esp:19", "green", ["h9.6", "v-38.29", "h-101.53", "v115.43"]], + ["sd1:DI", "esp:23", "magenta", ["h38.4", "v-96.09", "h-139.93", "v77.03"]] + ], + "dependencies": {} +} diff --git a/src/platforms/esp32/test/diagram.esp32.json.license b/src/platforms/esp32/test/diagram.esp32.json.license new file mode 100644 index 000000000..b805ab2ca --- /dev/null +++ b/src/platforms/esp32/test/diagram.esp32.json.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: AtomVM Contributors diff --git a/src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt b/src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt index 72de3ddac..fe93ae418 100644 --- a/src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt +++ b/src/platforms/esp32/test/main/test_erl_sources/CMakeLists.txt @@ -39,6 +39,7 @@ endfunction() compile_erlang(test_esp_partition) compile_erlang(test_file) +compile_erlang(test_wifi_example) compile_erlang(test_list_to_binary) compile_erlang(test_md5) compile_erlang(test_crypto) @@ -59,6 +60,7 @@ add_custom_command( HostAtomVM-prefix/src/HostAtomVM-build/libs/atomvmlib.avm test_esp_partition.beam test_file.beam + test_wifi_example.beam test_list_to_binary.beam test_md5.beam test_crypto.beam @@ -75,6 +77,7 @@ add_custom_command( DEPENDS HostAtomVM "${CMAKE_CURRENT_BINARY_DIR}/test_esp_partition.beam" + "${CMAKE_CURRENT_BINARY_DIR}/test_wifi_example.beam" "${CMAKE_CURRENT_BINARY_DIR}/test_file.beam" "${CMAKE_CURRENT_BINARY_DIR}/test_list_to_binary.beam" "${CMAKE_CURRENT_BINARY_DIR}/test_md5.beam" diff --git a/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl b/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl new file mode 100644 index 000000000..44500e589 --- /dev/null +++ b/src/platforms/esp32/test/main/test_erl_sources/test_wifi_example.erl @@ -0,0 +1,114 @@ +% +% This file is part of AtomVM. +% +% Copyright 2020 Fred Dushin +% +% Licensed under the Apache License, Version 2.0 (the "License"); +% you may not use this file except in compliance with the License. +% You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +% See the License for the specific language governing permissions and +% limitations under the License. +% +% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later +% + +-module(test_wifi_example). + +-export([start/0]). + +start() -> + case verify_platform(atomvm:platform()) of + ok -> + start_network(), + loop(0); + Error -> + Error + end. + +start_network() -> + Config = [ + {ap, [ + {ap_started, fun ap_started/0}, + {sta_connected, fun sta_connected/1}, + {sta_ip_assigned, fun sta_ip_assigned/1}, + {sta_disconnected, fun sta_disconnected/1} + | [] + ]}, + {sta, [ + {connected, fun connected/0}, + {got_ip, fun got_ip/1}, + {disconnected, fun disconnected/0} + | [ + {dhcp_hostname, "my_device_name"}, + {ssid, "Wokwi-GUEST"}, + {psk, ""} + ] + ]}, + {sntp, [ + {host, "time.aws.com"}, + {synchronized, fun sntp_synchronized/1} + ]} + ], + case network:start(Config) of + {ok, _Pid} -> + io:format("Network started.~n"); + Error -> + Error + end. + +ap_started() -> + io:format("AP started.~n"). + +sta_connected(Mac) -> + io:format("STA connected with mac ~p~n", [Mac]). + +sta_disconnected(Mac) -> + io:format("STA disconnected with mac ~p~n", [Mac]). + +sta_ip_assigned(Address) -> + io:format("STA assigned address ~p~n", [Address]). + +connected() -> + io:format("STA connected.~n"). + +got_ip(IpInfo) -> + io:format("Got IP: ~p.~n", [IpInfo]). + +disconnected() -> + io:format("STA disconnected.~n"). + +sntp_synchronized({TVSec, TVUsec}) -> + io:format("Synchronized time with SNTP server. TVSec=~p TVUsec=~p~n", [TVSec, TVUsec]). + +verify_platform(esp32) -> + ok; +verify_platform(Platform) -> + {error, {unsupported_platform, Platform}}. + +loop(Count) when Count =:= 40 -> + io:format("Never got SNTP.~n"), + tests(), + network:stop(); +loop(Count) -> + timer:sleep(500), + {{Year, Month, Day}, {Hour, Minute, Second}} = erlang:universaltime(), + io:format("Date: ~p/~p/~p ~p:~p:~p (~pms)~n", [ + Year, Month, Day, Hour, Minute, Second, erlang:system_time(millisecond) + ]), + case Year of + 1970 -> + loop(Count + 1); + _ -> + io:format("Got SNTP.~n"), + tests(), + network:stop() + end. +tests() -> + ok = test_net:start(), + io:format("test_net OK.~n"). diff --git a/src/platforms/esp32/test/main/test_main.c b/src/platforms/esp32/test/main/test_main.c index 509f948c7..e88f5e9c5 100644 --- a/src/platforms/esp32/test/main/test_main.c +++ b/src/platforms/esp32/test/main/test_main.c @@ -65,6 +65,8 @@ TEST_CASE("atomvm_missing_0", "[platform_nifs]") TEST_ASSERT(nif == NULL); } +// Configure OPEN_ETH usage for QEMU targets. +#if CONFIG_ETH_USE_OPENETH // Derived from: // https://github.com/espressif/esp-idf/blob/release/v4.4/examples/common_components/protocol_examples_common/connect.c @@ -122,6 +124,7 @@ static void eth_stop(esp_netif_t *eth_netif) esp_netif_destroy(eth_netif); } +#endif term avm_test_case(const char *test_module) { @@ -177,8 +180,9 @@ TEST_CASE("test_esp_partition", "[test_run]") TEST_ASSERT(term_to_int(ret_value) == 0); } -// qemu SDMMC works all esp-idf versions for esp32 - still no support c3. -#if !CONFIG_IDF_TARGET_ESP32C3 +// SDMMC SDMMC works all esp-idf versions for esp32 - still no support c3. +// only run in QEMU (eg. OPENETH configured) +#if !CONFIG_IDF_TARGET_ESP32C3 && CONFIG_ETH_USE_OPENETH TEST_CASE("test_file", "[test_run]") { esp_vfs_fat_sdmmc_mount_config_t mount_config = { @@ -218,6 +222,74 @@ TEST_CASE("test_file", "[test_run]") } #endif +// SPI SD CARD, requires: cp diagram.esp32.json diagram.json +// To wire up sd card to simulator +#if (!CONFIG_ETH_USE_OPENETH && CONFIG_IDF_TARGET_ESP32) +TEST_CASE("test_file", "[test_run]") +{ + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = true, + .max_files = 5, + .allocation_unit_size = 16 * 1024 + }; + sdmmc_card_t *card; + const char mount_point[] = "/sdcard"; + ESP_LOGI(TAG, "Initializing SD card"); + + ESP_LOGI(TAG, "Using SDSPI peripheral"); + // By default, SD card frequency is initialized to SDMMC_FREQ_DEFAULT (20MHz) + // For setting a specific frequency, use host.max_freq_khz (range 400kHz - 40MHz for SDMMC) + // Example: for fixed frequency of 10MHz, use host.max_freq_khz = 10000; + sdmmc_host_t host = SDSPI_HOST_DEFAULT(); + + // This initializes the slot without card detect (CD) and write protect (WP) signals. + // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals. + sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); + + ESP_LOGI(TAG, "Mounting filesystem"); + +#if SOC_SPI_PERIPH_NUM > 2 + host.slot = SPI3_HOST; +#elif SOC_SPI_PERIPH_NUM <= 2 + host.slot = SPI2_HOST; +#else + host.slot = SPI2_HOST; +#endif + + spi_bus_config_t bus_cfg = { + .mosi_io_num = 23, + .miso_io_num = 19, + .sclk_io_num = 18, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + .max_transfer_sz = 4000 + }; + esp_err_t ret2 = spi_bus_initialize(host.slot, &bus_cfg, SDSPI_DEFAULT_DMA); + if (ret2 != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize bus."); + return; + } + + // This initializes the slot without card detect (CD) and write protect (WP) signals. + // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals. + slot_config.gpio_cs = 5; + slot_config.host_id = host.slot; + + ESP_LOGI(TAG, "Mounting filesystem"); + esp_err_t ret = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card); + + TEST_ASSERT(ret == ESP_OK); + + sdmmc_card_print_info(stdout, card); + + term ret_value = avm_test_case("test_file.beam"); + TEST_ASSERT(ret_value == OK_ATOM); + + esp_vfs_fat_sdcard_unmount(mount_point, card); + ESP_LOGI(TAG, "Card unmounted"); +} +#endif + TEST_CASE("test_list_to_binary", "[test_run]") { term ret_value = avm_test_case("test_list_to_binary.beam"); @@ -230,11 +302,14 @@ TEST_CASE("test_md5", "[test_run]") TEST_ASSERT(ret_value == OK_ATOM); } +// Full crypto suite not yet supported on ESP32-P4 simulator. +#if !CONFIG_IDF_TARGET_ESP32P4 TEST_CASE("test_crypto", "[test_run]") { term ret_value = avm_test_case("test_crypto.beam"); TEST_ASSERT(ret_value == OK_ATOM); } +#endif TEST_CASE("test_monotonic_time", "[test_run]") { @@ -242,7 +317,7 @@ TEST_CASE("test_monotonic_time", "[test_run]") TEST_ASSERT(ret_value == OK_ATOM); } -#if !CONFIG_IDF_TARGET_ESP32C3 +#if !CONFIG_IDF_TARGET_ESP32C3 && CONFIG_ETH_USE_OPENETH // this test is failing on v5.0.7 due to some kind of problem with atomvm:posix_open #if ESP_IDF_VERSION_MAJOR >= 5 && ESP_IDF_VERSION_MINOR >= 1 TEST_CASE("test_mount", "[test_run]") @@ -432,6 +507,7 @@ TEST_CASE("atomvm_smp_0", "[smp]") } #endif +#if CONFIG_ETH_USE_OPENETH static volatile bool network_got_ip = false; static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) @@ -502,6 +578,7 @@ TEST_CASE("test_ssl", "[test_run]") TEST_ASSERT(ret_value == OK_ATOM); } +#endif TEST_CASE("test_rtc_slow", "[test_run]") { @@ -509,8 +586,17 @@ TEST_CASE("test_rtc_slow", "[test_run]") TEST_ASSERT(term_to_int(ret_value) == 0); } +// Only test wifi on simulator, not on QEMU +#if !CONFIG_ETH_USE_OPENETH && !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32P4 +TEST_CASE("test_wifi_example", "[test_run]") +{ + term ret_value = avm_test_case("test_wifi_example.beam"); + TEST_ASSERT(ret_value == OK_ATOM); +} +#endif + // Works C3 on local runs, but fails GH actions -#if ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_IDF_TARGET_ESP32C3 +#if (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_IDF_TARGET_ESP32C3) || (ESP_IDF_VERSION_MAJOR >= 5 && !CONFIG_ETH_USE_OPENETH) TEST_CASE("test_twdt", "[test_run]") { term ret_value = avm_test_case("test_twdt.beam"); diff --git a/src/platforms/esp32/test/sdkconfig.ci.wokwi b/src/platforms/esp32/test/sdkconfig.ci.wokwi new file mode 100644 index 000000000..c91728191 --- /dev/null +++ b/src/platforms/esp32/test/sdkconfig.ci.wokwi @@ -0,0 +1,7 @@ +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=10000 +CONFIG_AVM_RTC_SLOW_MAX_SIZE=1024 +CONFIG_ETH_USE_OPENETH=n +CONFIG_COMPILER_OPTIMIZATION_PERF=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y \ No newline at end of file diff --git a/src/platforms/esp32/test/sdkconfig.ci.wokwi.license b/src/platforms/esp32/test/sdkconfig.ci.wokwi.license new file mode 100644 index 000000000..b805ab2ca --- /dev/null +++ b/src/platforms/esp32/test/sdkconfig.ci.wokwi.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: AtomVM Contributors diff --git a/src/platforms/esp32/test/test_atomvm.py b/src/platforms/esp32/test/test_atomvm.py index e480100e0..42d8f6f2b 100644 --- a/src/platforms/esp32/test/test_atomvm.py +++ b/src/platforms/esp32/test/test_atomvm.py @@ -52,3 +52,10 @@ def test_atomvm(dut, redirect): assert len(dut.testsuite.testcases) > 0 assert dut.testsuite.attrs['failures'] == 0 assert dut.testsuite.attrs['errors'] == 0 + +# These tests are run on sim tests +def test_atomvm_sim(dut, redirect): + dut.expect_unity_test_output(timeout=230) + assert len(dut.testsuite.testcases) > 0 + assert dut.testsuite.attrs['failures'] == 0 + assert dut.testsuite.attrs['errors'] == 0 diff --git a/src/platforms/esp32/test/wokwi.toml b/src/platforms/esp32/test/wokwi.toml new file mode 100644 index 000000000..a0a34b29c --- /dev/null +++ b/src/platforms/esp32/test/wokwi.toml @@ -0,0 +1,5 @@ +[wokwi] +version = 1 +generatedBy = "pytest-embedded-wokwi 1.8.1" +firmware = "build/flasher_args.json" +elf = "build/atomvm-esp32-test.elf" diff --git a/src/platforms/esp32/test/wokwi.toml.license b/src/platforms/esp32/test/wokwi.toml.license new file mode 100644 index 000000000..b805ab2ca --- /dev/null +++ b/src/platforms/esp32/test/wokwi.toml.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: Apache-2.0 +SPDX-FileCopyrightText: AtomVM Contributors