Skip to content

Commit

Permalink
Deploy b109780 to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Deploy from CI committed Jun 29, 2024
0 parents commit 13c1b84
Show file tree
Hide file tree
Showing 81 changed files with 38,479 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Base image
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

# Arguments
ARG CONTAINER_USER=esp
ARG CONTAINER_GROUP=esp
ARG NIGHTLY_VERSION=nightly-2023-11-14
ARG ESP_IDF_VERSION=v5.1.2
ARG ESP_BOARD=esp32c3

# Install dependencies
RUN apt-get update \
&& apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv \
cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \
llvm-dev libclang-dev clang pkg-config unzip libusb-1.0-0 \
libpython3-all-dev python3-virtualenv curl \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/library-scripts

# Set users
RUN adduser --disabled-password --gecos "" ${CONTAINER_USER}
USER ${CONTAINER_USER}
WORKDIR /home/${CONTAINER_USER}

# Install rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
--default-toolchain ${NIGHTLY_VERSION} -y --profile minimal \
--component rust-src,clippy,rustfmt

# Update envs
ENV PATH=${PATH}:$HOME/.cargo/bin

# Install extra crates
RUN ARCH=$($HOME/.cargo/bin/rustup show | grep "Default host" | sed -e 's/.* //') && \
curl -L "https://github.com/esp-rs/espflash/releases/latest/download/cargo-espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/cargo-espflash.zip" && \
unzip "${HOME}/.cargo/bin/cargo-espflash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/cargo-espflash.zip" && \
chmod u+x "${HOME}/.cargo/bin/cargo-espflash" && \
curl -L "https://github.com/esp-rs/espflash/releases/latest/download/espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/espflash.zip" && \
unzip "${HOME}/.cargo/bin/espflash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/espflash.zip" && \
chmod u+x "${HOME}/.cargo/bin/espflash" && \
curl -L "https://github.com/esp-rs/esp-web-flash-server/releases/latest/download/web-flash-${ARCH}.zip" -o "${HOME}/.cargo/bin/web-flash.zip" && \
unzip "${HOME}/.cargo/bin/web-flash.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/web-flash.zip" && \
chmod u+x "${HOME}/.cargo/bin/web-flash" && \
curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-${ARCH}.zip" -o "${HOME}/.cargo/bin/ldproxy.zip" && \
unzip "${HOME}/.cargo/bin/ldproxy.zip" -d "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/ldproxy.zip" && \
chmod u+x "${HOME}/.cargo/bin/ldproxy" && \
GENERATE_VERSION=$(git ls-remote --refs --sort="version:refname" --tags "https://github.com/cargo-generate/cargo-generate" | cut -d/ -f3- | tail -n1) && \
GENERATE_URL="https://github.com/cargo-generate/cargo-generate/releases/latest/download/cargo-generate-${GENERATE_VERSION}-${ARCH}.tar.gz" && \
curl -L "${GENERATE_URL}" -o "${HOME}/.cargo/bin/cargo-generate.tar.gz" && \
tar xf "${HOME}/.cargo/bin/cargo-generate.tar.gz" -C "${HOME}/.cargo/bin/" && \
rm "${HOME}/.cargo/bin/cargo-generate.tar.gz" && \
chmod u+x "${HOME}/.cargo/bin/cargo-generate"

# Install esp-idf
RUN mkdir -p ${HOME}/.espressif/frameworks/ \
&& git clone --branch ${ESP_IDF_VERSION} -q --depth 1 --shallow-submodules \
--recursive https://github.com/espressif/esp-idf.git \
${HOME}/.espressif/frameworks/esp-idf \
&& python3 ${HOME}/.espressif/frameworks/esp-idf/tools/idf_tools.py install cmake \
&& ${HOME}/.espressif/frameworks/esp-idf/install.sh ${ESP_BOARD} \
&& rm -rf .espressif/dist \
&& rm -rf .espressif/frameworks/esp-idf/docs \
&& rm -rf .espressif/frameworks/esp-idf/examples \
&& rm -rf .espressif/frameworks/esp-idf/tools/esp_app_trace \
&& rm -rf .espressif/frameworks/esp-idf/tools/test_idf_size

# Activate ESP environment
ENV IDF_TOOLS_PATH=${HOME}/.espressif
RUN echo "source ${HOME}/.espressif/frameworks/esp-idf/export.sh > /dev/null 2>&1" >> ~/.bashrc

CMD "/bin/bash"
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "espressif-training",
// Comment the image and use the build property to build the image from the
// Dockerfile instead of downloading it from https://hub.docker.com/r/espressif/rust-std-training
"image": "docker.io/espressif/rust-std-training",
// "build": {
// "dockerfile": "Dockerfile",
// "args": {
// "NIGHTLY_VERSION": "nightly-2023-11-14"
// }
// },
"customizations": {
"vscode": {
"settings": {
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.formatOnType": true,
"lldb.executable": "/usr/bin/lldb",
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
},
"extensions": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"vadimcn.vscode-lldb",
"serayuzgur.crates",
"mutantdino.resourcemonitor",
"yzhang.markdown-all-in-one",
"Wokwi.wokwi-vscode"
]
}
},
"remoteUser": "esp",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace"
}
50 changes: 50 additions & 0 deletions .devcontainer/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

set -ef

echo "Compiling $1"

cd /home/esp/workspace/$1

if [ -f cfg.toml.example ]; then
# Rename file to cfg.toml
cp cfg.toml.example cfg.toml
# Replace defaults
sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml
sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml
sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml
sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml
sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml
fi

$HOME/.cargo/bin/cargo clean
$HOME/.cargo/bin/cargo build

# Check examples
if [[ "$1" == advanced/button-interrupt ]]; then
$HOME/.cargo/bin/cargo build --example solution
$HOME/.cargo/bin/cargo build --example solution_led
# Simulate with Wokwi
sed -i 's/^[[:space:]]*firmware[[:space:]]*=[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']\([[:space:]]*\)$/\nfirmware = "target\/riscv32imc-esp-espidf\/debug\/examples\/solution"/' wokwi.toml
fi

if [[ "$1" == advanced/i2c-sensor-reading ]]; then
$HOME/.cargo/bin/cargo build --example part_1
$HOME/.cargo/bin/cargo build --example part_2
fi

if [[ "$1" == intro/http-client ]]; then
$HOME/.cargo/bin/cargo build --example http_client
$HOME/.cargo/bin/cargo build --example https_client
# Simulate with Wokwi
sed -i 's/^[[:space:]]*firmware[[:space:]]*=[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']\([[:space:]]*\)$/\nfirmware = "target\/riscv32imc-esp-espidf\/debug\/examples\/http_client"/' wokwi.toml
fi

if [[ "$1" == intro/http-server ]]; then
$HOME/.cargo/bin/cargo build --example http_server
fi

if [[ "$1" == intro/mqtt/exercise ]]; then
$HOME/.cargo/bin/cargo build --example solution_publ_rcv
$HOME/.cargo/bin/cargo build --example solution_publ
fi
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Deploy GitHub Pages
run: |
# This assumes your book is in the root of your repository.
# Just add a `cd` here if you need to change to another directory.
cd book
mdbook build
git worktree add gh-pages
git config user.name "Deploy from CI"
git config user.email ""
cd gh-pages
# Delete the ref to avoid keeping history.
git update-ref -d refs/heads/gh-pages
rm -rf *
mv ../book/* .
git add .
git commit -m "Deploy $GITHUB_SHA to gh-pages"
git push --force --set-upstream origin gh-pages
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode
.idea
target
Cargo.lock
cfg.toml
__pycache__
.DS_Store
.embuild/
.vale
.vale.ini
components_esp32c3.lock
Loading

0 comments on commit 13c1b84

Please sign in to comment.