Skip to content

Commit

Permalink
DevOps recharged (#135)
Browse files Browse the repository at this point in the history
DevOps recharged:
- DevOps: Auto build for Update Packages, closes #56
- DevOps: Platform IO Build: replace deprecated commands, closes #136
- DevOps: evaluate use of GitHub Actions, closes #138
- Documentation: How to create the tup files for the OTA update, closes #127
  • Loading branch information
JakobLichterfeld authored Feb 22, 2023
1 parent 0befc7f commit 79e56be
Show file tree
Hide file tree
Showing 11 changed files with 330 additions and 116 deletions.
16 changes: 16 additions & 0 deletions .github/actions/get-correct-short-commit-sha/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
name: 'Get correct short commit SHA'
description: 'Get correct short commit SHA and make available as env.short_sha'
runs:
using: "composite"
steps:
- name: Get correct short commit SHA
id: correct_commit_sha
shell: bash
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$calculatedSha" >> $GITHUB_ENV
- name: Confirm git commit SHA output
shell: bash
run: echo ${{ env.short_sha }}
46 changes: 46 additions & 0 deletions .github/actions/platformio-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'PlatformIO Build'
description: 'PlatformIO Build'
runs:
using: "composite"
steps:
- uses: actions/checkout@v3

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install PlatformIO Core
shell: bash
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build PlatformIO project
working-directory: ./mcu
shell: bash
run: pio run

- name: Get correct short commit SHA stored into env.short_sha
uses: ./.github/actions/get-correct-short-commit-sha

- name: publish as artifact
uses: actions/upload-artifact@v3
with:
name: PlatformIO-build_${{ env.short_sha }}
path: ./mcu/.pio/build/az-delivery-devkit-v4/firmware.bin
if-no-files-found: error
retention-days: 1
55 changes: 55 additions & 0 deletions .github/actions/ui-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'UI build'
description: 'UI build'
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
working-directory: ./ui
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: ./ui
shell: bash
run: pnpm install

- name: Build
working-directory: ./ui
shell: bash
run: pnpm build

- name: Get correct short commit SHA stored into env.short_sha
uses: ./.github/actions/get-correct-short-commit-sha

- name: publish as artifact
uses: actions/upload-artifact@v3
with:
name: UI-build_${{ env.short_sha }}
path: ./ui/dist/
if-no-files-found: error
retention-days: 1
44 changes: 44 additions & 0 deletions .github/actions/ui-lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'UI lint'
description: 'UI lint'
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
working-directory: ./ui
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: ./ui
shell: bash
run: pnpm install

- name: Lint
working-directory: ./ui
shell: bash
run: pnpm lint
56 changes: 56 additions & 0 deletions .github/actions/update-tool-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Update Tool build'
description: 'Update Tool build'
runs:
using: "composite"
steps:
- name: Checkout Code
uses: actions/checkout@v3

# - name: print g++ version
# shell: bash
# if: startsWith(matrix.os,'ubuntu') || startsWith(runner.os,'ubuntu') || startsWith(matrix.os,'Windows') || startsWith(runner.os,'Windows')
# run: |
# if [ '$runner_os' == 'Linux' || '$matrix_os' == 'Linux' || '$runner_os' == 'Windows' || '$matrix_os' == 'Windows' ]; then
# gcc --version
# elif [ '$runner_os' == 'macOS' || '$matrix_os' == 'macOS' ]; then
# brew info gcc
# fi

- name: Set up GCC for Linux
if: startsWith(matrix.os,'ubuntu') || startsWith(runner.os,'ubuntu')
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: x64

# - name: Set up MinGW for Windows
# if: startsWith(${{ matrix.os }},'Windows') || startsWith(${{ runner.os }},'Windows')
# uses: egor-tensin/setup-mingw@v2
# with:
# platform: x64

# - name: Set up GCC for MacOS
# if: startsWith(${{ matrix.os }},'macOS') || startsWith(${{ runner.os }},'macOS')
# shell: bash
# run: |
# export HOMEBREW_NO_ANALYTICS=1
# brew update
# brew upgrade
# brew info gcc
# brew install gcc
# brew cleanup

- name: g++ build
shell: bash
working-directory: update-package-tool
run: |
mkdir build
g++ -std=c++17 -g ./src/*.cpp -o build/tupt_for_${{ runner.os }}.exe
- name: publish TesLight Update Packaging Tool for ${{ runner.os }}
uses: actions/upload-artifact@v3
with:
name: TesLight_Update_Packaging_Tool_for_${{ runner.os }}
path: update-package-tool/build/tupt_for_${{ runner.os }}.exe
if-no-files-found: error
retention-days: 90
24 changes: 4 additions & 20 deletions .github/workflows/PlatformIO-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,12 @@ on:
pull_request:
branches: ["main"]
workflow_dispatch:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v3
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Run PlatformIO
working-directory: ./mcu
run: pio run

- name: PlatformIO Build
uses: ./.github/actions/platformio-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: TesLight Update Packaging Tool and TUP file Build
on:
push:
branches: ["main", "releases/**"]
tags: ["v*", "v**", "v.*", "v.**" ]
pull_request:
branches: ["main", "releases/**"]
workflow_dispatch:
workflow_call:
jobs:
build_update_tool_for_different_os:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
# prevent stuck jobs
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Update Tool Build
uses: ./.github/actions/update-tool-build

generate_tup_file:
needs: [build_update_tool_for_different_os]
runs-on: ubuntu-latest
# prevent stuck jobs
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Get correct short commit SHA stored into env.short_sha
uses: ./.github/actions/get-correct-short-commit-sha

- name: PlatformIO Build
uses: ./.github/actions/platformio-build

- name: UI Build
uses: ./.github/actions/ui-build

- name: Download artifact - PlatformIO Build
uses: actions/download-artifact@v3
with:
name: PlatformIO-build_${{ env.short_sha }}
path: ./update-package-tool/build/tup/src

- name: Download artifact - UI Build
uses: actions/download-artifact@v3
with:
name: UI-build_${{ env.short_sha }}
path: ./update-package-tool/build/tup/src

- name: Download artifact - TesLight_Update_Packaging_Tool
uses: actions/download-artifact@v3
with:
name: TesLight_Update_Packaging_Tool_for_${{ runner.os }}
path: update-package-tool/build

- name: File permissions
if: startsWith(${{ runner.os }},'ubuntu') || startsWith(${{ runner.os }},'macOS')
shell: bash
run: chmod +x ./update-package-tool/build/tupt_for_*.exe

- name: tup build
shell: bash
run: |
mkdir -p ./update-package-tool/build/tup/build
./update-package-tool/build/tupt_for_${{ runner.os }}.exe ./update-package-tool/build/tup/build/update_${{ env.short_sha }}.tup ./update-package-tool/build/tup/src
- name: publish TesLight Update Package File
uses: actions/upload-artifact@v3
with:
name: TesLight_Update_Package_${{ env.short_sha }}
path: ./update-package-tool/build/tup/build/update_${{ env.short_sha }}.tup
if-no-files-found: error
retention-days: 90
27 changes: 27 additions & 0 deletions .github/workflows/ui-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: UI build

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: UI lint
uses: ./.github/actions/ui-lint

build:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: UI build
uses: ./.github/actions/ui-build
Loading

0 comments on commit 79e56be

Please sign in to comment.