Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into change-splash
Browse files Browse the repository at this point in the history
  • Loading branch information
felixerdy committed Dec 20, 2024
2 parents 0a579ca + 92c7682 commit 67395c1
Show file tree
Hide file tree
Showing 19 changed files with 1,384 additions and 492 deletions.
1 change: 1 addition & 0 deletions .github/workflows/registry-build-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b
with:
context: .
target: production
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
46 changes: 46 additions & 0 deletions .github/workflows/release-arduino-lib-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Update Release Body with Arduino Libraries

on:
release:
types: [published]

jobs:
update-release-body:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

- name: Install jq
run: sudo apt-get install jq

- name: Build docker container
run: docker build -t sketches --no-cache .

# Generate the libraries list
- name: Generate libraries list
id: generate_libraries_list
run: docker run sketches arduino-cli lib list --all > libraries.txt

# Update the release body
- name: Update Release Body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch the release details
RELEASE_URL=$(jq -r '.release.url' "${GITHUB_EVENT_PATH}")
RELEASE_BODY=$(jq -r '.release.body' "${GITHUB_EVENT_PATH}")
LIBRARIES_FILE=$(cat libraries.txt)
# Append the generated text with a heading and escape special characters
NEW_BODY=$(echo -e "${RELEASE_BODY}\n\n## Libraries\n\n\`\`\`\n${LIBRARIES_FILE}\n\`\`\`" | jq -Rs .)
# Update the release body using GitHub API
curl -X PATCH \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"${RELEASE_URL}" \
-d "{\"body\":${NEW_BODY}}"
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ name: Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
# Triggers the workflow on pull request events but only for the main branch
pull_request:
branches: [main]

Expand All @@ -26,7 +24,13 @@ jobs:
- uses: actions/checkout@v2

- name: Build docker test container
run: docker build -t sketches-test -f Dockerfile.test --no-cache .
run: docker build -t sketches-test --target test --no-cache .

- name: Run docker test container
run: docker run sketches-test
run: docker run -v ${{ github.workspace }}/ctrf:/app/ctrf sketches-test

- name: Run CTRF annotations
run: npx github-actions-ctrf pull-request ctrf/ctrf-report.json
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
yarn-error.log
*.bin
*.hex

ctrf
90 changes: 40 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
FROM node:17

ENV ARDUINO_CLI_VERSION=0.35.3 \
SENSEBOXCORE_VERSION=2.0.0 \
ARDUINO_SAMD_VERSION=1.8.13 \
ARDUINO_AVR_VERSION=1.8.5 \
ESP32_VERSION=2.0.17 \
SENSEBOXCORE_URL=https://raw.githubusercontent.com/mariopesch/senseBoxMCU-core/master/package_sensebox_index.json \
ESP32CORE_URL=https://espressif.github.io/arduino-esp32/package_esp32_index.json \
SSD1306_PLOT_LIBRARY_URL=https://github.com/sensebox/SSD1306-Plot-Library/archive/refs/tags/v1.1.0.zip \
SENSEBOX_LIBWEB_URL=https://github.com/sensebox/sensebox-libweb/archive/refs/heads/master.zip \
SDS011_LIBRARY_URL=https://github.com/sensebox/SDS011-select-serial/archive/refs/heads/master.zip \
RTC_LIBRARY_URL=https://github.com/sensebox/RV8523-RTC-Arduino-Library/archive/refs/heads/main.zip \
BMX055_LIBRARY_URL=https://github.com/sensebox/BMX055-Arduino-Library/archive/refs/heads/main.zip \
LTR329_LIBRARY_URL=https://github.com/sensebox/LTR329-Lightsensor-Arduino-Library/archive/refs/heads/main.zip \
SDS011S_LIBRARY_URL=https://github.com/sensebox/SDS011-select-serial/archive/refs/heads/master.zip \
VEML6070_LIBRARY_URL=https://github.com/sensebox/VEML6070-UV-Arduino-Library/archive/refs/heads/main.zip \
AMS5915_LIBRARY_URL=https://github.com/bolderflight/ams5915/archive/refs/heads/main.zip

RUN apt-get update && apt-get install -y xz-utils unzip wget

RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh -s ${ARDUINO_CLI_VERSION}
FROM node:22-alpine AS base

ENV ARDUINO_CLI_VERSION=1.1.0
ENV SENSEBOXCORE_VERSION=2.0.0
ENV ARDUINO_SAMD_VERSION=1.8.13
ENV ARDUINO_AVR_VERSION=1.8.5
ENV ESP32_VERSION=2.0.17
ENV SENSEBOXCORE_URL=https://raw.githubusercontent.com/mariopesch/senseBoxMCU-core/master/package_sensebox_index.json
ENV ESP32CORE_URL=https://espressif.github.io/arduino-esp32/package_esp32_index.json

RUN apk update
RUN apk add curl
RUN apk add libc6-compat
RUN apk add bash
RUN apk add python3
RUN apk add py3-pyserial

RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION}

RUN arduino-cli config init

# aloow unsafe sources (zip, git)
# allow unsafe sources (zip, git)
RUN arduino-cli config set library.enable_unsafe_install true

# update arduino-cli
Expand All @@ -38,31 +34,9 @@ RUN curl -o /root/.arduino15/package_sensebox_index.json ${SENSEBOXCORE_URL}
RUN arduino-cli --additional-urls ${SENSEBOXCORE_URL} core install sensebox:samd

# install ESP32
RUN apt-get install -y python3-pip
RUN pip install pyserial
RUN curl -o /root/.arduino15/package_esp32_index.json ${ESP32CORE_URL}
RUN arduino-cli --additional-urls ${ESP32CORE_URL} core install esp32:esp32@${ESP32_VERSION}


RUN wget -O ssd1306_plot_library.zip $SSD1306_PLOT_LIBRARY_URL \
&& arduino-cli lib install --zip-path ssd1306_plot_library.zip \
&& wget -O sensebox_libweb.zip $SENSEBOX_LIBWEB_URL \
&& arduino-cli lib install --zip-path sensebox_libweb.zip \
&& wget -O sds011-select-serial.zip $SDS011_LIBRARY_URL \
&& arduino-cli lib install --zip-path sds011-select-serial.zip \
&& wget -O rtc_library.zip $RTC_LIBRARY_URL \
&& arduino-cli lib install --zip-path rtc_library.zip \
&& wget -O bmx055_library.zip $BMX055_LIBRARY_URL \
&& arduino-cli lib install --zip-path bmx055_library.zip \
&& wget -O ltr329_library.zip $LTR329_LIBRARY_URL \
&& arduino-cli lib install --zip-path ltr329_library.zip \
&& wget -O sds011_select_library.zip $SDS011S_LIBRARY_URL \
&& arduino-cli lib install --zip-path sds011_select_library.zip \
&& wget -O veml6070_library.zip $VEML6070_LIBRARY_URL \
&& arduino-cli lib install --zip-path veml6070_library.zip \
&& wget -O ams5915_library.zip $AMS5915_LIBRARY_URL \
&& arduino-cli lib install --zip-path ams5915_library.zip

# install Libraries with arduino-cli
RUN arduino-cli lib install "Ethernet"
RUN arduino-cli lib install "ArduinoJson"
Expand Down Expand Up @@ -109,20 +83,36 @@ RUN arduino-cli lib install "NeoGPS"
RUN arduino-cli lib install "Adafruit NeoMatrix"
RUN arduino-cli lib install "Arduino Low Power"
RUN arduino-cli lib install "Adafruit seesaw Library"

RUN arduino-cli lib install --git-url https://github.com/sensebox/SSD1306-Plot-Library
RUN arduino-cli lib install --git-url https://github.com/sensebox/sensebox-libweb
RUN arduino-cli lib install --git-url https://github.com/sensebox/SDS011-select-serial
RUN arduino-cli lib install --git-url https://github.com/sensebox/RV8523-RTC-Arduino-Library
RUN arduino-cli lib install --git-url https://github.com/sensebox/BMX055-Arduino-Library
RUN arduino-cli lib install --git-url https://github.com/sensebox/LTR329-Lightsensor-Arduino-Library
RUN arduino-cli lib install --git-url https://github.com/sensebox/VEML6070-UV-Arduino-Library
RUN arduino-cli lib install --git-url https://github.com/bolderflight/ams5915

WORKDIR /app

ENV NODE_ENV=production

COPY package.json /app
COPY yarn.lock /app

RUN yarn install --pure-lockfile --production
# test stage
FROM base AS test
ENV NODE_ENV=test
RUN yarn install --pure-lockfile
COPY src /app/src
COPY test /app/test
COPY mocha-reporters.json /app
CMD ["yarn","test"]

# production stage
FROM base AS production
ENV NODE_ENV=production
RUN yarn install --pure-lockfile --production
COPY src /app/src
COPY splash.h ../root/Arduino/libraries/Adafruit_SSD1306/splash.h

# COPY platform.txt /app/src/arduino-ide/packages/arduino/hardware/samd/1.8.11

CMD ["yarn","start"]
CMD ["yarn","start"]
120 changes: 0 additions & 120 deletions Dockerfile.test

This file was deleted.

3 changes: 3 additions & 0 deletions mocha-reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"reporterEnabled": "spec, mocha-ctrf-json-reporter"
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"scripts": {
"start": "node src/index.js",
"test": "mocha --exit --timeout 20000"
"test": "mocha --exit --timeout 60000 --reporter mocha-multi-reporters --reporter-options configFile=mocha-reporters.json"
},
"dependencies": {
"body-parser": "^1.18.2",
Expand All @@ -20,6 +20,8 @@
"devDependencies": {
"chai": "^4.2.0",
"chai-http": "^4.2.0",
"mocha": "^5.2.0"
"mocha": "^5.2.0",
"mocha-ctrf-json-reporter": "^0.0.6",
"mocha-multi-reporters": "^1.5.1"
}
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const errorHandler = function errorHandler (err, req, res, next) {
};

const startServer = function startServer () {
app.use(morgan(':date[iso] :res[x-backend-server] :remote-addr :req[x-real-ip] :method :url :response-time[0] :status'));
app.use(morgan(':date[iso] :res[x-backend-server] :remote-addr :req[x-real-ip] :method :url :response-time[0] :status', { skip: (req, res) => process.env.NODE_ENV === 'test' }));
app.use(responseTime());
app.use(preflight);
app.use(preRequestValidator);
Expand Down
Loading

0 comments on commit 67395c1

Please sign in to comment.