Skip to content

Commit

Permalink
ci: Switch to GitHub Action (wip)
Browse files Browse the repository at this point in the history
Use ubuntu-18.04 to try to fix build errors

Error:

  time.c:88:28: error: conflicting types for ‘gettimeofday’
     88 | int RETRACE_IMPLEMENTATION(gettimeofday)(struct timeval *tv, struct timezone *tz)
        |                            ^~~~~~~~~~~~
  common.h:170:39: note: in definition of macro ‘RETRACE_IMPLEMENTATION’
    170 | #define RETRACE_IMPLEMENTATION(func) (func)
        |                                       ^~~~
  In file included from common.h:9,
                   from time.c:26:
  /usr/include/x86_64-linux-gnu/sys/time.h:66:12: note: previous declaration of ‘gettimeofday’ was here
     66 | extern int gettimeofday (struct timeval *__restrict __tv,
        |            ^~~~~~~~~~~~
  • Loading branch information
ribose-jeffreylau committed Dec 28, 2021
1 parent 7080097 commit 9a4a2d3
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 146 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/checkpatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Checkpatch

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up environment
run: |
echo CHECKPATCH_INSTALL="${HOME}/builds/checkpatch-install" >> "${GITHUB_ENV}"
./ci/before_install.sh
- name: Install more prerequisites
run: ./ci/install.sh checkpatch
- name: Check patch
run: ./ci/checkpatch.sh
45 changes: 45 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: macOS

on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'
- '.github/workflows/*.yml'
- '!.github/workflows/macos.yml'
pull_request:
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-10.15, macos-11.0]
if: "!contains(github.event.head_commit.message, 'skip ci')"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up environment
run: |
echo CMOCKA_INSTALL="${HOME}/builds/cmocka-install" >> "${GITHUB_ENV}"
- name: Install more prerequisites
run: |
./ci/before_install.sh
./ci/install.sh cmocka libnereon
- name: Configure
run: |
./autogen.sh
./configure --enable-tests
- name: Build
run: ./ci/main.sh
43 changes: 43 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Ubuntu

on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'
- '.github/workflows/*.yml'
- '!.github/workflows/ubuntu.yml'
pull_request:
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'

jobs:
build:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
if: "!contains(github.event.head_commit.message, 'skip ci')"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up environment
run: |
echo CMOCKA_INSTALL="${HOME}/builds/cmocka-install" >> "${GITHUB_ENV}"
- name: Install more prerequisites
run: |
./ci/before_install.sh
./ci/install.sh cmocka libnereon
- name: Configure
run: |
./autogen.sh
./configure --enable-tests
- name: Build
run: ./ci/main.sh
50 changes: 50 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Windows

on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'
- '.github/workflows/*.yml'
- '!.github/workflows/windows.yml'
pull_request:
paths-ignore:
- 'docs/**'
- '**.adoc'
- '**.md'

jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
if: "!contains(github.event.head_commit.message, 'skip ci')"

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: msys2/setup-msys2@v2
with:
path-type: inherit
- name: Set up environment
shell: msys2 {0}
run: |
echo CMOCKA_INSTALL="${HOME}/builds/cmocka-install" >> "${GITHUB_ENV}"
- name: Install more prerequisites
shell: msys2 {0}
run: |
./ci/before_install.sh
./ci/install.sh libnereon
- name: Configure
shell: msys2 {0}
run: |
./autogen.sh
./configure --enable-tests
- name: Build
shell: msys2 {0}
run: ./ci/main.sh
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

30 changes: 23 additions & 7 deletions ci/before_install.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

# https://gist.github.com/marcusandre/4b88c2428220ea255b83
get_os() {
if [ -z $OSTYPE ]; then
echo "$(uname | tr '[:upper:]' '[:lower:]')"
if [ -z "$OSTYPE" ]; then
uname
else
echo "$(echo $OSTYPE | tr '[:upper:]' '[:lower:]')"
fi
echo "$OSTYPE"
fi | tr '[:upper:]' '[:lower:]'
}

macos_install() {
Expand All @@ -24,9 +24,9 @@ macos_install() {
ruby
"
for p in ${packages}; do
brew install ${p} || brew upgrade ${p}
brew install "${p}" || brew upgrade "${p}"
done
mkdir -p ${CMOCKA_INSTALL}
mkdir -p "${CMOCKA_INSTALL}"
gem install mustache
}

Expand All @@ -53,6 +53,20 @@ netbsd_install() {
}

linux_install() {
sudo gem install mustache
}

msys_install() {
packages=(
automake
mingw-w64-x86_64-cmocka
mingw64/mingw-w64-x86_64-ninja
mingw64/mingw-w64-x86_64-cmake
mingw64/mingw-w64-x86_64-graphviz # for doxygen's dot component
openssl-devel
doxygen
)
pacman --noconfirm -S --needed "${packages[@]}"
gem install mustache
}

Expand All @@ -72,6 +86,8 @@ main() {
macos_install ;;
linux*)
linux_install ;;
msys*)
msys_install ;;
*) echo "unknown"; exit 1 ;;
esac

Expand Down
84 changes: 49 additions & 35 deletions ci/checkpatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,63 @@ set -eu
CHECKPATCH=$CHECKPATCH_INSTALL/checkpatch.pl
CHECKPATCH_TYPEDEFS=$CHECKPATCH_INSTALL/typedefs.checkpatch

CHECKPATCH_FLAGS+=" --no-tree"
CHECKPATCH_FLAGS+=" --ignore COMPLEX_MACRO"
CHECKPATCH_FLAGS+=" --ignore TRAILING_SEMICOLON"
CHECKPATCH_FLAGS+=" --ignore LONG_LINE"
CHECKPATCH_FLAGS+=" --ignore LONG_LINE_STRING"
CHECKPATCH_FLAGS+=" --ignore LONG_LINE_COMMENT"
CHECKPATCH_FLAGS+=" --ignore SYMBOLIC_PERMS"
CHECKPATCH_FLAGS+=" --ignore NEW_TYPEDEFS"
CHECKPATCH_FLAGS+=" --ignore SPLIT_STRING"
CHECKPATCH_FLAGS+=" --ignore USE_FUNC"
CHECKPATCH_FLAGS+=" --ignore COMMIT_LOG_LONG_LINE"
CHECKPATCH_FLAGS+=" --ignore FILE_PATH_CHANGES"
CHECKPATCH_FLAGS+=" --ignore MISSING_SIGN_OFF"
CHECKPATCH_FLAGS+=" --ignore RETURN_PARENTHESES"
CHECKPATCH_FLAGS+=" --ignore STATIC_CONST_CHAR_ARRAY"
CHECKPATCH_FLAGS+=" --ignore ARRAY_SIZE"
CHECKPATCH_FLAGS+=" --ignore NAKED_SSCANF"
CHECKPATCH_FLAGS+=" --ignore SSCANF_TO_KSTRTO"
CHECKPATCH_FLAGS+=" --ignore EXECUTE_PERMISSIONS"
CHECKPATCH_FLAGS+=" --ignore MULTISTATEMENT_MACRO_USE_DO_WHILE"
CHECKPATCH_FLAGS+=" --ignore STORAGE_CLASS"
CHECKPATCH_FLAGS+=" --ignore SPDX_LICENSE_TAG"
CHECKPATCH_FLAGS+=" --ignore PREFER_ALIGNED"
CHECKPATCH_FLAGS+=" --ignore EMAIL_SUBJECT"
CHECKPATCH_FLAGS=(
--no-tree
--ignore COMPLEX_MACRO
--ignore TRAILING_SEMICOLON
--ignore LONG_LINE
--ignore LONG_LINE_STRING
--ignore LONG_LINE_COMMENT
--ignore SYMBOLIC_PERMS
--ignore NEW_TYPEDEFS
--ignore SPLIT_STRING
--ignore USE_FUNC
--ignore COMMIT_LOG_LONG_LINE
--ignore FILE_PATH_CHANGES
--ignore MISSING_SIGN_OFF
--ignore RETURN_PARENTHESES
--ignore STATIC_CONST_CHAR_ARRAY
--ignore ARRAY_SIZE
--ignore NAKED_SSCANF
--ignore SSCANF_TO_KSTRTO
--ignore EXECUTE_PERMISSIONS
--ignore MULTISTATEMENT_MACRO_USE_DO_WHILE
--ignore STORAGE_CLASS
--ignore SPDX_LICENSE_TAG
--ignore PREFER_ALIGNED
--ignore EMAIL_SUBJECT
)

# checkpatch.pl will ignore the following paths
CHECKPATCH_IGNORE+=" checkpatch.pl.patch Makefile test/Makefile test/http.redirect/hello.txt src/v2/parson.c src/v2/parson.h *.json"
CHECKPATCH_EXCLUDE=$(for p in $CHECKPATCH_IGNORE; do echo ":(exclude)$p" ; done)
CHECKPATCH_IGNORE=(checkpatch.pl.patch Makefile test/Makefile test/http.redirect/hello.txt src/v2/parson.c src/v2/parson.h "*.json")
CHECKPATCH_EXCLUDE=("${CHECKPATCH_IGNORE[@]/#/":(exclude)"}")

function _checkpatch() {
$CHECKPATCH $CHECKPATCH_FLAGS --typedefsfile=$CHECKPATCH_TYPEDEFS --no-tree -
_checkpatch() {
"$CHECKPATCH" "${CHECKPATCH_FLAGS[@]}" "--typedefsfile=$CHECKPATCH_TYPEDEFS" --no-tree -
}

function checkpatch() {
git show --oneline --no-patch $1
git format-patch -1 $1 --stdout -- $CHECKPATCH_EXCLUDE . | _checkpatch
checkpatch() {
local commit="${1:?Missing commit}"
git show --oneline --no-patch "${commit}"
git format-patch -1 "${commit}" --stdout -- "${CHECKPATCH_EXCLUDE[@]}" . | _checkpatch
}

# checkpatch
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
#
# Check HEAD for pull requests.
#
# NOTE: $GITHUB_HEAD_REF is only set for pull requests.
# See: https://docs.github.com/en/actions/learn-github-actions/environment-variables
if [[ -z "${GITHUB_HEAD_REF:-}" ]]; then
checkpatch HEAD

# XXX: HEAD^2 seems to only makes sense for merge commits
elif git show --format=short | head -n2 | grep -q ^Merge:
then
while read -r c; do
checkpatch "$c"
done < <(git rev-list HEAD^1..HEAD^2)
else
for c in $(git rev-list HEAD^1..HEAD^2); do
checkpatch $c
done
>&2 echo "Warning: this should not be run."
exit 1
fi
1 change: 0 additions & 1 deletion ci/env-freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export PATH=/usr/local/bin:$PATH
export MD5SUM=/sbin/md5sum
export CMOCKA_INSTALL=$(pwd)/builds/cmocka-install
export CHECKPATCH_INSTALL=$(pwd)/builds/checkpatch-install
export TRAVIS_PULL_REQUEST="true"
1 change: 0 additions & 1 deletion ci/env-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export PATH=/usr/local/bin:$PATH
export MD5SUM=/sbin/md5
export CMOCKA_INSTALL=$(pwd)/builds/cmocka-install
export CHECKPATCH_INSTALL=$(pwd)/builds/checkpatch-install
export TRAVIS_PULL_REQUEST="true"
3 changes: 1 addition & 2 deletions ci/env-openbsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export PATH=/usr/local/bin:$PATH
export MD5SUM=/bin/md5
export CMOCKA_INSTALL=$(pwd)/builds/cmocka-install
export CHECKPATCH_INSTALL=$(pwd)/builds/checkpatch-install
export TRAVIS_PULL_REQUEST="true"
export AUTOCONF_VERSION=2.69
export AUTOMAKE_VERSION=1.15
export AUTOMAKE_VERSION=1.15
Loading

0 comments on commit 9a4a2d3

Please sign in to comment.