mirror of
https://github.com/emqx/neuron.git
synced 2026-10-18 13:41:22 +08:00
177 lines
4.4 KiB
YAML
177 lines
4.4 KiB
YAML
name: EMQX Neuron dev workflow
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
clang_format_check:
|
|
runs-on: ubuntu-18.04
|
|
|
|
steps:
|
|
# checkout
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Run clang-format style check for C/C++ programs.
|
|
uses: DoozyX/clang-format-lint-action@v0.12
|
|
with:
|
|
source: 'src plugins include tests'
|
|
exclude: 'include/vector.h'
|
|
clangFormatVersion: 10
|
|
style: file
|
|
|
|
test_neuron:
|
|
runs-on: ubuntu-18.04
|
|
|
|
container: ghcr.io/${{ github.repository }}/base:latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Start neuron
|
|
run: |
|
|
mkdir -p build
|
|
cd build
|
|
cmake .. && make
|
|
|
|
- name: Run unit test
|
|
run: |
|
|
mkdir -p build
|
|
cd build
|
|
ctest --output-on-failure
|
|
|
|
- name: Run function test
|
|
run: |
|
|
mosquitto -v &
|
|
python3 -m pip install -U pip
|
|
python3 -m pip install -r ft/requirements.txt
|
|
python3 -m robot -P ft/ --variable neuron_api:http -d ft/http_reports ft
|
|
python3 -m robot -P ft/ --variable neuron_api:mqtt -d ft/mqtt_reports ft
|
|
|
|
#- uses: actions/upload-artifact@v2
|
|
#with:
|
|
#name: ft-http-output
|
|
#path: "ft/http_reports/output.xml"
|
|
|
|
#- uses: actions/upload-artifact@v2
|
|
#with:
|
|
#name: ft-http-log
|
|
#path: "ft/http_reports/log.html"
|
|
|
|
#- uses: actions/upload-artifact@v2
|
|
#with:
|
|
#name: ft-http-report
|
|
#path: "ft/http_reports/report.html"
|
|
|
|
compile:
|
|
strategy:
|
|
matrix:
|
|
arch:
|
|
- "arm-linux-gnueabihf"
|
|
- "aarch64-linux-gnu"
|
|
- "x86_64-linux-gnu"
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
container: ghcr.io/${{ github.repository }}/base:latest
|
|
|
|
steps:
|
|
# checkout
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Compile
|
|
run: |
|
|
mkdir -p build
|
|
cd build
|
|
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/${{ matrix.arch }}.cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_UT=ON
|
|
make
|
|
|
|
- name: Create package
|
|
env:
|
|
ARCH: ${{ matrix.arch }}
|
|
run: |
|
|
./package.sh -p ${ARCH} -n neuron-${GITHUB_REF##*/}-${ARCH%%-*}
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ matrix.arch }}
|
|
path: "*.tar.gz"
|
|
|
|
run_neuron:
|
|
needs: compile
|
|
strategy:
|
|
matrix:
|
|
arch:
|
|
- "arm-linux-gnueabihf"
|
|
- "aarch64-linux-gnu"
|
|
- "x86_64-linux-gnu"
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@v2
|
|
id: download
|
|
with:
|
|
name: ${{ matrix.arch }}
|
|
|
|
- id: package
|
|
env:
|
|
ARCH: ${{ matrix.arch }}
|
|
run: echo "::set-output name=name::neuron-${GITHUB_REF##*/}-${ARCH%%-*}.tar.gz"
|
|
|
|
- uses: docker/setup-buildx-action@v1
|
|
- uses: docker/setup-qemu-action@v1
|
|
with:
|
|
image: tonistiigi/binfmt:latest
|
|
platforms: all
|
|
|
|
- name: Run neuron
|
|
run: |
|
|
case ${{ matrix.arch }} in
|
|
"arm-linux-gnueabihf")
|
|
platform="linux/arm/v7"
|
|
;;
|
|
"aarch64-linux-gnu")
|
|
platform="linux/arm64"
|
|
;;
|
|
"x86_64-linux-gnu")
|
|
platform="linux/amd64"
|
|
;;
|
|
esac
|
|
docker run -d --name neuron \
|
|
-v $(pwd)/${{ steps.package.outputs.name }}:/opt/neuron.tar.gz \
|
|
-p 7001:7001 \
|
|
--platform ${platform} \
|
|
ubuntu:18.04 \
|
|
bash -c "tar -zxvf neuron.tar.gz -C /opt && cd /opt/neuron && ./neuron"
|
|
|
|
- name: Check status
|
|
timeout-minutes: 1
|
|
run: |
|
|
if ! curl --silent --show-error -X POST http://127.0.0.1:7001/api/v2/ping > /dev/null; then
|
|
sleep 1
|
|
fi
|
|
|
|
- uses: actions/upload-release-asset@v1
|
|
if: github.event_name == 'release'
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: ./${{ steps.package.outputs.name}}
|
|
asset_name: ${{ steps.package.outputs.name}}
|
|
asset_content_type: application/octet-stream
|
|
|
|
- uses: geekyeggo/delete-artifact@v1
|
|
with:
|
|
name: ${{ matrix.arch }}
|