1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 01:35:35 +03:00

Merge pull request #5558 from iNavFlight/agh_github_ci_pr_only

[CI] CI updates
This commit is contained in:
Alberto García Hierro 2020-04-01 16:14:14 +01:00 committed by GitHub
commit aabbadb1ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 87 deletions

View file

@ -1,33 +1,11 @@
name: Build firmware name: Build firmware
on: # Don't enable CI on push, just on PR. If you
push: # are working on the main repo and want to trigger
branches-ignore: # a CI build submit a draft PR.
- master on: pull_request
- development
pull_request:
jobs: 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: build:
needs: download-toolchain
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
strategy: strategy:
matrix: matrix:
@ -35,58 +13,55 @@ jobs:
count: [10] count: [10]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup environment - name: Setup environment
run: | run: |
echo "::set-env name=TARGETS::$(./src/utils/build-targets.sh -n -s ${{ matrix.start }} -c ${{ matrix.count }})" # This is the hash of the commit for the PR
echo "::set-env name=BUILD_SUFFIX::ci-$(git rev-parse --short ${{ github.ref }})" # when the action is triggered by PR, empty otherwise
echo "::set-env name=IS_LAST_JOB::$([ $(expr ${{ strategy.job-index }} + 1) = ${{ strategy.job-total }} ] && echo yes)" COMMIT_ID=${{ github.event.pull_request.head.sha }}
- name: Ensure all targets will be tested # This is the hash of the commit when triggered by push
if: ${{ env.IS_LAST_JOB }} # but the hash of refs/pull/<n>/merge, which is different
run: | # from the hash of the latest commit in the PR, that's
UNTESTED=$(./src/utils/build-targets.sh -n -s $(expr ${{ matrix.start }} + ${{ matrix.count }}) -c 10000) # why we try github.event.pull_request.head.sha first
if ! [ -z "${UNTESTED}" ]; then COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
echo "Untested targets: ${UNTESTED}" >&2 BUILD_SUFFIX=ci-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
exit 1 echo "::set-env name=TARGETS::$(./src/utils/build-targets.sh -n -s ${{ matrix.start }} -c ${{ matrix.count }})"
fi echo "::set-env name=BUILD_SUFFIX::${BUILD_SUFFIX}"
- name: Prepare ARM toolchain environment echo "::set-env name=BUILD_NAME::inav-$(make print_version)-${BUILD_SUFFIX}"
if: ${{ env.TARGETS }} echo "::set-env name=IS_LAST_JOB::$([ $(expr ${{ strategy.job-index }} + 1) = ${{ strategy.job-total }} ] && echo yes)"
run: | - name: Ensure all targets will be tested
echo "::set-env name=ARM_SDK_FILENAME::$(make arm_sdk_print_filename)" if: ${{ env.IS_LAST_JOB }}
echo "::set-env name=ARM_SDK_DOWNLOAD_DIR::$(dirname $(make arm_sdk_print_download_path))" run: |
- name: Download ARM toolchain UNTESTED=$(./src/utils/build-targets.sh -n -s $(expr ${{ matrix.start }} + ${{ matrix.count }}) -c 10000)
if: ${{ env.TARGETS }} if ! [ -z "${UNTESTED}" ]; then
uses: actions/download-artifact@v1 echo "Untested targets: ${UNTESTED}" >&2
with: exit 1
name: ${{ env.ARM_SDK_FILENAME }} fi
path: ${{ env.ARM_SDK_DOWNLOAD_DIR }} - uses: actions/cache@v1
- name: Install ARM toolchain with:
if: ${{ env.TARGETS }} path: downloads
run: make arm_sdk_install key: ${{ runner.os }}-downloads-${{ hashFiles('Makefile') }}-${{ hashFiles('**/make/*.mk')}}
- name: Build targets (${{ matrix.start }}) - name: Install ARM toolchain
if: ${{ env.TARGETS }} run: make arm_sdk_install
run: ./src/utils/build-targets.sh -s ${{ matrix.start }} -c ${{ matrix.count }} -S ${{ env.BUILD_SUFFIX }} - name: Build targets (${{ matrix.start }})
- name: Upload artifacts if: ${{ env.TARGETS }}
if: ${{ env.TARGETS }} run: ./src/utils/build-targets.sh -s ${{ matrix.start }} -c ${{ matrix.count }} -S ${{ env.BUILD_SUFFIX }}
uses: actions/upload-artifact@v2-preview - name: Upload artifacts
with: if: ${{ env.TARGETS }}
name: inav-${{ env.BUILD_SUFFIX }}.zip uses: actions/upload-artifact@v2-preview
path: ./obj/*.hex with:
name: ${{ env.BUILD_NAME }}.zip
path: ./obj/*.hex
test: test:
needs: [download-toolchain, build] needs: [build]
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Prepare ARM toolchain environment - uses: actions/cache@v1
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
with: with:
name: ${{ env.ARM_SDK_FILENAME }} path: downloads
path: ${{ env.ARM_SDK_DOWNLOAD_DIR }} key: ${{ runner.os }}-downloads-${{ hashFiles('Makefile') }}-${{ hashFiles('**/make/*.mk')}}
- name: Install ARM toolchain - name: Install ARM toolchain
run: make arm_sdk_install run: make arm_sdk_install
- name: Run Tests - name: Run Tests

View file

@ -64,8 +64,6 @@ endif
# Things that need to be maintained as the source changes # Things that need to be maintained as the source changes
# #
FORKNAME = inav
# Working directories # Working directories
SRC_DIR := $(ROOT)/src/main SRC_DIR := $(ROOT)/src/main
OBJECT_DIR := $(ROOT)/obj/main OBJECT_DIR := $(ROOT)/obj/main
@ -85,17 +83,9 @@ MHZ_VALUE ?=
# used for turning on features like VCP and SDCARD # used for turning on features like VCP and SDCARD
FEATURES = FEATURES =
include $(ROOT)/make/version.mk
include $(ROOT)/make/targets.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) BUILD_DATE = $(shell date +%Y%m%d)
# Search path for sources # Search path for sources
@ -255,9 +245,6 @@ CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
# Things we will build # Things we will build
# #
TARGET_BIN := $(BIN_DIR)/$(FORKNAME)_$(FC_VER) TARGET_BIN := $(BIN_DIR)/$(FORKNAME)_$(FC_VER)
ifneq ($(FC_VER_SUFFIX),)
TARGET_BIN := $(TARGET_BIN)-$(FC_VER_SUFFIX)
endif
TARGET_BIN := $(TARGET_BIN)_$(TARGET) TARGET_BIN := $(TARGET_BIN)_$(TARGET)
ifneq ($(BUILD_SUFFIX),) ifneq ($(BUILD_SUFFIX),)
TARGET_BIN := $(TARGET_BIN)_$(BUILD_SUFFIX) TARGET_BIN := $(TARGET_BIN)_$(BUILD_SUFFIX)

View file

@ -80,7 +80,7 @@ arm_sdk_clean:
ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists) ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists)
ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi- 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) GCC_VERSION = $(shell arm-none-eabi-gcc -dumpversion)
ifeq ($(GCC_VERSION),) 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) $(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
View 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)