Skip to content

Commit

Permalink
Merge pull request #350 from SimonKagstrom/issue-345-github-actions
Browse files Browse the repository at this point in the history
Issue #345: Use github actions as CI
  • Loading branch information
SimonKagstrom authored Jan 1, 2021
2 parents afac849 + 222bc74 commit 6b10a1b
Show file tree
Hide file tree
Showing 22 changed files with 308 additions and 124 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [SimonKagstrom]
9 changes: 9 additions & 0 deletions .github/workflows/ci-run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

run () {
tests/tools/run-tests build/src/kcov /tmp/ build-tests/ `pwd` -v || exit 64
}

run "$@"
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI
on: [push, pull_request]

jobs:
build-linux:
name: Build and test Linux executable
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, armv7, aarch64, ppc64le]

steps:
- uses: actions/checkout@v2

- name: Prepare
run: chmod u+x .github/workflows/*.sh

- name: Build for matrix.arch == amd64
if: ${{ matrix.arch == 'amd64' }}
run: |
sudo .github/workflows/generic-build.sh ${{ matrix.arch }}
sudo .github/workflows/ci-run-tests.sh ${{ matrix.arch }}
wget https://codecov.io/bash || true
bash bash -s /tmp/kcov-kcov || true
- name: Build for matrix.arch == i386
if: ${{ matrix.arch == 'i386' }}
run: |
chmod u+x ./.github/workflows/setup-i386.sh
sudo .github/workflows/setup-i386.sh
sudo schroot -c mychroot -- ./.github/workflows/generic-build.sh ${{ matrix.arch }}
sudo .github/workflows/ci-run-tests.sh ${{ matrix.arch }}
- name: Build for matrix.arch == armv7, aarch64, ppc64le
if: ${{ matrix.arch == 'armv7' || matrix.arch == 'aarch64' || matrix.arch == 'ppc64le' }}
uses: uraimo/run-on-arch-action@v1.0.9
with:
architecture: ${{ matrix.arch }}
distribution: ubuntu18.04
run: |
.github/workflows/generic-build.sh ${{ matrix.arch }}
build-osx:
name: Build and test OSX executable
runs-on: macOS-latest
env:
CC: clang
CXX: clang++

steps:
- uses: actions/checkout@v2

- name: Prepare
run: |
chmod u+x .github/workflows/osx-build.sh .github/workflows/ci-run-tests.sh
brew install zlib bash cmake pkgconfig python@3.9 openssl@1.1
- name: Build for OSX
run: |
sudo .github/workflows/osx-build.sh
sudo .github/workflows/ci-run-tests.sh
build-freebsd:
runs-on: macos-latest
name: Build and test FreeBSD executable
steps:
- uses: actions/checkout@v2
- name: FreeBSD
id: test
uses: vmactions/freebsd-vm@v0.0.9
with:
usesh: true
sync: rsync
prepare: pkg install -y binutils cmake elfutils python bash git
run: |
chmod u+x .github/workflows/freebsd-build.sh .github/workflows/ci-run-tests.sh
.github/workflows/freebsd-build.sh x86_64
.github/workflows/ci-run-tests.sh
19 changes: 19 additions & 0 deletions .github/workflows/freebsd-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

run () {
export PATH="${PATH}:${HOME}/kcov/bin"
mkdir build build-tests
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. || exit 64
make || exit 64
make install || exit 64
cd ..
cd build-tests
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../tests || exit 64
make || exit 64
cd ..
}

run "$@"
20 changes: 18 additions & 2 deletions .github/workflows/generic-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@
set -euo pipefail

run () {
DEB_ARCH=$1
EXTRA_PACKAGES=""
if [ "$DEB_ARCH" = "ppc64le" ]; then
DEB_ARCH="ppc64"
elif [ "$DEB_ARCH" = "armv7" ]; then
DEB_ARCH="armhf"
elif [ "$DEB_ARCH" = "aarch64" ]; then
DEB_ARCH="arm64"
else
EXTRA_PACKAGES="g++-multilib"
fi

apt-get update
apt-mark hold php* google* libobjc* libpq* libidn* postgresql* python-samba python3-httplib2 samba* >/dev/null
apt-get upgrade -y
apt-get install -y binutils-dev libcurl4-openssl-dev libdw-dev libiberty-dev gcc g++ make cmake libssl-dev git python python3
apt-get install -y binutils-dev libcurl4-openssl-dev libdw-dev libiberty-dev gcc g++ make cmake libssl-dev git python python3 $EXTRA_PACKAGES
export PATH="${PATH}:${HOME}/kcov/bin"
mkdir build
mkdir build build-tests
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. || exit 64
make || exit 64
make install || exit 64
cd ..
cd build-tests
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../tests || exit 64
make || exit 64
cd ..
tar czf kcov-"$1".tar.gz /usr/local/bin/kcov* /usr/local/share/doc/kcov/* /usr/local/share/man/man1/kcov.1
readelf -h /usr/local/bin/kcov
if [[ -e "kcov-$1.tar.gz" ]]; then
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/osx-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

run () {
export PATH="${PATH}:${HOME}/kcov/bin"
mkdir build build-tests
cd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCMAKE_INSTALL_PREFIX=/usr/local .. || exit 64
make || exit 64
make install || exit 64
cd ..
cd build-tests
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../tests || exit 64
make || exit 64
cd ..
}

run "$@"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Release
on:
push:
tags:
Expand All @@ -16,26 +16,31 @@ jobs:
- uses: actions/checkout@v2

- name: Prepare
run: chmod u+x .github/workflows/generic-build.sh
run: chmod u+x .github/workflows/generic-build.sh .github/workflows/ci-run-tests.sh

- name: Build for matrix.arch == amd64
if: ${{ matrix.arch == 'amd64' }}
run: sudo .github/workflows/generic-build.sh ${{ matrix.arch }}
run: |
sudo .github/workflows/generic-build.sh ${{ matrix.arch }}
sudo .github/workflows/ci-run-tests.sh ${{ matrix.arch }}
- name: Build for matrix.arch == i386
if: ${{ matrix.arch == 'i386' }}
run: |
chmod u+x ./.github/workflows/setup-i386.sh
sudo .github/workflows/setup-i386.sh
sudo schroot -c mychroot -- ./.github/workflows/generic-build.sh ${{ matrix.arch }}
sudo schroot -c mychroot -- ./.github/workflows/ci-run-tests.sh ${{ matrix.arch }}
- name: Build for matrix.arch == armv7, aarch64, ppc64le
if: ${{ matrix.arch == 'armv7' || matrix.arch == 'aarch64' || matrix.arch == 'ppc64le' }}
uses: uraimo/run-on-arch-action@v1.0.9
with:
architecture: ${{ matrix.arch }}
distribution: ubuntu18.04
run: .github/workflows/generic-build.sh ${{ matrix.arch }}
run: |
.github/workflows/generic-build.sh ${{ matrix.arch }}
.github/workflows/ci-run-tests.sh ${{ matrix.arch }}
- uses: actions/upload-artifact@v2
with:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/unittest-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

run () {
export PATH="${PATH}:${HOME}/kcov/bin"
git submodule update --recursive --remote

mkdir build-ut
cd build-ut
cmake ../tests/unit-tests || exit 64
make || exit 64
./ut || exit 64
cd ..
}

run "$@"
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ before_install: make -f travis/Makefile prepare_environment

os:
- linux
# - osx

language: cpp
compiler:
- gcc
- clang


env:
Expand Down
34 changes: 20 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cmake_minimum_required (VERSION 2.8.4)
project (kcov-tests)

list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
include(TargetArch)
target_architecture(CMAKE_TARGET_ARCHITECTURES)
message(STATUS "Target architectures: ${CMAKE_TARGET_ARCHITECTURES}")

enable_language(ASM)

if (POLICY CMP0042)
Expand Down Expand Up @@ -111,7 +116,6 @@ set (daemon_SRCS
)

add_library(shared_library SHARED
shared-library/big-symbol.S
shared-library/solib.c
)

Expand Down Expand Up @@ -173,19 +177,21 @@ else (CMAKE_VERSION VERSION_LESS "2.8.9")
endif (CMAKE_VERSION VERSION_LESS "2.8.9")

if (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
add_executable(recursive-ptrace ${recursive-ptrace_SRCS})
add_custom_target (illegal-insn ALL
COMMAND "${CMAKE_C_COMPILER}"
-nostdlib
"${CMAKE_CURRENT_SOURCE_DIR}/assembly/illegal-insn.S"
-o "${CMAKE_CURRENT_BINARY_DIR}/illegal-insn"
)

add_custom_target (fork-32 ALL
COMMAND "${CMAKE_C_COMPILER}" -g -m32
"${CMAKE_CURRENT_SOURCE_DIR}/fork/fork.c"
-o "${CMAKE_CURRENT_BINARY_DIR}/fork-32"
)
if (CMAKE_TARGET_ARCHITECTURES STREQUAL "i386" OR CMAKE_TARGET_ARCHITECTURES STREQUAL "x86_64")
add_executable(recursive-ptrace ${recursive-ptrace_SRCS})
add_custom_target (illegal-insn ALL
COMMAND "${CMAKE_C_COMPILER}"
-nostdlib
"${CMAKE_CURRENT_SOURCE_DIR}/assembly/illegal-insn.S"
-o "${CMAKE_CURRENT_BINARY_DIR}/illegal-insn"
)

add_custom_target (fork-32 ALL
COMMAND "${CMAKE_C_COMPILER}" -g -m32
"${CMAKE_CURRENT_SOURCE_DIR}/fork/fork.c"
-o "${CMAKE_CURRENT_BINARY_DIR}/fork-32"
)
endif()
endif (NOT(CMAKE_SYSTEM_NAME STREQUAL "Darwin"))

add_custom_target(tests-stripped ALL
Expand Down
1 change: 1 addition & 0 deletions tests/daemon/test-issue31.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ int main() {
ofs << ++i << std::endl;
sleep(1);
}
printf("Over and out\n");
return 0;
}
2 changes: 1 addition & 1 deletion tests/daemon/test-script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

if [ $# -ne 3 ] ; then
echo "Usage: <kcov-binary> <out-dir> <program-to-run>"
Expand Down
9 changes: 0 additions & 9 deletions tests/shared-library/big-symbol.S

This file was deleted.

5 changes: 5 additions & 0 deletions tests/tools/bash.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import testbase
import os
import unittest
import platform
import sys
import parse_cobertura

class BashBase(testbase.KcovTestCase):
Expand Down Expand Up @@ -110,6 +112,8 @@ def runTest(self):
assert parse_cobertura.hitsPerLine(dom, "unitundertest.sh", 16) == 1

class bash_accumulate_changed_data(testbase.KcovTestCase):
# Not sure why, but for now...
@unittest.skipUnless(platform.machine() in ["x86_64", "i686", "i386"], "Only for x86")
def runTest(self):
self.setUp()
os.system("mkdir -p /tmp/test-kcov")
Expand Down Expand Up @@ -326,6 +330,7 @@ def runTest(self):
assert parse_cobertura.hitsPerLine(dom, "function-with-spaces.sh", 11) == 1

class bash_drain_stdout_without_return(testbase.KcovTestCase):
@unittest.skipIf(sys.platform.startswith("darwin"), "Not for OSX")
def runTest(self):
rv,o = self.do(testbase.kcov + " " + testbase.outbase + "/kcov " +
testbase.sources + "/tests/bash/long-output-without-return.sh",
Expand Down
Loading

0 comments on commit 6b10a1b

Please sign in to comment.