ci: optimize ci workflow

This commit is contained in:
fengzero
2022-03-07 03:19:56 +00:00
parent 56d65d0a58
commit 6bbfcd47a9
7 changed files with 279 additions and 95 deletions
+170
View File
@@ -0,0 +1,170 @@
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/vector.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]
- [arm-linux-gnueabihf, armv4, gcc-arm-linux-gnueabihf, g++-arm-linux-gnueabihf, /opt/externs/libs]
- [x86_64-linux-gnu, x86_64, gcc, g++, /usr/local]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: install
run: sudo apt-get install -y ${{ matrix.arch[2] }} ${{ matrix.arch[3] }} ninja-build pkg-config
- 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: Create package
env:
ARCH: ${{ matrix.arch[0] }}
run: |
./package.sh -p ${ARCH} -n neuron-${GITHUB_REF##*/}-${ARCH%%-*}
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.arch[0] }}
path: "*.tar.gz"
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
release:
runs-on: ubuntu-20.04
if: github.event_name == 'release'
needs: cross-build
strategy:
matrix:
arch:
- "arm-linux-gnueabihf"
- "aarch64-linux-gnu"
- "x86_64-linux-gnu"
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: 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