Skip to content

Commit

Permalink
Merge branch 'hostilefork-github-workflow'
Browse files Browse the repository at this point in the history
  • Loading branch information
phma committed Dec 29, 2024
2 parents 80ab3f7 + 19d72af commit 2ba6ac4
Show file tree
Hide file tree
Showing 21 changed files with 349 additions and 50 deletions.
242 changes: 242 additions & 0 deletions .github/workflows/linux-gcc-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
#
# File: %linux-gcc-build.yml
#
#=============================================================================#
#
# This does Linux builds on GitHub's Ubuntu container, using gcc.
#

name: Linux GCC


# When To Trigger Builds
#
on:
push:
branches: [
master, # for now do a linux build on every push to master
linux, # pushing to a branch called "linux" builds this
github-workflow # specifically pushing github-workflow branch
]
pull_request:
branches: [
master
]
workflow_dispatch: # Allows running this workflow manually from Actions tab


# Standardize to use bash on all platforms.
#
defaults:
run:
shell: bash


# Each "Job" runs in its own VM, and a workflow run is made up of one or more
# jobs that can run sequentially or in parallel.
#
jobs:
linux-gcc-build: # Name of this workflow's only job

# https://github.com/actions/virtual-environments#available-environments
#
# Building on older available Ubuntus means the GLIBC used by the EXE will
# run on newer Ubuntus. The reverse is not true.
#
runs-on: ubuntu-20.04


# Build Matrix (add as many permutations as desired)
#
strategy:
matrix:
include:
- rigorous: ON
build_type: Debug
sanitize: ON

- rigorous: ON
build_type: Release
sanitize: OFF


# Environment Variables
#
# (Proxy build matrix variables to environment variables so that behavior
# in script code used here doesn't need GitHub-Workflow-specific syntax)
#
env:
RIGOROUS: ${{ matrix.rigorous }}
BUILD_TYPE: ${{ matrix.build_type }}
SANITIZE: ${{ matrix.sanitize }}


# Steps are a sequence of tasks that will be executed within a single VM
# as part of the job.
#
steps: # (no indentatation needed below; so indent the minimum!)


#====# CHECKOUT STEPS #=====================================================#


# Checkout Action
#
# https://github.com/actions/checkout
#
- uses: actions/checkout@v4
with:
path: "bezitopo/"


# Portably Capture Git Hashes
#
- name: Grab Git Hash and Short Hash Into Environment Variables
run: |
cd bezitopo
git_commit="$(git show --format="%H" --no-patch)"
git_commit_short="$(git show --format="%h" --no-patch)"
echo "GIT_COMMIT=$git_commit" >> $GITHUB_ENV
echo "GIT_COMMIT_SHORT=$git_commit_short" >> $GITHUB_ENV
#====# TOOLCHAIN INSTALLATION STEPS #=======================================#


# Install Qt Libraries
#
# https://github.com/jurplel/install-qt-action
#
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: '5.15.2'
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
cache: 'true'
cache-key-prefix: 'install-qt-action'


# Install OpenGL Dependencies
#
# Mesa is an open-source implementation of the OpenGL specification for 3D
# graphics. GLU is the OpenGL Utility library, which includes higher-level
# drawing routines and support for NURBS (Non-Uniform Rational B-Splines)
#
- name: Install Mesa Common and GLU Libraries
run: |
sudo apt install mesa-common-dev libglu1-mesa-dev
# Show a little bit of sanity check information.
#
- name: Output System Information
run: |
echo "GCC version check:"
gcc -v
#====# BUILD STEPS #========================================================#


# Generate Makefile
#
# Note: Should not have to set -DCMAKE_PREFIX_PATH=<...> as the GitHub
# Action that installed Qt is supposed to set the enviornment correctly.
#
- name: Use CMake to Generate a makefile
run: |
mkdir build
cd build
cmake \
-DRIGOROUS=$RIGOROUS \
-DSANITIZE=$SANITIZE \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
../bezitopo/ # directory containing CMakeLists.txt
# Run Make
#
# At time of writing, 2 jobs is the most the GitHub Workflow runners do.
#
- name: Run Make
working-directory: build/
run: |
make -j 2
# https://github.com/actions/upload-artifact
#
- name: Optional Download of Build Files Before Tests
if: false # Change this to true to download a file
uses: actions/upload-artifact@v4
with:
name: downloaded-file-name.ext
path: build/some-file.ext


#====# TESTING STEPS #======================================================#

- name: Basic Smoke Test (Run Bezitopo and Exit)
working-directory: build/
run: |
echo "exit" | ./bezitopo
- name: Fetch Independence Park File From Website
working-directory: build/
run: |
curl -o topo0.asc http://bezitopo.org/topo0.asc
- name: Test Independence Park Processing Command
working-directory: build/
run: |
(echo "indpark"; echo "exit") | ./bezitopo
- name: Run Bezitest
if: false # !!! At time of writing, bezitest segfaults
working-directory: build/
run: |
./bezitest
#====# DEPLOY STEPS (TBD) #==================================================#

# !!! This is how you would do deployments of the build products to AWS if
# that were something you wanted to do.


# Configure AWS Credentials
#
# https://github.com/aws-actions/configure-aws-credentials
#
# This is disabled with `if: false`, but would be something along the
# lines of `if: github.ref = 'refs/heads/master`
#
- name: Configure AWS Credentials
if: false # disabled
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.YOUR_GITHUB_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.YOUR_GITHUB_AWS_SECRET_KEY }}
aws-region: us-east-1


# Upload Files to AWS
#
- name: Upload Files to AWS
if: false # disabled
run: |
cd build
NEW_NAME="bezitopo-${GIT_COMMIT_SHORT}${VARIATION}"
MIME_TYPE="" # e.g. "--content-type application/wasm"
local=bezitopo
lastpart=ci-builds/${NEW_NAME}
remote=s3://${AWS_S3_BUCKET_NAME}/$lastpart
aws s3 cp $local $remote $MIME_TYPE
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#Ignore backup files
*~
*.backup

# Ignore User's Visual Studio Code Configuration Files
.vscode/
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
-- Organize code into src/
- Tom Kacvinsky <tkacvins@gmail.com>
-- Apple Silicon testing
- Brian Dickens <brian@hostilefork.com>
-- Continuous integration and warning fixes

# Projections
- Pierre Abbat <phma@bezitopo.org>
Expand Down
46 changes: 44 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.5.0)
project(bezitopo)
cmake_minimum_required(VERSION 3.1.0)

# Copyright 2012-2022,2024 Pierre Abbat.
# Copyright 2020 звездочёт.
# This file is part of Bezitopo.
Expand Down Expand Up @@ -42,6 +43,47 @@ set(FUZZ none)
#Setting FUZZ to boldatni disables reading all geoid formats except boldatni
#in convertgeoid and disables the boldatni magic string check.

# To build with Address Sanitizer: cmake -DSANITIZE=ON <...>
# The build products are slower and bigger, but run faster than using Valgrind.
# See: https://clang.llvm.org/docs/AddressSanitizer.html
#
option(SANITIZE "Enable AddressSanitizer" OFF)
if (SANITIZE)
message(STATUS "AddressSanitizer enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
endif()

# To enable rigorous compilation settings: cmake -DRIGOROUS=ON <...>
# This converts all warnings to errors and raises the compiler warning levels.
# Some useful warnings are disabled pending review of stylistic choices
#
option(RIGOROUS "Enable rigorous compilation settings" OFF)
if (RIGOROUS)
message(STATUS "Rigorous compilation settings enabled")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic")
set(DISABLED_WARNINGS
-Wno-sign-compare
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-but-set-variable
-Wno-overloaded-virtual
-Wno-parentheses
-Wno-empty-body
-Wno-implicit-fallthrough
-Wno-maybe-uninitialized # a bad one to disable!
-Wno-unused-result # also not good to turn off
)
foreach(WARNING ${DISABLED_WARNINGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING}")
endforeach()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
# TBD: MSVC warning disablements to get RIGOROUS working
endif ()
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Qt5 COMPONENTS Core Widgets Gui LinguistTools REQUIRED)
find_package(FFTW)
Expand Down Expand Up @@ -130,7 +172,7 @@ set(sourcelib src/angle.cpp
src/boundrect.cpp
src/breakline.cpp
src/circle.cpp
src/cogo.cpp
src/cogo.cpp
src/cogospiral.cpp
src/color.cpp
src/contour.cpp
Expand Down
13 changes: 7 additions & 6 deletions src/angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,13 @@ string radtoangle(double angle,int64_t unitp)
dig=angmult-base*trunc(angmult/base);
angmult=trunc(angmult/base);
sprintf(digit,(base>10)?"%02d":"%01d",dig);
if (base>10)
if (ret.substr(0,1)==".")
ret+=(prec>60)?"":"";
else
strcat(digit,(prec>60)?"":"");
ret=digit+ret;
if (base>10) {
if (ret.substr(0,1)==".")
ret+=(prec>60)?"":"";
else
strcat(digit,(prec>60)?"":"");
ret=digit+ret;
}
}
if (base>10)
ret=unitsign+ret;
Expand Down
2 changes: 1 addition & 1 deletion src/bezier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "rootfind.h"
using namespace std;

const char ctrlpttab[16]=
const unsigned char ctrlpttab[16]=
{
3, 3, 3, 3,
3, 3, 2, 4,
Expand Down
6 changes: 3 additions & 3 deletions src/bezitest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <csignal>
#include <cfloat>
#include <cstring>
#include <QTime>
#include <QElapsedTimer>
#include "config.h"
#include "point.h"
#include "cogo.h"
Expand Down Expand Up @@ -1923,7 +1923,7 @@ void testmanysum()
double odd[32];
long double oddl[32];
int pairtime=0;
QTime starttime;
QElapsedTimer starttime;
cout<<"manysum"<<endl;
for (i=0;i<32;i++)
oddl[i]=odd[i]=2*i+1;
Expand Down Expand Up @@ -2953,7 +2953,7 @@ void test1curly(double curvature,double clothance,PostScript &ps,array<int,3> &t
double curlyLength,tooCurlyLength,maxLength;
spiralarc s;
int i;
QTime starttime;
QElapsedTimer starttime;
const int niter=1000;
double lo=0,hi=1,mid;
BoundRect br;
Expand Down
Loading

0 comments on commit 2ba6ac4

Please sign in to comment.