rusefi/.github/workflows/build-firmware.yaml

672 lines
22 KiB
YAML

name: Firmware at GHA
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
lts:
description: 'LTS Build'
required: false
type: boolean
jobs:
build-libopenblt-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: cmake configure libopenblt
working-directory: ./firmware/ext/openblt/Host/Source/LibOpenBLT/build
run: cmake -DCMAKE_BUILD_TYPE=Release ..
# - name: make libopenblt
# working-directory: ./firmware/ext/openblt/Host/Source/LibOpenBLT/build
# run: make -j8
- name: cmake configure libopenblt_jni
working-directory: ./misc/libopenblt_jni/build
run: cmake -DCMAKE_BUILD_TYPE=Release ..
# - name: make libopenblt_jni
# working-directory: ./misc/libopenblt_jni/build
# run: make -j8
- name: coalesce
if: 0
run: |
mkdir deliver
cp ./firmware/ext/openblt/Host/libopenblt.so deliver/
cp ./misc/libopenblt_jni/build/libopenblt_jni.so deliver/
# - uses: actions/upload-artifact@v4
# if: 0
# name: libopenblt-linux
# path: |
# ./deliver/libopenblt.so
# ./deliver/libopenblt_jni.so
release:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Set run condition variables
run: |
if [ "${{github.event_name}}" = "schedule" ] && [ "${{github.repository}}" = "rusefi/rusefi" ]; then
echo "full=true" >> $GITHUB_ENV
echo "upload=release" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
fi
- uses: mukunku/tag-exists-action@v1.6.0
id: checkTag
with:
tag: ${{ env.date }}
- name: Create Release Tag
if: ${{ env.full == 'true' && env.upload == 'release' && steps.checkTag.outputs.exists == 'false' }}
id: tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
custom_tag: ${{ env.date }}
tag_prefix: ''
- name: Create Release
if: ${{ env.full == 'true' && env.upload == 'release' }}
uses: ncipollo/release-action@v1.14.0
with:
tag: ${{ env.date }}
name: "Nightly ${{ env.date }}"
artifacts: "artifacts/rusefi_bundle_*.zip"
replacesArtifacts: false
token: ${{ secrets.ACCESS_TOKEN }}
allowUpdates: true
prerelease: true
- name: coalesce
if: 0
run: |
mkdir deliver
cp ./firmware/ext/openblt/Host/libopenblt.dylib deliver/
cp ./misc/libopenblt_jni/build/libopenblt_jni.dylib deliver/
- uses: actions/upload-artifact@v4
with:
name: bootcommander-linux
path: |
./deliver/libopenblt.dylib
./deliver/libopenblt_jni.dylib
build-firmware:
runs-on: ubuntu-latest
needs: [
# todo proper build of build-libopenblt #5866
#build-libopenblt-linux,
#build-libopenblt-macos,
release]
strategy:
# Let all builds finish even if one fails early
fail-fast: false
matrix:
# What boards should we build for? In the 'include' section below,
# set up what each of these boards needs to build.
#
# see also gen_config where we have a similar list for all boards!
# see also build-primary-bundle where default/primary bundle is build separately
#
build-target: [
alphax-2chan,
alphax-4chan,
alphax-4chan_f7,
alphax-8chan,
alphax-8chan_debug,
m74_9,
s105,
t-b-g,
hellen72,
hellen81,
hellen88bmw,
hellen88bmw_avr,
hellen-nb1,
hellen-gm-e67,
hellenNA8_96,
hellenNA6,
hellen128,
hellen121vag,
hellen-honda-k,
hellen121nissan,
cypress,
frankenso_na6,
kinetis,
mre_f4,
mre_f4_no_openblt,
mre_f4_debug,
mre_f4_recovery,
mre_f7,
prometheus_405,
prometheus_469,
proteus_f4,
proteus_f7,
proteus_h7,
stm32f429_nucleo,
stm32f767_nucleo,
stm32f767_nucleo_debug,
stm32h743_nucleo,
subaru_eg33_f7,
subaru_eg33_f7_no_bl,
f407-discovery,
f429-discovery,
atlas,
tdg-pdm8,
at_start_f435,
]
include:
# Board configurations
# 'target' should match corresponding SHORT_BOARD_NAME
- build-target: hellen72
folder: config/boards/hellen/hellen72
short-board-name: hellen72
skip-rate: 90
- build-target: hellen81
folder: config/boards/hellen/hellen81
short-board-name: hellen81
skip-rate: 90
- build-target: alphax-2chan
folder: config/boards/hellen/alphax-2chan
short-board-name: alphax-2chan
skip-rate: 0
- build-target: alphax-4chan
folder: config/boards/hellen/alphax-4chan
short-board-name: alphax-4chan
- build-target: alphax-4chan_f7
folder: config/boards/hellen/alphax-4chan
short-board-name: alphax-4chan_f7
- build-target: alphax-8chan
folder: config/boards/hellen/alphax-8chan
short-board-name: alphax-8chan
skip-rate: 0
- build-target: alphax-8chan_debug
folder: config/boards/hellen/alphax-8chan
short-board-name: alphax-8chan
skip-rate: 95
- build-target: alphax-8chan_f7
folder: config/boards/hellen/alphax-8chan
short-board-name: alphax-8chan_f7
skip-rate: 0
- build-target: s105
folder: config/boards/s105
short-board-name: s105
skip-rate: 90
- build-target: t-b-g
folder: config/boards/test-build-guards
short-board-name: t-b-g
skip-rate: 90
- build-target: m74_9
folder: config/boards/m74_9
short-board-name: m74_9
skip-rate: 50
- build-target: small-can-board
folder: config/boards/hellen/small-can-board
short-board-name: small-can-board
skip-rate: 50
- build-target: uaefi
folder: config/boards/hellen/uaefi
short-board-name: uaefi
- build-target: small-can-board_debug
folder: config/boards/hellen/small-can-board
short-board-name: small-can-board
skip-rate: 00
- build-target: hellen88bmw
folder: config/boards/hellen/hellen88bmw
short-board-name: hellen88bmw
skip-rate: 99
- build-target: hellen88bmw_avr
folder: config/boards/hellen/hellen88bmw
short-board-name: hellen88bmw
skip-rate: 99
- build-target: hellen-nb1
folder: config/boards/hellen/hellen-nb1
short-board-name: hellen-nb1
skip-rate: 99
- build-target: hellen-112-17
folder: config/boards/hellen/hellen-112-17
short-board-name: hellen-112-17
skip-rate: 0
- build-target: hellen-112-17_debug
folder: config/boards/hellen/hellen-112-17
short-board-name: hellen-112-17
skip-rate: 0
- build-target: hellen-gm-e67
folder: config/boards/hellen/hellen-gm-e67
short-board-name: hellen-gm-e67
skip-rate: 99
- build-target: hellenNA8_96
folder: config/boards/hellen/hellenNA8_96
short-board-name: hellenNA8_96
skip-rate: 99
- build-target: hellenNA6
folder: config/boards/hellen/hellen64_miataNA6_94
short-board-name: hellenNA6
skip-rate: 90
- build-target: hellen128
folder: config/boards/hellen/hellen128
short-board-name: hellen128
skip-rate: 50
- build-target: hellen121vag
folder: config/boards/hellen/hellen121vag
short-board-name: hellen121vag
skip-rate: 99
- build-target: hellen121nissan
folder: config/boards/hellen/hellen121nissan
short-board-name: hellen121nissan
- build-target: hellen-honda-k
folder: config/boards/hellen/hellen-honda-k
short-board-name: hellen-honda-k
- build-target: hellen-honda-k_debug
folder: config/boards/hellen/hellen-honda-k
short-board-name: hellen-honda-k
- build-target: hellen154hyundai
folder: config/boards/hellen/hellen154hyundai
short-board-name: hellen154hyundai
skip-rate: 0
- build-target: hellen154hyundai_f7
folder: config/boards/hellen/hellen154hyundai
short-board-name: hellen154hyundai
skip-rate: 0
- build-target: cypress
folder: config/boards/cypress
short-board-name: cypress
- build-target: frankenso_na6
folder: config/boards/frankenso_na6
short-board-name: frankenso_na6
skip-rate: 90
- build-target: kinetis
folder: config/boards/kinetis
short-board-name: kin
skip-rate: 0
- build-target: mre_f4
folder: config/boards/microrusefi
short-board-name: mre_f4
- build-target: mre_f4_no_openblt
folder: config/boards/microrusefi
short-board-name: mre_f4
- build-target: mre_f4_debug
folder: config/boards/microrusefi
short-board-name: mre_f4
skip-rate: 100
- build-target: mre_f4_recovery
folder: config/boards/microrusefi
short-board-name: mre_f4
skip-rate: 100
- build-target: mre_f7
folder: config/boards/microrusefi
short-board-name: mre_f7
skip-rate: 90
- build-target: prometheus_405
folder: config/boards/prometheus
short-board-name: prometheus_405
skip-rate: 90
- build-target: prometheus_469
folder: config/boards/prometheus
short-board-name: prometheus_469
skip-rate: 90
- build-target: proteus_f4
folder: config/boards/proteus
short-board-name: proteus_f4
- build-target: proteus_f4_debug
folder: config/boards/proteus
short-board-name: proteus_f4
skip-rate: 80
- build-target: proteus_f7
folder: config/boards/proteus
short-board-name: proteus_f7
# - build-target: proteus_f7_debug
# folder: config/boards/proteus
# short-board-name: proteus_f7
# skip-rate: 80
- build-target: proteus_h7
folder: config/boards/proteus
short-board-name: proteus_h7
skip-rate: 90
- build-target: stm32f429_nucleo
folder: config/boards/nucleo_f429
short-board-name: stm32f429_nucleo
- build-target: stm32f767_nucleo
folder: config/boards/nucleo_f767
short-board-name: stm32f767_nucleo
skip-rate: 0
- build-target: stm32f767_nucleo_debug
folder: config/boards/nucleo_f767
short-board-name: stm32f767_nucleo
skip-rate: 0
- build-target: stm32h743_nucleo
folder: config/boards/nucleo_h743
short-board-name: stm32h743_nucleo
skip-rate: 95
- build-target: subaru_eg33_f7
folder: config/boards/subaru_eg33
short-board-name: subaru_eg33_f7
skip-rate: 50
- build-target: subaru_eg33_f7_no_bl
folder: config/boards/subaru_eg33
short-board-name: subaru_eg33_f7
skip-rate: 50
- build-target: f407-discovery
folder: config/boards/f407-discovery
short-board-name: f407-discovery
skip-rate: 0
- build-target: f407-discovery_debug
folder: config/boards/f407-discovery
short-board-name: f407-discovery
skip-rate: 0
- build-target: f429-discovery
folder: config/boards/f429-discovery
short-board-name: f429-discovery
skip-rate: 95
- build-target: atlas
folder: config/boards/atlas
short-board-name: atlas
skip-rate: 95
- build-target: tdg-pdm8
folder: config/boards/tdg-pdm8
short-board-name: tdg-pdm8
skip-rate: 95
- build-target: at_start_f435
folder: config/boards/at_start_f435
short-board-name: at_start_f435
skip-rate: 0
steps:
- name: Check branch name
if: ${{ contains(github.ref_name, '.') }}
run: echo '::error::Branch names must not contain ".", this breaks firmware autoupdates.' && exit 1
- name: Execution throttle early exit
# Don't skip any jobs if this workflow was run manually,
# or if the commit contains `only:`, signifying that only one bundle should be built.
if: ${{ matrix.skip-rate && github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' && github.event_name != 'pull_request' || contains(github.event.head_commit.message, 'only:') }}
run: |
# if the commit message contains `only:`, get the part after the semicolon and check if it matches the build target.
read -d '' MSG << EOM || true
${{ github.event.head_commit.message }}
EOM
if echo $MSG | grep "only:"; then
if [ "$(echo $MSG | grep -Po '(?<=only:)[^\s]*')" = "${{ matrix.build-target }}" ]; then
exit 0
else
# if it doesn't match, skip this job.
echo "skip=true" >> $GITHUB_ENV
exit 0
fi
fi
if (($(($RANDOM % 100)) < ${{ matrix.skip-rate }})); then echo "skip=true" >> $GITHUB_ENV; fi
- name: Set run condition variables
run: |
if [ "${{github.event_name}}" = "schedule" ] && [ "${{github.repository}}" = "rusefi/rusefi" ]; then
echo "Scheduled mode"
echo "full=true" >> $GITHUB_ENV
echo "upload=release" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
elif [ "${{github.event_name}}" = "push" ]\
&& [ "${{github.ref}}" = "refs/heads/master" ]\
&& [ "${{env.skip}}" != "true" ]\
|| [ "${{toJSON(inputs.lts)}}" = "true" ]; then
echo "Full mode"
echo "full=true" >> $GITHUB_ENV
echo "upload=server" >> $GITHUB_ENV
elif [ "${{env.skip}}" != "true" ]; then
echo "Partial mode"
echo "partial=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
if: ${{ env.skip != 'true' }}
- name: Checkout Submodules
if: ${{ env.skip != 'true' }}
run: |
git submodule update --init --depth=1 firmware/ChibiOS
git submodule update --init --depth=1 firmware/ChibiOS-Contrib
git submodule update --init --depth=1 firmware/libfirmware
git submodule update --init --depth=1 firmware/ext/lua
git submodule update --init --depth=1 firmware/ext/uzlib
git submodule update --init --depth=1 firmware/ext/openblt
git submodule update --init --depth=1 firmware/controllers/lua/luaaa
git submodule update --init --depth=1 firmware/controllers/can/wideband_firmware
git submodule update --init --depth=1 java_console/luaformatter
git submodule update --init --depth=1 java_console/peak-can-basic
- uses: actions/setup-java@v4
if: ${{ env.skip != 'true' }}
with:
distribution: 'zulu'
java-version: '11'
- name: Install multilib, mingw, sshpass and mtools
if: ${{ env.skip != 'true' }}
run: |
sudo bash misc/actions/add-ubuntu-latest-apt-mirrors.sh
sudo apt-get install gcc-multilib g++-multilib g++-mingw-w64 gcc-mingw-w64 sshpass mtools zip dosfstools
- name: Generate Live Documentation
if: ${{ env.skip != 'true' }}
working-directory: ./firmware/
run: ./gen_live_documentation.sh
- name: Generate Configs for build-target
if: ${{ env.skip != 'true' }}
working-directory: ./firmware/
# todo: we have code duplication with gen_config.sh here :(
run: |
if [ "${{ matrix.build-target }}" = "kinetis" ]; then
config/boards/kinetis/config/gen_kinetis_config.sh
[ $? -eq 0 ] || { echo "ERROR generating board kinetis kin"; exit 1; }
elif [ "${{ matrix.build-target }}" = "cypress" ]; then
config/boards/cypress/config/gen_cypress_config.sh
[ $? -eq 0 ] || { echo "ERROR generating board cypress cypress"; exit 1; }
elif [ "${{ matrix.build-target }}" = "subaru_eg33_f7" ]; then
bash config/boards/subaru_eg33/config/gen_subaru_config.sh
[ $? -eq 0 ] || { echo "ERROR generating board subaru_eg33 subaru_eg33_f7"; exit 1; }
elif [ "${{ matrix.build-target }}" = "subaru_eg33_f7_no_bl" ]; then
bash config/boards/subaru_eg33/config/gen_subaru_config.sh
[ $? -eq 0 ] || { echo "ERROR generating board subaru_eg33 subaru_eg33_f7_no_bl"; exit 1; }
elif [ "${{ matrix.short-board-name }}" = "" ]; then
echo "ERROR: ${{ matrix.build-target }} is missing short-board-name attribute"
exit -1
else
bash gen_config_board.sh ${{matrix.folder}} ${{matrix.short-board-name}}
fi
- name: Git Status
if: ${{ env.skip != 'true' }}
run: |
git status
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
if: ${{ env.skip != 'true' }}
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '12.3.Rel1'
# Make sure the compiler we just downloaded works - just print out the version
- name: Test arm-none-eabi-gcc Compiler
if: ${{ env.skip != 'true' }}
run: arm-none-eabi-gcc -v
- name: Configs Set SSH variables
if: ${{ env.full == 'true' && env.upload == 'server' }}
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
echo "RUSEFI_SSH_SERVER=${{secrets.RUSEFI_SSH_SERVER}}" >> $GITHUB_ENV
echo "RUSEFI_SSH_USER=${{secrets.RUSEFI_SSH_USER}}" >> $GITHUB_ENV
echo "RUSEFI_SSH_PASS=${{secrets.RUSEFI_SSH_PASS}}" >> $GITHUB_ENV
# Build rusEFI console
- name: Build console
if: ${{ env.full == 'true' }}
run: bash misc/jenkins/build_java_console.sh
# Build the simulator
- name: Build simulator
if: ${{ env.full == 'true' }}
# 'OS="Windows_NT"' allows us to build Windows executable on unix
run: OS="Windows_NT" bash misc/jenkins/build_simulator.sh
# - name: Download LibOpenBLT Tool (Linux)
# uses: actions/download-artifact@v3
# with:
# name: libopenblt-linux
# path: ./firmware/ext/openblt/Host/
# - name: Download LibOpenBLT Tool (MacOS)
# uses: actions/download-artifact@v3
# with:
# name: libopenblt-macos
# path: ./firmware/ext/openblt/Host/
# Build the firmware!
- name: Build Firmware
if: ${{ env.skip != 'true' }}
run: bash misc/jenkins/compile_other_versions/compile.sh ${{matrix.folder}} ${{matrix.build-target}}
- name: Package Bundle
if: ${{ env.full == 'true' }}
run: bash misc/jenkins/compile_other_versions/prepare_bundle.sh ${{matrix.build-target}} "firmware/tunerstudio/generated/rusefi_${{matrix.short-board-name}}.ini" ${{ github.ref_name }} ${{ toJSON(inputs.lts) }}
- name: Add Bundles to Release
if: ${{ env.full == 'true' && env.upload == 'release' }}
uses: ncipollo/release-action@v1.14.0
with:
tag: ${{ env.date }}
name: "Nightly ${{ env.date }}"
artifacts: "artifacts/rusefi_bundle_*.zip"
replacesArtifacts: false
token: ${{ secrets.ACCESS_TOKEN }}
allowUpdates: true
prerelease: true
- name: Upload .ini files to server
if: ${{ env.full == 'true' }}
working-directory: ./firmware/tunerstudio/generated
run: ../upload_ini.sh "rusefi_${{matrix.short-board-name}}.ini" ${{ secrets.RUSEFI_ONLINE_FTP_USER }} ${{ secrets.RUSEFI_ONLINE_FTP_PASS }} ${{ secrets.RUSEFI_FTP_SERVER }}
- name: Upload build elf artifact
if: ${{ env.partial == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.elf
path: ./firmware/build/rusefi.elf
- name: Upload build map artifact
if: ${{ env.partial == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.map
path: ./firmware/build/rusefi.map
- name: Upload build bin artifact
if: ${{ env.partial == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.bin
path: ./firmware/deliver/rusefi*.bin
- name: Upload build hex artifact
if: ${{ env.partial == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.hex
# we have a bit of a mess - this file from 'build' folder is only legit for not-BLT builds
# todo: we should produce .hex in both OpenBLT and non-OpenBLT case same as we do for .bin and .elf
path: ./firmware/build/rusefi*.hex
- name: Upload build dfu artifact
if: ${{ env.partial == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_${{matrix.build-target}}.dfu
path: ./firmware/deliver/rusefi*.dfu
- name: Upload bundle artifact
if: ${{ env.full == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_bundle_${{matrix.build-target}}.zip
path: ./artifacts/rusefi_bundle*.zip
- name: Upload autoupdate bundle artifact
if: ${{ env.full == 'true' }}
uses: actions/upload-artifact@v4
with:
name: rusefi_bundle_${{matrix.build-target}}_autoupdate.zip
path: ./artifacts/rusefi_bundle_${{matrix.build-target}}_autoupdate.zip