mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 01:05:21 +03:00
Merge pull request #5558 from iNavFlight/agh_github_ci_pr_only
[CI] CI updates
This commit is contained in:
commit
aabbadb1ee
4 changed files with 67 additions and 87 deletions
119
.github/workflows/ci.yml
vendored
119
.github/workflows/ci.yml
vendored
|
@ -1,33 +1,11 @@
|
|||
name: Build firmware
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- master
|
||||
- development
|
||||
pull_request:
|
||||
# Don't enable CI on push, just on PR. If you
|
||||
# are working on the main repo and want to trigger
|
||||
# a CI build submit a draft PR.
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
# This downloads the GNU toolchain from ARM once, then
|
||||
# saves it as an artifact for the remaining jobs, making
|
||||
# the download way faster.
|
||||
download-toolchain:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Prepare ARM toolchain environment
|
||||
run: |
|
||||
echo "::set-env name=ARM_SDK_FILENAME::$(make arm_sdk_print_filename)"
|
||||
echo "::set-env name=ARM_SDK_DOWNLOAD_PATH::$(make arm_sdk_print_download_path)"
|
||||
- name: Download ARM toolchain
|
||||
run: make arm_sdk_download
|
||||
- name: Save toolchain as artifact
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: ${{ env.ARM_SDK_FILENAME }}
|
||||
path: ${{ env.ARM_SDK_DOWNLOAD_PATH }}
|
||||
|
||||
build:
|
||||
needs: download-toolchain
|
||||
runs-on: ubuntu-18.04
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -35,58 +13,55 @@ jobs:
|
|||
count: [10]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup environment
|
||||
run: |
|
||||
echo "::set-env name=TARGETS::$(./src/utils/build-targets.sh -n -s ${{ matrix.start }} -c ${{ matrix.count }})"
|
||||
echo "::set-env name=BUILD_SUFFIX::ci-$(git rev-parse --short ${{ github.ref }})"
|
||||
echo "::set-env name=IS_LAST_JOB::$([ $(expr ${{ strategy.job-index }} + 1) = ${{ strategy.job-total }} ] && echo yes)"
|
||||
- name: Ensure all targets will be tested
|
||||
if: ${{ env.IS_LAST_JOB }}
|
||||
run: |
|
||||
UNTESTED=$(./src/utils/build-targets.sh -n -s $(expr ${{ matrix.start }} + ${{ matrix.count }}) -c 10000)
|
||||
if ! [ -z "${UNTESTED}" ]; then
|
||||
echo "Untested targets: ${UNTESTED}" >&2
|
||||
exit 1
|
||||
fi
|
||||
- name: Prepare ARM toolchain environment
|
||||
if: ${{ env.TARGETS }}
|
||||
run: |
|
||||
echo "::set-env name=ARM_SDK_FILENAME::$(make arm_sdk_print_filename)"
|
||||
echo "::set-env name=ARM_SDK_DOWNLOAD_DIR::$(dirname $(make arm_sdk_print_download_path))"
|
||||
- name: Download ARM toolchain
|
||||
if: ${{ env.TARGETS }}
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: ${{ env.ARM_SDK_FILENAME }}
|
||||
path: ${{ env.ARM_SDK_DOWNLOAD_DIR }}
|
||||
- name: Install ARM toolchain
|
||||
if: ${{ env.TARGETS }}
|
||||
run: make arm_sdk_install
|
||||
- name: Build targets (${{ matrix.start }})
|
||||
if: ${{ env.TARGETS }}
|
||||
run: ./src/utils/build-targets.sh -s ${{ matrix.start }} -c ${{ matrix.count }} -S ${{ env.BUILD_SUFFIX }}
|
||||
- name: Upload artifacts
|
||||
if: ${{ env.TARGETS }}
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: inav-${{ env.BUILD_SUFFIX }}.zip
|
||||
path: ./obj/*.hex
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup environment
|
||||
run: |
|
||||
# This is the hash of the commit for the PR
|
||||
# when the action is triggered by PR, empty otherwise
|
||||
COMMIT_ID=${{ github.event.pull_request.head.sha }}
|
||||
# This is the hash of the commit when triggered by push
|
||||
# but the hash of refs/pull/<n>/merge, which is different
|
||||
# from the hash of the latest commit in the PR, that's
|
||||
# why we try github.event.pull_request.head.sha first
|
||||
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
|
||||
BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
|
||||
echo "::set-env name=TARGETS::$(./src/utils/build-targets.sh -n -s ${{ matrix.start }} -c ${{ matrix.count }})"
|
||||
echo "::set-env name=BUILD_SUFFIX::${BUILD_SUFFIX}"
|
||||
echo "::set-env name=BUILD_NAME::inav-$(make print_version)-${BUILD_SUFFIX}"
|
||||
echo "::set-env name=IS_LAST_JOB::$([ $(expr ${{ strategy.job-index }} + 1) = ${{ strategy.job-total }} ] && echo yes)"
|
||||
- name: Ensure all targets will be tested
|
||||
if: ${{ env.IS_LAST_JOB }}
|
||||
run: |
|
||||
UNTESTED=$(./src/utils/build-targets.sh -n -s $(expr ${{ matrix.start }} + ${{ matrix.count }}) -c 10000)
|
||||
if ! [ -z "${UNTESTED}" ]; then
|
||||
echo "Untested targets: ${UNTESTED}" >&2
|
||||
exit 1
|
||||
fi
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: downloads
|
||||
key: ${{ runner.os }}-downloads-${{ hashFiles('Makefile') }}-${{ hashFiles('**/make/*.mk')}}
|
||||
- name: Install ARM toolchain
|
||||
run: make arm_sdk_install
|
||||
- name: Build targets (${{ matrix.start }})
|
||||
if: ${{ env.TARGETS }}
|
||||
run: ./src/utils/build-targets.sh -s ${{ matrix.start }} -c ${{ matrix.count }} -S ${{ env.BUILD_SUFFIX }}
|
||||
- name: Upload artifacts
|
||||
if: ${{ env.TARGETS }}
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: ${{ env.BUILD_NAME }}.zip
|
||||
path: ./obj/*.hex
|
||||
|
||||
test:
|
||||
needs: [download-toolchain, build]
|
||||
needs: [build]
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Prepare ARM toolchain environment
|
||||
run: |
|
||||
echo "::set-env name=ARM_SDK_FILENAME::$(make arm_sdk_print_filename)"
|
||||
echo "::set-env name=ARM_SDK_DOWNLOAD_DIR::$(dirname $(make arm_sdk_print_download_path))"
|
||||
- name: Download ARM toolchain
|
||||
uses: actions/download-artifact@v1
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
name: ${{ env.ARM_SDK_FILENAME }}
|
||||
path: ${{ env.ARM_SDK_DOWNLOAD_DIR }}
|
||||
path: downloads
|
||||
key: ${{ runner.os }}-downloads-${{ hashFiles('Makefile') }}-${{ hashFiles('**/make/*.mk')}}
|
||||
- name: Install ARM toolchain
|
||||
run: make arm_sdk_install
|
||||
- name: Run Tests
|
||||
|
|
15
Makefile
15
Makefile
|
@ -64,8 +64,6 @@ endif
|
|||
# Things that need to be maintained as the source changes
|
||||
#
|
||||
|
||||
FORKNAME = inav
|
||||
|
||||
# Working directories
|
||||
SRC_DIR := $(ROOT)/src/main
|
||||
OBJECT_DIR := $(ROOT)/obj/main
|
||||
|
@ -85,17 +83,9 @@ MHZ_VALUE ?=
|
|||
# used for turning on features like VCP and SDCARD
|
||||
FEATURES =
|
||||
|
||||
include $(ROOT)/make/version.mk
|
||||
include $(ROOT)/make/targets.mk
|
||||
|
||||
REVISION = $(shell git rev-parse --short HEAD)
|
||||
|
||||
FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
|
||||
FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
|
||||
FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
|
||||
|
||||
FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
|
||||
FC_VER_SUFFIX ?=
|
||||
|
||||
BUILD_DATE = $(shell date +%Y%m%d)
|
||||
|
||||
# Search path for sources
|
||||
|
@ -255,9 +245,6 @@ CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
|
|||
# Things we will build
|
||||
#
|
||||
TARGET_BIN := $(BIN_DIR)/$(FORKNAME)_$(FC_VER)
|
||||
ifneq ($(FC_VER_SUFFIX),)
|
||||
TARGET_BIN := $(TARGET_BIN)-$(FC_VER_SUFFIX)
|
||||
endif
|
||||
TARGET_BIN := $(TARGET_BIN)_$(TARGET)
|
||||
ifneq ($(BUILD_SUFFIX),)
|
||||
TARGET_BIN := $(TARGET_BIN)_$(BUILD_SUFFIX)
|
||||
|
|
|
@ -80,7 +80,7 @@ arm_sdk_clean:
|
|||
|
||||
ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists)
|
||||
ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi-
|
||||
else ifeq (,$(filter targets,$(MAKECMDGOALS))$(findstring arm_sdk,$(MAKECMDGOALS)))
|
||||
else ifeq (,$(findstring print_,$(MAKECMDGOALS))$(filter targets,$(MAKECMDGOALS))$(findstring arm_sdk,$(MAKECMDGOALS)))
|
||||
GCC_VERSION = $(shell arm-none-eabi-gcc -dumpversion)
|
||||
ifeq ($(GCC_VERSION),)
|
||||
$(error **ERROR** arm-none-eabi-gcc not in the PATH. Run 'make arm_sdk_install' to install automatically in the tools folder of this repo)
|
||||
|
|
18
make/version.mk
Normal file
18
make/version.mk
Normal file
|
@ -0,0 +1,18 @@
|
|||
FORKNAME := inav
|
||||
|
||||
FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
|
||||
FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
|
||||
FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
|
||||
FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
|
||||
|
||||
FC_VER_SUFFIX ?=
|
||||
ifneq ($(FC_VER_SUFFIX),)
|
||||
FC_VER += -$(FC_VER_SUFFIX)
|
||||
endif
|
||||
|
||||
REVISION := $(shell git rev-parse --short HEAD)
|
||||
|
||||
.PHONY: print_version
|
||||
|
||||
print_version:
|
||||
@echo $(FC_VER)
|
Loading…
Add table
Add a link
Reference in a new issue