Skip to content

Commit

Permalink
More fixes, initial Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Feb 1, 2024
1 parent 541a7d7 commit 0ce00d0
Show file tree
Hide file tree
Showing 62 changed files with 1,913 additions and 857 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on: [push, pull_request ]
paths:
- 'src/**'
- 'include/**'
- 'tools/src/**'
- 'Makefile'
- '*.mk'
- '.github/workflows/build.yml'

jobs:
build:
name: Build libraries

runs-on: ubuntu-latest
env:
CC: gcc
steps:
- uses: actions/checkout@v3

- name: Build static library
run: make static

- name: Build shared library
run: make shared

- name: Generate CIO locator data
run: make cio_file



24 changes: 24 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: cppcheck

on: [push, pull_request ]
paths:
- 'src/**'
- 'include/**'
- 'Makefile'
- '*.mk'
- '.github/workflows/check.yml'

jobs:

cppcheck:
name: Check source code

runs-on: ubuntu-latest
env:
CC: gcc
steps:

- uses: actions/checkout@v3

- name: Run cppcheck
run: make check
29 changes: 29 additions & 0 deletions .github/workflows/dox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: API documentation

on: [push, pull_request ]
paths:
- 'src/**'
- 'include/**'
- 'css/**'
- 'Doxyfile'
- '.github/workflows/dox.yml'

apidocs:
name: Update API documentation

runs-on: ubuntu-latest
env:
CC: gcc
steps:

- uses: actions/checkout@v3

- name: About this workflow...
run: |
echo github.event_name = ${{ github.event_name }}
echo github.repository_owner = ${{ github.repository_owner }}
echo github.ref_name = ${{ github.ref_name }}
- name: Run doxygen
run: make dox

38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test

on: [push, pull_request ]
paths:
- 'src/**'
- 'include/**'
- 'test/src/**'
- 'test/reference/**'
- 'Makefile'
- '*.mk'
- '.github/workflows/test.yml'

jobs:
test:
name: Test and coverage

runs-on: ubuntu-latest
env:
CC: gcc
steps:

- uses: actions/checkout@v3

- name: Run regression tests
run: make test

- name: Generate coverage data
run: make coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
continue-on-error: true
with:
fail_ci_if_error: false
flags: unittests
name: codecov
verbose: true

153 changes: 31 additions & 122 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,103 +1,19 @@
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

SRC = $(PROJECT_ROOT)src
INC = $(PROJECT_ROOT)include

# Compiler options
CFLAGS = -I$(INC) -Os -Wall -Wextra

# For maximum compatibility with NOVAS C 3.1, uncomment the line below
#CFLAGS += -DCOMPAT=1

# Whether to build into the library specific versions of solarsystem()
#BUILTIN_SOLSYS1 = 1
#BUILTIN_SOLSYS2 = 1
BUILTIN_SOLSYS3 = 1

# Compile library with a default solarsystem() implementation, which will be used
# only if the application does not define another implementation via calls to the
# to set_solarsystem() type functions.
DEFAULT_SOLSYS = 3

# Compile library with a default readeph() implementation, which will be used
# only if the application does not define another implementation via calls to the
# to set_ephem_reader() function.
DEFAULT_READEPH = readeph0

# Compiler and linker options etc.
ifeq ($(BUILD_MODE),debug)
CFLAGS += -g
else ifeq ($(BUILD_MODE),run)
CFLAGS += -O2
else ifeq ($(BUILD_MODE),test)
CFLAGS += -O0 -g -pg -fprofile-arcs -ftest-coverage
LDFLAGS += -pg -fprofile-arcs -ftest-coverage
endif

# cppcheck options
CHECKOPTS = --enable=performance,warning,portability,style --language=c --std=c90 --error-exitcode=1


# ===============================================================================
# END of user config section, below is some logic and recipes only.
# WARNING! You should leave this Makefile alone probably
# To configure the build, you can edit config.mk
# ===============================================================================

include config.mk

ifeq ($(DEFAULT_SOLSYS), 1)
BUILTIN_SOLSYS1 = 1
CFLAGS += -DDEFAULT_SOLSYS=1
endif

ifeq ($(DEFAULT_SOLSYS), 2)
BUILTIN_SOLSYS2 = 1
CFLAGS += -DDEFAULT_SOLSYS=2
endif

ifeq ($(DEFAULT_SOLSYS), 3)
BUILTIN_SOLSYS3 = 1
CFLAGS += -DDEFAULT_SOLSYS=3
endif

SOURCES = $(SRC)/novas.c $(SRC)/nutation.c

ifeq ($(BUILTIN_SOLSYS1), 1)
SOURCES += $(SRC)/solsys1.c $(SRC)/eph_manager.c
CFLAGS += -DBUILTIN_SOLSYS1=1
endif

ifeq ($(BUILTIN_SOLSYS2), 1)
SOURCES += $(SRC)/solsys2.c
CFLAGS += -DBUILTIN_SOLSYS2=1
endif

ifeq ($(BUILTIN_SOLSYS3), 1)
SOURCES += $(SRC)/solsys3.c
CFLAGS += -DBUILTIN_SOLSYS3=1
endif

ifdef (DEFAULT_READEPH)
SOURCES += $(SRC)/$(DEFAULT_READEPH).c
CFLAGS += -DDEFAULT_READEPH=1
endif

OBJECTS := $(subst $(SRC),obj,$(SOURCES))
OBJECTS := $(subst .c,.o,$(OBJECTS))


# ===============================================================================
# Targets ans recipes below...
# Specific build targets and recipes below...
# ===============================================================================



# You can set the default CIO locator file to use depending on where you installed it.
# By default, the library will assume '/usr/share/novas/cio_ra.bin', or simply 'cio_ra.bin'
# if the COMPAT flag is set to a nonzero value (above). Some other good locations
# for this file may be in '/usr/local/share/novas', or '/opt/share/novas' for system-wide
# availability, or in '$(HOME)/.local/share/novas' for user-specific installation.
#
#CFLAGS += -DDEFAULT_CIO_LOCATOR_FILE="/user/share/novas/cio_ra.bin"

.PHONY: all
all: static shared dox

Expand All @@ -116,41 +32,34 @@ lib/novas.a: $(OBJECTS) | lib
lib/novas.so: $(SOURCES) | lib
$(CC) -o $@ $(CFLAGS) $^ -shared -fPIC

# Regular object files
obj/%.o: $(SRC)/%.c dep/%.d obj Makefile
$(CC) -o $@ -c $(CFLAGS) $<
# CIO locator data
.PHONY: cio_file
cio_file:
make -C tools cio_file

.PHONY: tools
tools:
make -C tools

# Create sub-directories for build targets
dep obj lib apidoc:
mkdir $@
.PHONY: test
test: tools
make -C test run

.PHONY: coverage
coverage: test
make -C test coverage

# Remove intermediate files
.PHONY: clean
clean:
rm -rf obj dep

# Remove all locally built files, effectively restoring the repo to its pristine state
.PHONY: distclean
distclean: clean
rm -rf lib apidoc

# Static code analysis using 'cppcheck'
.PHONY: check
check:
@echo " [check]"
@cppcheck -Iinclude $(CHECKOPTS) src

# Doxygen documentation (HTML and man pages) under apidocs/
.PHONY: dox
dox: $(SRC) $(INC) README.md | apidoc
@echo " [doxygen]"
@doxygen

# Automatic dependence on included header files.
.PRECIOUS: dep/%.d
dep/%.d: $(SRC)/%.c dep
@echo " > $@" \
&& $(CC) -I$(INC) -MM -MG $< > $@.$$$$ \
&& sed 's|\w*\.o[ :]*| obj/&|g' < $@.$$$$ > $@; \
rm -f $@.$$$$
@make -C tools clean
@make -C test clean

distclean:
@make -C tools clean
@make -C test clean


# ===============================================================================
# Generic targets and recipes below...
# ===============================================================================

include $(PROJECT_ROOT)/build.mk
53 changes: 53 additions & 0 deletions build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# ===============================================================================
# Generic build targets and recipes.
# You can include this in your Makefile
# ===============================================================================


# Regular object files
obj/%.o: $(SRC)/%.c dep/%.d obj Makefile
$(CC) -o $@ -c $(CFLAGS) $<

# Create sub-directories for build targets
dep obj lib bin apidoc:
mkdir $@

# Remove intermediate files locally
.PHONY: clean-local
clean-local:
rm -rf obj dep

# Remove all locally built files, effectively restoring the repo to its pristine state
.PHONY: distclean-local
distclean-local: clean-local
rm -rf bin lib apidoc

# Remove intermediate files (general)
.PHONY: clean
clean: clean-local

# Remove intermediate files (general)
.PHONY: distclean
distclean: distclean-local

# Static code analysis using 'cppcheck'
.PHONY: check
check:
@echo " [check]"
@cppcheck -I$(INC) $(CHECKOPTS) src

# Doxygen documentation (HTML and man pages) under apidocs/
.PHONY: dox
dox: $(SRC) $(INC) README.md | apidoc
@echo " [doxygen]"
@doxygen

# Automatic dependence on included header files.
.PRECIOUS: dep/%.d
dep/%.d: $(SRC)/%.c dep
@echo " > $@" \
&& $(CC) -I$(INC) -MM -MG $< > $@.$$$$ \
&& sed 's|\w*\.o[ :]*| obj/&|g' < $@.$$$$ > $@; \
rm -f $@.$$$$

27 changes: 27 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
codecov:
require_ci_to_pass: no

coverage:
precision: 2
round: down
status:
patch: off
project:
default:
target: auto
threshold: 0.1%
removed_code_behavior: adjust_base

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no

Loading

0 comments on commit 0ce00d0

Please sign in to comment.