Skip to content

Commit

Permalink
Set up GitHub workflow to run make
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed Apr 25, 2024
1 parent e6ee8c9 commit 641d117
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 24 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Make

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

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
continue-on-error: true # FIXME: remove when gcc build is passing
strategy:
fail-fast: false
matrix:
cc: [clang, gcc]
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: ${{ matrix.cc }} libbsd-dev libconfig-dev libmodbus-dev
- name: make with ${{ matrix.cc }}
run: env CC=${{ matrix.cc }} make
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: clang libbsd-dev libconfig-dev libmodbus-dev
- name: make lint
run: env CC=clang make lint
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
CC=clang
RM=rm -f
CC?=clang
#CC?=gcc
RM=rm -fv
CFLAGS=$(shell pkg-config --cflags libbsd libmodbus)
LIBS=$(shell pkg-config --libs libbsd libmodbus) -pthread

SRCS=src/epever.c src/*.h
SRCS=src/*

all: epever

epever: $(SRCS)
$(CC) $(CFLAGS) $(LIBS) -Wall -Werror -pedantic -O3 -o epever src/epever.c
$(CC) -v $(CFLAGS) $(LIBS) -Wall -Werror -O3 -o epever src/*.c

lint:
clang-format --verbose --Werror -i --style=file src/*
clang-tidy --checks='*,-altera-id-dependent-backward-branch,-altera-unroll-loops,-cert-err33-c,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-llvm-header-guard,-llvmlibc-restrict-system-libc-headers,-readability-function-cognitive-complexity' --format-style=llvm src/* -- $(CFLAGS)
clang-format --verbose --Werror -i --style=file $(SRCS)
clang-tidy --checks='*,-altera-id-dependent-backward-branch,-altera-unroll-loops,-cert-err33-c,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-llvm-header-guard,-llvmlibc-restrict-system-libc-headers,-readability-function-cognitive-complexity' --format-style=llvm $(SRCS) -- $(CFLAGS)
.PHONY: lint

clean:
Expand Down
34 changes: 17 additions & 17 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ set -euxo pipefail

cd "$(dirname "$0")"

target="${1:-epever}"
interactive="${2:-}"
container=${target}-builder
channel="${1:-stable}" # can be overriden with "bullseye" for example
target=epever
container=${target}-builder-${channel}
volume=/root/HOST
channel=stable
cc=clang

if [ -z "${FAST:-}" ]; then
docker pull debian:${channel}
docker pull "debian:${channel}"

[ "$(docker ps -qaf "name=${container}")" ] || docker run --name $container -d -t -v "${PWD}:${volume}" debian:${channel}
[ "$(docker ps -qaf "name=${container}")" ] || docker run --name "$container" --detach --tty --volume "${PWD}:${volume}" --network host "debian:${channel}"

docker start $container
docker start "$container"

docker exec $container dpkg --configure -a
docker exec $container bash -c "echo \"deb http://ftp.sg.debian.org/debian ${channel} main\" | tee /etc/apt/sources.list"
docker exec $container apt-get update
docker exec $container apt-get upgrade -y
docker exec $container apt-get install -y make clang pkg-config
docker exec $container apt-get install -y libbsd-dev libmodbus-dev
docker exec $container apt-get autoremove -y --purge
docker exec "$container" dpkg --configure -a
docker exec "$container" apt-get update
docker exec "$container" apt-get upgrade -y
docker exec "$container" apt-get install -y $cc
docker exec "$container" apt-get install -y make pkg-config
docker exec "$container" apt-get install -y libbsd-dev libmodbus-dev
docker exec "$container" apt-get autoremove -y --purge
fi

docker exec --workdir "${volume}" $container rm -fv $target
docker exec --workdir "${volume}" $container make $target
docker exec --workdir "${volume}" $container ls -l $target
docker exec --workdir "${volume}" "$container" rm -fv $target
docker exec --workdir "${volume}" "$container" env CC=$cc make $target
docker exec --workdir "${volume}" "$container" ls -l $target

0 comments on commit 641d117

Please sign in to comment.