Skip to content

Commit

Permalink
CI improvements (#334)
Browse files Browse the repository at this point in the history
- Main workflow
- Avoid duplicate runs
- Job dependencies
- Dependencies caching
- Job conditional execution
  • Loading branch information
tlifschitz authored Aug 28, 2024
1 parent e9b5ab8 commit bc38ed4
Show file tree
Hide file tree
Showing 17 changed files with 868 additions and 522 deletions.
63 changes: 63 additions & 0 deletions .github/actions/build-dbus/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 'Build DBus'
description: 'Clone and build DBus'

inputs:
os:
description: "Runner OS"
type: string
default: ''
required: false

arch:
description: "Platform architecture"
type: string
default: ''
required: false

runs:
using: "composite"
steps:
- name: Install Dependencies
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -H apt-get update -y
sudo -H apt-get install -y jq curl
- name: Build Expat
uses: ./.github/actions/build-expat
with:
os: ${{ inputs.os }}
arch: ${{ inputs.arch }}
- name: Set env
shell: bash
run: |
echo "EXPAT_ROOT=/tmp/expat/install" >> $GITHUB_ENV
echo "DBUS_ROOT=/tmp/dbus/install" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=/tmp/dbus/install:/tmp/expat/install" >> $GITHUB_ENV
- name: Get latest DBus commit hash
id: dbus-hash
shell: bash
run: |
DBUS_HASH=$(curl -s https://gitlab.freedesktop.org/api/v4/projects/1187/repository/commits | jq -r '.[0].id')
echo "value=$DBUS_HASH" >> $GITHUB_OUTPUT
- name: Cache DBus
id: cache-dbus
uses: actions/cache@v4
with:
path: /tmp/dbus/install
key: ${{ inputs.os }}-${{ inputs.arch }}-dbus-${{ steps.dbus-hash.outputs.value }}

- name: Build DBus
if: steps.cache-dbus.outputs.cache-hit != 'true'
shell: bash
run: |
git clone https://gitlab.freedesktop.org/dbus/dbus.git /tmp/dbus
cd /tmp/dbus
cmake -B build -DDBUS_SESSION_SOCKET_DIR=/usr/local/var/run/dbus/system_bus_socket -DDBUS_BUILD_TESTS=OFF
cmake --build build --config Release --parallel 4
cmake --install build --prefix /tmp/dbus/install
43 changes: 43 additions & 0 deletions .github/actions/build-expat/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Build Expat'
description: 'Clone and build Expat'
inputs:
os:
description: "Runner OS"
type: string
default: ''
required: false

arch:
description: "Platform architecture"
type: string
default: ''
required: false

runs:
using: "composite"
steps:
- name: Get latest Expat commit hash
id: expat-hash
shell: bash
run: |
EXPAT_HASH=$(curl -s https://api.github.com/repos/libexpat/libexpat/commits/master | jq -r .sha)
echo "value=$EXPAT_HASH" >> $GITHUB_OUTPUT
echo "EXPAT_ROOT=/tmp/expat/install" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=/tmp/expat/install" >> $GITHUB_ENV
- name: Cache Expat
id: cache-expat
uses: actions/cache@v4
with:
path: /tmp/expat/install
key: ${{ inputs.os }}-${{ inputs.arch }}-expat-${{ steps.expat-hash.outputs.value }}

- name: Build Expat
if: steps.cache-expat.outputs.cache-hit != 'true'
shell: bash
run: |
git clone https://github.com/libexpat/libexpat.git /tmp/expat
cd /tmp/expat/expat
cmake -B build -DEXPAT_BUILD_DOCS=OFF -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF
cmake --build build --config Release --parallel 4
cmake --install build --prefix /tmp/expat/install
9 changes: 9 additions & 0 deletions .github/actions/setup-cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Setup CMake'
description: 'Setup CMake'

runs:
using: "composite"
steps:
- uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.21'
39 changes: 39 additions & 0 deletions .github/actions/setup-gtest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Build GTest'
description: 'Clone and build Google Test'

runs:
using: "composite"
steps:
- name: Get latest GTest commit hash
id: gtest-hash
shell: bash
run: |
GTEST_HASH=$(curl -s https://api.github.com/repos/google/googletest/commits/main | jq -r .sha)
echo "value=$GTEST_HASH" >> $GITHUB_OUTPUT
- name: Cache GTest
id: cache-gtest
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/googletest/install
key: ${{ runner.os }}-${{ runner.arch }}-gtest-${{ steps.gtest-hash.outputs.value }}

- name: Build GTest for Unix-like systems
if: runner.os != 'Windows' && steps.cache-gtest.outputs.cache-hit != 'true'
shell: bash
run: |
git clone https://github.com/google/googletest
cd googletest
cmake . -B build
cmake --build ./build --config Release --parallel 4
cmake --install ./build --prefix ./install
- name: Build GTest for Windows
if: runner.os == 'Windows' && steps.cache-gtest.outputs.cache-hit != 'true'
shell: cmd
run: |
git clone https://github.com/google/googletest
cd googletest
cmake . -B build -Dgtest_force_shared_crt=ON
cmake --build .\build --config Release --parallel 4
cmake --install .\build --prefix .\install
68 changes: 0 additions & 68 deletions .github/workflows/ci_build_examples.yml

This file was deleted.

163 changes: 0 additions & 163 deletions .github/workflows/ci_cpp_release_test.yml

This file was deleted.

Loading

0 comments on commit bc38ed4

Please sign in to comment.