Skip to content

Improve build workflow (#1001) #730

Improve build workflow (#1001)

Improve build workflow (#1001) #730

Workflow file for this run

---
name: Style
on:
push:
branches: [main, develop, release, improve_build-workflow]
paths-ignore:
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- 'docker/**'
- '**.md'
- '!docs/building-cmake.md'
- 'changelog.txt'
- 'LICENSE'
- '.github/**'
- '!.github/workflows/styles.yml'
- 'snap/**'
- 'build/**'
- 'assets/**'
- 'Docker/**'
- 'report/**'
- 'resources/**'
pull_request:
types: [opened, reopened]
paths-ignore:
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- 'docker/**'
- '**.md'
- '!docs/building-cmake.md'
- 'changelog.txt'
- 'LICENSE'
- '.github/**'
- '!.github/workflows/styles.yml'
- 'snap/**'
- 'build/**'
- 'assets/**'
- 'Docker/**'
- 'report/**'
- 'resources/**'
release:
types: [published]
env:
SOURCE_CACHE: ${{ github.workspace }}/src
QT_VERSION: 6.2.0
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
PRODUCT: jmbde
targetName: jmbde
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
platform: [ubuntu-latest]
qt_arch: [gcc_64]
arch: [amd64]
artifact: [Ubuntu-gcc]
cmake_generator: [Ninja]
cc: [clang-12]
cxx: [clang-12]
fail-fast: true
steps:
- name: '🧰 Checkout Source Code'
if: github.event_name == 'push'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: '🧰 Checkout Source Code'
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2
with:
path: '**/src'
key: ${{ github.workflow }}-src-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake')
}}
- name: '⚙️ Install dependencies'
run: |
sudo apt-get -y -qq update
sudo apt-get -y --no-install-recommends install \
ninja-build
- name: '⚙️ install python dependencies'
run: |
pipx install conan
- name: '⚙️ Cache Qt'
id: cache-qt
uses: actions/cache@v1 # not v2!
with:
path: '${{ github.workspace }}/Qt'
key: QtCache-${{ matrix.platform }}-{{ matrix.arch }}-${{ env.QT_VERSION }}
- name: '⚙️ Install Qt'
uses: jurplel/install-qt-action@v2
with:
version: ${{ env.QT_VERSION }}
target: ${{ env.QT_TARGET }}
arch: ${{ matrix.qt_arch }}
# modules: 'qtscript'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx}}
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: |
cmake $GITHUB_WORKSPACE \
-G ${{matrix.config.generator}} \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DENABLE_CLANG_FORMAT=ON
- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build . \
--config ${{ env.BUILD_TYPE }} \
-j$(nproc)
# Run only on linux
- name: Validate QML and JavaScript files
uses: liri-infra/qmllint-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: SQL Check
uses: yokawasa/action-sqlcheck@v1.3.0
id: sqlcheck
with:
post-comment: true
risk-level: 3
verbose: true
token: ${{ secrets.GITHUB_TOKEN }}
postfixes: |
sql
sqlx
schema
directories: |
src/models
- name: Get SQL CHECK output
if: steps.sqlcheck.outputs.issue-found
run: echo "Issues found in previous step"
- name: Clang Format
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: './src'
clangFormatVersion: 12
inplace: True
- uses: EndBug/add-and-commit@v9
with:
author_name: Clang Robot
author_email: robot@example.com
message: 'Committing clang-format changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: PMD Code Analyzer Action
# uses: billyan2018/setup-pmd@PMDAnalyzer1.0
# run: pmd -d ./src -R category/apex/design.xml -f text
# - name: Check_for_duplicate_code
# uses: platisd/duplicate-code-detection-tool@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# directories: 'src'
# # Ignore the specified directories
# ignore_directories: 'src/3rd-party'
# # Only examine .h and .cpp files
# file_extensions: 'h, cpp'
# # Only report similarities above 5%
# ignore_below: 5
# # If a file is more than 70% similar to another, then the job fails
# fail_above: 70
# # If a file is more than 15% similar to another, show a warning symbol in the report
# warn_above: 15
# # Remove `src/` from the file paths when reporting similarities
# project_root_dir: 'src'