Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel 5.0 fixes #25

Merged
merged 12 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG IDF_VERSION=4.4
ARG IMAGE=ghcr.io/embeddednim/esp-idf:${IDF_VERSION}-latest

FROM $IMAGE AS build

ARG IDF_VERSION=4.4

COPY . /app/

WORKDIR /app/
RUN nimble develop -y

RUN : \
&& nimble test
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "esp-idf",
"image": "ghcr.io/embeddednim/esp-idf:4.4-latest",
"remoteUser": "root",
"postCreateCommand": "git config --global --add safe.directory '*' && sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --skip-chsh\" ",
// "postStartCommand": "",
"customizations": {
"vscode": {
"extensions": [
"nimsaem.nimvscode",
"twxs.cmake",
"ms-vscode.cpptools"
]
},
"settings": {
"terminal.integrated.profiles.linux": {
"zsh login": {
"path": "/bin/zsh",
"args": ["-l"],
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.linux": "zsh login"
}
}
}
17 changes: 17 additions & 0 deletions .devcontainer/idf-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo "IDF ENV"

export IDF_PATH="${IDF_PATH}"

# Call idf_tools.py to export tool paths
export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
export IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh
# Allow calling some IDF python tools without specifying the full path
# ${IDF_PATH}/tools is already added by 'idf_tools.py export'
IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool"
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/espcoredump"
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table"
IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/app_update"

idf_exports=$("$ESP_PYTHON" "${IDF_PATH}/tools/idf_tools.py" export "--add_paths_extras=${IDF_ADD_PATHS_EXTRAS}") || return 1
eval "${idf_exports}"
export PATH="${IDF_ADD_PATHS_EXTRAS}:${PATH}"
151 changes: 151 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian-11
# FROM espressif/idf:release-v4.0

ARG DEBIAN_FRONTEND=noninteractive

RUN : \
&& sudo apt-get update \
&& sudo apt-get install -y \
apt-utils \
bison \
ca-certificates \
ccache \
check \
curl \
flex \
git \
git-lfs \
gperf \
lcov \
libbsd-dev \
libffi-dev \
libncurses-dev \
libusb-1.0-0-dev \
make \
ninja-build \
python3 \
python3-venv \
python3-pip \
ruby \
unzip \
wget \
xz-utils \
zip \
&& sudo apt-get autoremove -y \
&& sudo rm -rf /var/lib/apt/lists/* \
&& sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \
&& :

# To build the image for a branch or a tag of IDF, pass --build-arg IDF_CLONE_BRANCH_OR_TAG=name.
# To build the image with a specific commit ID of IDF, pass --build-arg IDF_CHECKOUT_REF=commit-id.
# It is possibe to combine both, e.g.:
# IDF_CLONE_BRANCH_OR_TAG=release/vX.Y
# IDF_CHECKOUT_REF=<some commit on release/vX.Y branch>.
# Use IDF_CLONE_SHALLOW=1 to peform shallow clone (i.e. --depth=1 --shallow-submodules)
# Use IDF_INSTALL_TARGETS to install tools only for selected chip targets (CSV)

ARG IDF_CLONE_URL=https://github.com/espressif/esp-idf.git
ARG IDF_CLONE_BRANCH_OR_TAG=master
ARG IDF_CHECKOUT_REF=
ARG IDF_CLONE_SHALLOW=
ARG IDF_INSTALL_TARGETS=all

ENV IDF_PATH=/opt/esp/idf
ENV IDF_TOOLS_PATH=/opt/esp

RUN echo IDF_CHECKOUT_REF=$IDF_CHECKOUT_REF IDF_CLONE_BRANCH_OR_TAG=$IDF_CLONE_BRANCH_OR_TAG && \
git clone --recursive \
${IDF_CLONE_SHALLOW:+--depth=1 --shallow-submodules} \
${IDF_CLONE_BRANCH_OR_TAG:+-b $IDF_CLONE_BRANCH_OR_TAG} \
$IDF_CLONE_URL $IDF_PATH && \
if [ -n "$IDF_CHECKOUT_REF" ]; then \
cd $IDF_PATH && \
if [ -n "$IDF_CLONE_SHALLOW" ]; then \
git fetch origin --depth=1 --recurse-submodules ${IDF_CHECKOUT_REF}; \
fi && \
git checkout $IDF_CHECKOUT_REF && \
git submodule update --init --recursive; \
fi

# Install all the required tools
RUN : \
&& update-ca-certificates --fresh \
&& $IDF_PATH/tools/idf_tools.py --non-interactive install required \
&& $IDF_PATH/tools/idf_tools.py --non-interactive install cmake \
&& $IDF_PATH/tools/idf_tools.py --non-interactive install-python-env \
&& rm -rf $IDF_TOOLS_PATH/dist \
&& :

# The constraint file has been downloaded and the right Python package versions installed. No need to check and
# download this at every invocation of the container.
ENV IDF_PYTHON_CHECK_CONSTRAINTS=no

# Ccache is installed, enable it by default
# ENV IDF_CCACHE_ENABLE=1

# Install QEMU runtime dependencies
RUN : \
&& apt-get update && apt-get install -y -q \
libglib2.0-0 \
libpixman-1-0 \
&& rm -rf /var/lib/apt/lists/* \
&& :


# Install QEMU
ARG QEMU_VER=esp-develop-20220919
ARG QEMU_DIST=qemu-${QEMU_VER}.tar.bz2
ARG QEMU_SHA256=f6565d3f0d1e463a63a7f81aec94cce62df662bd42fc7606de4b4418ed55f870
RUN : \
&& wget --no-verbose https://github.com/espressif/qemu/releases/download/${QEMU_VER}/${QEMU_DIST} \
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \
&& tar -xf ${QEMU_DIST} -C /opt \
&& rm ${QEMU_DIST} \
&& :
ENV PATH=/opt/qemu/bin:${PATH}

# Call idf_tools.py to export tool paths
ENV IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
ENV IDF_TOOLS_INSTALL_CMD=${IDF_PATH}/install.sh
# Allow calling some IDF python tools without specifying the full path
# ${IDF_PATH}/tools is already added by 'idf_tools.py export'
ENV IDF_ADD_PATHS_EXTRAS="${IDF_PATH}/components/esptool_py/esptool"
ENV IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/espcoredump"
ENV IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/partition_table"
ENV IDF_ADD_PATHS_EXTRAS="${IDF_ADD_PATHS_EXTRAS}:${IDF_PATH}/components/app_update"

RUN : \
&& echo 'source /opt/esp/idf/export.sh' >> /etc/bash.bashrc \
&& echo 'source /opt/esp/idf/export.sh' >> /etc/zsh/zshrc

USER vscode

RUN : \
&& printf '[safe]\n directory = /opt/esp/idf\n' >> /home/vscode/.gitconfig


ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG BUILDPLATFORM
ARG BUILDOS
ARG BUILDARCH

# COPY idf-env.sh /etc/profile.d/idf-env.sh
RUN : \
&& cd $HOME/ \
&& case ${TARGETARCH} in \
"arm64") TARCH=arm64 ;; \
"amd64") TARCH=x64 ;; \
"arm") TARCH=arm ;; \
"386") TARCH=x32 ;; \
*) TARCH=${TARGETARCH} ;; \
esac \
&& env \
&& NIM_PLATFORM=${TARGETOS}_${TARCH} \
&& wget https://github.com/nim-lang/nightlies/releases/download/latest-version-1-6/${NIM_PLATFORM}.tar.xz \
&& tar xf ${NIM_PLATFORM}.tar.xz \
&& sudo mv nim-* /usr/local/ \
&& for b in atlas nim nimble nim_dbg nim-gdb nimgrep nimpretty nimsuggest testament; \
do sudo ln -sf /usr/local/nim-*/bin/$b /usr/local/bin/; \
done
81 changes: 81 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '26 20 * * 1'
push:
branches: [ "container-*" ]
# Publish semver tags as releases.
# tags: [ 'v*.*.*' ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
file: .devcontainer/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}

72 changes: 59 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
on: [push]

name: Build Firmware

on:
push:
branches:
- "*"
tags:
- "v*"

env:
REPO: ghcr.io/elcritch/nesper

jobs:
build:
runs-on: ubuntu-latest
build: !test
runs-on: ubuntu-22.04

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Start docker
run: docker run -itd -e IDF_TARGET=esp32 -v "${GITHUB_WORKSPACE}:/nesper" --name container espressif/idf:v4.4
- name: Install nim
run: docker exec container bash -c "curl https://nim-lang.org/choosenim/init.sh -sSf | sh -s -- -y"
- name: Install nesper
run: docker exec container bash -c 'cd /nesper && PATH=/root/.nimble/bin:$PATH nimble install -y'
- name: I2S example
run: docker exec -w /nesper/esp-idf-examples/i2s container bash -c '. /opt/esp/idf/export.sh && PATH=/root/.nimble/bin:$PATH nimble esp_build'

- name: Env
run: env

- uses: actions/checkout@v3
with:
submodules: recursive

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Extract metadata (tags, labels) for Docker
- name: Set Tag
run: |
VERSION=$(cat esp32_sensor_router.nimble | grep version | awk '{print $3}' | tr -d '"')
DATE=$(date --iso-8601)
RTAG=$(cat .git/HEAD | tr '/' ' ' | cut -d ' ' -f 4)

ITAG=$REPO:$RTAG-$DATE
ITAG=$ITAG,$REPO:version-$VERSION
ITAG=$ITAG,$REPO:ref-$GITHUB_SHA
echo "ITAG=$ITAG" >> $GITHUB_ENV

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: .devcontainer/Dockerfile.build
push: false
platforms: linux/amd64
tags: ${{ env.ITAG }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}
4 changes: 0 additions & 4 deletions docker/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions docker/build_docker.sh

This file was deleted.

4 changes: 0 additions & 4 deletions docker/run_shell.sh

This file was deleted.

Loading
Loading