Files
neuron/.github/workflows/ci.yml
T
2022-04-07 08:44:04 +00:00

298 lines
8.9 KiB
YAML

name: EMQX neuron dev
on:
push:
pull_request:
release:
types:
- published
jobs:
clang_format_check:
runs-on: ubuntu-20.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/neuron/vector.h include/neuron/utils/uthash.h include/neuron/utils/utarray.h'
clangFormatVersion: 10
style: file
cross-build:
runs-on: ubuntu-20.04
strategy:
matrix:
arch:
- [aarch64-linux-gnu, aarch64, gcc-aarch64-linux-gnu, g++-aarch64-linux-gnu, /opt/externs/libs, arm64]
- [arm-linux-gnueabihf, armv4, gcc-arm-linux-gnueabihf, g++-arm-linux-gnueabihf, /opt/externs/libs, armhf]
- [x86_64-linux-gnu, x86_64, gcc, g++, /usr/local, amd64]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.arch[2] }} ${{ matrix.arch[3] }} pkg-config alien
- name: install dep
run: |
./install.sh -d ${{ matrix.arch[4] }} -c ${{ matrix.arch[0] }} -a ${{ matrix.arch[1] }}
- name: compile
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/${{ matrix.arch[0] }}.cmake \
-DCMAKE_BUILD_TYPE=Release -DDISABLE_UT=ON
make -j4
- name: get version
id: get_version
run: echo "::set-output name=version::$(cat version)"
- name: Create neuron package
env:
ARCH: ${{ matrix.arch[5] }}
run: |
./package.sh -p ${ARCH} -n neuron-${{ steps.get_version.outputs.version }}
cd package
python3 create_neuron_deb.py ${{ steps.get_version.outputs.version }} ${{ matrix.arch[5] }}
sudo alien --scripts -k -r *.deb
mv *.rpm neuron-${{ steps.get_version.outputs.version }}-${{ matrix.arch[5] }}.rpm
mv *.rpm ../
mv *.deb ../
- uses: actions/upload-artifact@v3
with:
name: neuron-${{ matrix.arch[5] }}
path: |
*.tar.gz
*.deb
*.rpm
- name: Create neuron sdk package
run: |
./package-sdk.sh -p ${{ matrix.arch[5] }} -n neuron-sdk-${{ steps.get_version.outputs.version }}
cd package
python3 create_neuron_sdk_deb.py ${{ steps.get_version.outputs.version }} ${{ matrix.arch[5] }}
sudo alien --scripts -k -r *.deb
mv *.rpm neuron-sdk-${{ steps.get_version.outputs.version }}-${{ matrix.arch[5] }}.rpm
mv *.rpm ../
mv *.deb ../
- uses: actions/upload-artifact@v3
with:
name: neuron-sdk-${{ matrix.arch[5] }}
path: |
neuron-sdk-*.tar.gz
neuron-sdk-*.deb
neuron-sdk-*.rpm
ut:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install dep
run: |
./install.sh -d /usr/local -a x86_64 -c x86_64-linux-gnu
- name: compile
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-linux-gnu.cmake
make -j4
- name: unit test
run: |
cd build
ctest --output-on-failure
http_ft:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install dep
run: |
./install.sh -d /usr/local -a x86_64 -c x86_64-linux-gnu
- name: compile
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-linux-gnu.cmake
make -j4
- name: function test
run: |
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
mqtt_ft:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install dep
run: |
./install.sh -d /usr/local -a x86_64 -c x86_64-linux-gnu
- name: compile
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-linux-gnu.cmake
make -j4
- name: function test
run: |
sudo apt-get install -y mosquitto
mosquitto -v &
python3 -m pip install -U pip
python3 -m pip install -r ft/requirements.txt
python3 -m robot -P ft/ --variable neuron_api:mqtt -d ft/http_reports ft/modbus_tcp_test.robot
create_daily_release:
runs-on: ubuntu-20.04
if: github.event_name == 'push'
needs: cross-build
steps:
- name: delete old daily-pre-release
uses: dev-drprasad/delete-tag-and-release@v0.2.0
with:
delete_release: true
tag_name: daily
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create daily-pre-release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: daily
release_name: Daily Release
draft: false
prerelease: true
- shell: bash
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- uses: actions/upload-artifact@v3
with:
name: release_url
path: release_url.txt
upload_daily_release_asset:
runs-on: ubuntu-20.04
if: github.event_name == 'push'
needs: create_daily_release
strategy:
matrix:
arch: [arm64, armhf, amd64]
type: [neuron, neuron-sdk]
package: [tar.gz, deb, rpm]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: get version
id: get_version
run: echo "::set-output name=version::$(cat version)"
- uses: actions/download-artifact@v2
with:
name: release_url
- id: release_url
run: |
value=`cat release_url.txt`
echo "::set-output name=name::$value"
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.type }}-${{ matrix.arch }}
- id: package
run: echo "::set-output name=name::${{ matrix.type }}-${{ steps.get_version.outputs.version }}-${{ matrix.arch }}.${{ matrix.package }}"
- name: upload daily release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_url.outputs.name }}
asset_path: ./${{ steps.package.outputs.name }}
asset_name: ${{ matrix.type }}-${{ steps.get_version.outputs.version }}-daily-linux-${{ matrix.arch }}.${{ matrix.package }}
asset_content_type: application/octet-stream
release:
runs-on: ubuntu-20.04
if: github.event_name == 'release'
needs: cross-build
strategy:
matrix:
arch: [arm64, armhf, amd64]
type: [neuron]
package: [tar.gz, deb, rpm]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: get version
id: get_version
run: echo "::set-output name=version::$(cat version)"
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.type }}-${{ matrix.arch }}
- id: package
run: echo "::set-output name=name::${{ matrix.type }}-${{ steps.get_version.outputs.version }}-${{ matrix.arch }}.${{ matrix.package }}"
- name: gen packages sha256
run: sudo bash -c "echo $(sha256sum ./${{ steps.package.outputs.name }} | awk '{print $1}') > ./${{ steps.package.outputs.name }}.sha256"
- 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}}.sha256
asset_name: ${{ matrix.type }}-${{ steps.get_version.outputs.version }}-linux-${{ matrix.arch }}.${{ matrix.package }}.sha256
asset_content_type: application/octet-stream
- 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: ${{ matrix.type }}-${{ steps.get_version.outputs.version }}-linux-${{ matrix.arch }}.${{ matrix.package }}
asset_content_type: application/octet-stream