Skip to content

Commit

Permalink
Add tests to verify that we work with cmake & autotools (#1678)
Browse files Browse the repository at this point in the history
* ci: remove a useless command

* add a configure example

* add a cmake example

* Test with autotools & cmake in the CI
  • Loading branch information
sylvestre committed Mar 22, 2023
1 parent 0a6c099 commit 056cc67
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 2 deletions.
117 changes: 115 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ jobs:
- name: Test Twice for Cache Read
run: |
rm -f hello_world
export CXX="${SCCACHE_PATH} clang++"
$CXX -c `pwd`/tests/test_clang_multicall.c
Expand Down Expand Up @@ -487,7 +486,6 @@ jobs:
- name: Test Twice for Cache Read
run: |
rm -f hello_world
export CXX="${SCCACHE_PATH} g++"
$CXX -c `pwd`/tests/test_clang_multicall.c
Expand All @@ -496,3 +494,118 @@ jobs:
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
autotools:
runs-on: ubuntu-latest
needs: build

env:
SCCACHE_GHA_ENABLED: "on"

steps:
- uses: actions/checkout@v3

- name: Configure Cache Env
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '')
- uses: actions/download-artifact@v3
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}

- name: Install dependencies
shell: bash
run: |
## Install dependencies
sudo apt-get update
sudo apt-get install autoconf automake libtool
- name: Test
run: |
cd `pwd`/tests/autotools/
autoreconf||true
automake --add-missing
./configure CXX="${SCCACHE_PATH} g++"
make
- name: Output
run: |
${SCCACHE_PATH} --show-stats
- name: Test Twice for Cache Read
run: |
cd `pwd`/tests/autotools/
make distclean
./configure CXX="${SCCACHE_PATH} g++"
make
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
cmake:
runs-on: ubuntu-latest
needs: build

env:
SCCACHE_GHA_ENABLED: "on"

steps:
- uses: actions/checkout@v3

- name: Configure Cache Env
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '')
- uses: actions/download-artifact@v3
with:
name: integration-tests
path: /home/runner/.cargo/bin/
- name: Chmod for binary
run: chmod +x ${SCCACHE_PATH}

- name: Install dependencies
shell: bash
run: |
## Install dependencies
sudo apt-get update
sudo apt-get install cmake
- name: Test
run: |
cd `pwd`/tests/cmake/
mkdir build
cd build
cmake -DCMAKE_C_COMPILER_LAUNCHER=${SCCACHE_PATH} -DCMAKE_CXX_COMPILER_LAUNCHER=${SCCACHE_PATH} ..
make
- name: Output
run: |
${SCCACHE_PATH} --show-stats
- name: Test Twice for Cache Read
run: |
cd `pwd`/tests/cmake/
rm -rf build
mkdir build
cd build
cmake -DCMAKE_C_COMPILER_LAUNCHER=${SCCACHE_PATH} -DCMAKE_CXX_COMPILER_LAUNCHER=${SCCACHE_PATH} ..
make
- name: Output
run: |
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
2 changes: 2 additions & 0 deletions tests/autotools/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
noinst_LIBRARIES = libmyproject.a
libmyproject_a_SOURCES = main.cpp
10 changes: 10 additions & 0 deletions tests/autotools/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AC_INIT([myproject], [1.0])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_SRCDIR([main.cpp])
AC_CONFIG_HEADERS([config.h])
AC_PROG_RANLIB

AC_PROG_CXX

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
5 changes: 5 additions & 0 deletions tests/autotools/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <iostream>

void print_hello() {
std::cout << "Hello, World!" << std::endl;
}
5 changes: 5 additions & 0 deletions tests/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.10)

project(myproject LANGUAGES CXX)

add_library(myproject OBJECT main.cpp)
5 changes: 5 additions & 0 deletions tests/cmake/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <iostream>

void print_hello() {
std::cout << "Hello, World!" << std::endl;
}

0 comments on commit 056cc67

Please sign in to comment.