Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to Automatically Create Releases #202

Merged
merged 108 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
26553ce
Add Github Actions workflow
Wind1337 Feb 22, 2024
33dc2eb
Actions: Create new release on push to main
Wind1337 Mar 9, 2024
a57e18a
Actions: Deploy binary to go-cart server
Wind1337 Mar 12, 2024
f8ca81b
[skip ci] Disable deploy to go-cart
Wind1337 Mar 12, 2024
5fd9418
Enable deployment
Wind1337 Mar 22, 2024
bc8ddb7
[skip ci] Actions: Update dependencies to compile binary
Wind1337 Mar 26, 2024
b644670
Merge branch 'main' of https://github.com/mgastner/cartogram-cpp
Wind1337 Mar 26, 2024
926127e
Actions: Test macos build
Wind1337 Apr 3, 2024
4c2586a
Fix compilation errors on Ubuntu
Wind1337 Apr 23, 2024
d6aef50
actions: Remove macos build workflow
Wind1337 Apr 23, 2024
7acc9ca
actions: Update dependencies and disable auto releases
Wind1337 Apr 23, 2024
f735abc
actions: Re-enable release, change versioning system
Wind1337 Apr 23, 2024
6826d46
[skip ci] Enable binary deployment
Wind1337 Jun 16, 2024
65305d9
Merge branch 'main' into pr/adisidev/201
adisidev Sep 25, 2024
72530da
Increase `cmake_minimum_required` version
adisidev Sep 25, 2024
80eda89
Make `CMakeLists.txt` compatible with macOS
adisidev Sep 25, 2024
234b06c
Make `CMakeLists.txt` as similar to `main` as possible
adisidev Sep 25, 2024
419a919
Add the `mole`: one line causing the error
adisidev Sep 25, 2024
19688af
Make matplot++ conditional (temporary fix)
adisidev Sep 26, 2024
d003e8e
Separate build into configure and build step
adisidev Sep 26, 2024
46289c0
Remove CORES variable, add -j$(nproc)
adisidev Sep 26, 2024
5535336
Add "pr/adisidev/201" branch to run
adisidev Sep 26, 2024
b40bd79
Make cairo lowercase, so it works on ubuntu
adisidev Sep 26, 2024
ee5c482
Cache apt packages
adisidev Sep 26, 2024
88cea22
Fix cmake build command
adisidev Sep 26, 2024
6ccd77c
Make CMakeLists.txt cross-compatible (ubunut / macos)
adisidev Sep 26, 2024
853320d
Update build.yml
adisidev Sep 26, 2024
513a991
Write _input.geojson after storing original geodivs
adisidev Oct 9, 2024
27a9416
Merge pull request #203 from mgastner/fix-O-flag
adisidev Oct 9, 2024
7ea73f5
Separate build and deploy workflows
adisidev Oct 9, 2024
2d1b166
Change new_tag to short_sha
adisidev Oct 9, 2024
5f2201a
Update csv.hpp from vincentlaucsb/csv-parser
adisidev Oct 10, 2024
a2209d4
Moved csv.hpp to include folder
adisidev Oct 10, 2024
551873d
Remove MSVC conditions, we don't support MSVC
adisidev Oct 10, 2024
7a1bfbc
Remove Matplot++ dependency
adisidev Oct 10, 2024
d925bbc
Add SYSTEM property to external libraries
adisidev Oct 10, 2024
5688ac0
Update installation instructions, and fix CMake bug
adisidev Oct 10, 2024
234d9ba
Update `target_include_directories` based on SO post
adisidev Oct 10, 2024
0e80c40
More updates based on SO post. Thank you!
adisidev Oct 10, 2024
c9dff97
Run build.yml only on main
adisidev Oct 10, 2024
2eefaec
Add CGAL as a submodule
adisidev Oct 11, 2024
a4b08b1
Switch to previous major CGAL release
adisidev Oct 11, 2024
034b04c
Move csv.hpp to external
adisidev Oct 11, 2024
ab8c45c
cgal --> CGAL
adisidev Oct 11, 2024
61f79a3
Revert "cgal --> CGAL"
adisidev Oct 11, 2024
36c9bd4
Direct CMake to local CGAL, not system CGAL
adisidev Oct 11, 2024
6feb768
Update instructions to not install CGAL
adisidev Oct 11, 2024
4002a09
Update build.yml to mirror README.md
adisidev Oct 11, 2024
51cdb4a
Add instruction to use `--recurse-submodules`
adisidev Oct 11, 2024
8e03a6d
Merge pull request #207 from mgastner/make-cgal-version-static
adisidev Oct 11, 2024
c729236
Add branch as trigger for testing
adisidev Oct 11, 2024
132624a
Split adpt update and add-apt-repo commands
adisidev Oct 11, 2024
58d0619
Cache dependencies
adisidev Oct 11, 2024
8742ee0
Don't output new_tag to GITHUB_OUTPUT
adisidev Oct 11, 2024
8480a9a
Change CGAL_DIR
adisidev Oct 11, 2024
23f1b61
Update CMAKE_PREFIX_PATH
adisidev Oct 11, 2024
e1cab29
Add submodules: 'recursive' property to action
adisidev Oct 11, 2024
c952414
Add CGAL dependencies to build.yml
adisidev Oct 11, 2024
dad1a53
Revert "Don't output new_tag to GITHUB_OUTPUT"
adisidev Oct 11, 2024
9c462a2
Update apt-requirements.txt
adisidev Oct 11, 2024
89e0ceb
Update cmake version requirement
adisidev Oct 11, 2024
356022d
Change apt cache version
adisidev Oct 11, 2024
fcc787f
Run github action on container
adisidev Oct 16, 2024
38e53b1
Share .vscode settings
adisidev Oct 16, 2024
37dc440
Add .geojson in write_geojson instead of main.cpp
adisidev Oct 17, 2024
788ffd1
Move external libraries to external folder
adisidev Oct 17, 2024
4420edb
Ignore all external libraries in vscode
adisidev Oct 17, 2024
ba8b62b
std::cerr --> std::cout
adisidev Oct 17, 2024
67191fa
Compile stdout before printing all at once at end
adisidev Oct 17, 2024
b85a2ca
Attempt run on docker container
adisidev Oct 17, 2024
3552779
Merge pull request #208 from mgastner/correct-stdout-json-output
adisidev Oct 17, 2024
c6630fc
Don't add ubuntu-toolchain-r/test
adisidev Oct 17, 2024
f9e146b
Install packages without xargs apt install -y
adisidev Oct 17, 2024
40022da
Change minimum required version of CMake to 3.25
adisidev Oct 17, 2024
580c1ed
Specify directory containing bin
adisidev Oct 17, 2024
31ec78c
Print working directory for docker
adisidev Oct 17, 2024
33aa3a8
Remove git --local tags
adisidev Oct 17, 2024
618ec49
Implement Copilot suggestions
adisidev Oct 18, 2024
e69302d
Reduce dependencies, don't fetch --tags
adisidev Oct 18, 2024
d2a7cd3
Track maximum progress reached
adisidev Oct 18, 2024
894ddeb
Always increment progress by minimum amount
adisidev Oct 18, 2024
d2b5223
Prevent progress bar from reaching 100 prematurely
adisidev Oct 18, 2024
e6d3982
Use dynamic progress increment
adisidev Oct 18, 2024
1b90bad
Temper progress bar at start, make buffer 0.75
adisidev Oct 18, 2024
c71c442
Fixes #175 and significantly improves pb smoothness
adisidev Oct 18, 2024
0159a91
Merge pull request #210 from mgastner/prevent-progress-bar-going-back…
adisidev Oct 18, 2024
fb56747
Update apt, remove "Figure out working directory" step
adisidev Oct 18, 2024
3f2aadd
Modify docker container environment in actions
adisidev Oct 18, 2024
30572a9
Change where .env is defined
adisidev Oct 18, 2024
8095809
Separate build and release job
adisidev Oct 18, 2024
e70c77e
Only output simplified and original version to stdout
nihalzp Oct 24, 2024
564e94b
Revert "Compile stdout before printing all at once at end"
adisidev Oct 24, 2024
4bf68ed
Explain meaning of processed as a comment
adisidev Oct 24, 2024
9e1e00e
Don't output to stdout by default
adisidev Oct 24, 2024
51524f7
Merge pull request #211 from mgastner/stdout-fix-pr
adisidev Oct 24, 2024
8450938
Allow bbox values below -1
adisidev Oct 24, 2024
00ca879
cast lx, ly to (int) to compare with bbox
adisidev Oct 24, 2024
c4b6752
Merge branch 'pr/adisidev/201' of https://github.com/mgastner/cartogr…
adisidev Oct 24, 2024
435b25d
Make cartogram --version equal to RELEASE_TAG
adisidev Oct 24, 2024
fea5c1b
Push tag before releasing
adisidev Oct 24, 2024
bd7f3c9
Use github-script to push tag, add -j4
adisidev Oct 24, 2024
d8f0675
Remove github script to push tag (warning msg)
adisidev Oct 29, 2024
623487f
Remove `uses: actions/github-script@v5`
adisidev Oct 29, 2024
e3e0bac
Moved deployment to go-cart-io/cartogram-docker
adisidev Nov 6, 2024
bb537f8
Add troubleshooting step about CGAL submodule
adisidev Nov 6, 2024
963e880
write_csv(): write current cartogram state as csv
adisidev Nov 6, 2024
c489c3e
Put outputting processed input behind flag
adisidev Nov 6, 2024
9377065
Make changes suggested by @nihalzp
adisidev Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build and Release (on GitHub only)

on:
# when a push is made to the main branch (like when a pull request is merged, or something is pushed directly)
workflow_dispatch:
push:
branches: [ "main" ]

env:
BUILD_TYPE: Release

jobs:

set-outputs:
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.vars.outputs.short_sha }}
steps:

- name: Checkout Repository
uses: actions/checkout@v4

- name: Calculate short_sha
id: vars
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

build-and-upload:

runs-on: ubuntu-latest
needs: set-outputs
container:
image: gocartio/cartogram-web:latest
steps:

- name: Install Dependencies
run: |
apt update -y
apt install -y git g++-11 build-essential cmake libboost-all-dev

- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRELEASE_TAG=${{ needs.set-outputs.outputs.short_sha }}

- name: Build
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install -j4 --

# - name: Run CTest
# working-directory: ${{github.workspace}}/build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{env.BUILD_TYPE}}

# - name: Run Stress Test
# run: |
# sudo make install -C build
# cd tests/
# chmod +x stress_test.sh
# bash stress_test.sh

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cartogram
path: /usr/local/bin/cartogram

release:

runs-on: ubuntu-latest
needs: [build-and-upload, set-outputs]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: cartogram

- name: Push tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ needs.set-outputs.outputs.short_sha }}
git push origin ${{ needs.set-outputs.outputs.short_sha }}

- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.set-outputs.outputs.short_sha }}
files: cartogram
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ cartogram
/*.geojson
/sample_data/*.geojson

# Ignore files generated by Visual Studio Code
.vscode

# Ignore DS_Store files created by macOS
**/.DS_Store
**/.cache*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/cgal"]
path = external/cgal
url = https://github.com/CGAL/cgal.git
78 changes: 78 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"files.associations": {
"__config": "cpp",
"__verbose_abort": "cpp",
"array": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdlib": "cpp",
"initializer_list": "cpp",
"limits": "cpp",
"numbers": "cpp",
"concepts": "cpp",
"algorithm": "cpp",
"type_traits": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"atomic": "cpp",
"deque": "cpp",
"hash_map": "cpp",
"forward_list": "cpp",
"ios": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"system_error": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"*.tcc": "cpp",
"any": "cpp",
"cmath": "cpp",
"cstdio": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"compare": "cpp",
"exception": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"utility": "cpp",
"format": "cpp",
"fstream": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"new": "cpp",
"ostream": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"__bit_reference": "cpp",
"__threading_support": "cpp",
"execution": "cpp"
},
"files.exclude": {
"**/external": true
}
}
76 changes: 45 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.27)
cmake_minimum_required(VERSION 3.25)

if(UNIX AND NOT APPLE)
set(CMAKE_CXX_COMPILER "g++-11")
endif()

project(cartogram LANGUAGES CXX)

# ========== Project Setup ==========
Expand All @@ -7,52 +12,61 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Assume development build by default
set(RELEASE_TAG "development" CACHE STRING "Release tag for the build")

# Default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()

# ========== Dependencies Setup ==========

# Direct CMake to local CGAL installation
set(CGAL_DIR ${PROJECT_SOURCE_DIR}/external/cgal)
find_package(CGAL REQUIRED)

# Boost
find_package(Boost REQUIRED COMPONENTS unit_test_framework)

# Matplot++
find_package(Matplot++ REQUIRED)

# PkgConfig, fftw, and cairo
find_package(PkgConfig REQUIRED)
pkg_search_module(fftw REQUIRED fftw3 IMPORTED_TARGET)
pkg_search_module(CAIRO REQUIRED CAIRO IMPORTED_TARGET)
pkg_search_module(cairo REQUIRED cairo IMPORTED_TARGET)

# ========== Source Files ==========
file(GLOB_RECURSE CARTOGRAM_SOURCES "src/*.cpp")
add_executable(cartogram ${CARTOGRAM_SOURCES})

target_compile_definitions(cartogram PRIVATE RELEASE_TAG="${RELEASE_TAG}")

# ========== Include Directories ==========
target_include_directories(cartogram PUBLIC
${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
PkgConfig::fftw
PkgConfig::CAIRO
target_include_directories(cartogram
PUBLIC
${PROJECT_SOURCE_DIR}/include
)

target_include_directories(cartogram
SYSTEM PUBLIC
${CGAL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/external
)

# ========== Compile Options ==========
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(cartogram PRIVATE -isystem ${Boost_INCLUDE_DIRS})
target_compile_options(cartogram PRIVATE -ffp-contract=off)
elseif(MSVC)
target_compile_options(cartogram PRIVATE /external:I ${Boost_INCLUDE_DIRS})
endif()
target_compile_options(cartogram PRIVATE -ffp-contract=off)

# Compiler warnings
target_compile_options(cartogram PRIVATE -Wall -Wextra -pedantic -Wno-deprecated-declarations)
target_compile_options(cartogram PRIVATE
-Wall # Enable all warnings
-Wextra # Enable extra warnings
-Wpedantic # Enable pedantic warnings
)

# ========== Linking Libraries ==========
target_link_libraries(cartogram
PkgConfig::fftw
PkgConfig::CAIRO
Matplot++::matplot
PkgConfig::fftw
PkgConfig::cairo
)

# ========== Installation ==========
Expand Down Expand Up @@ -80,18 +94,18 @@ foreach(TEST_FILE ${TEST_FILES})
add_executable(${TEST_NAME} ${TEST_FILE} ${CARTOGRAM_TEST_SOURCES_FROM_SRC})

# Include directories for the test executable
target_include_directories(${TEST_NAME} PUBLIC
${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
PkgConfig::fftw
target_include_directories(${TEST_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_include_directories(${TEST_NAME}
SYSTEM PUBLIC
${CGAL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/external
)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${TEST_NAME} PRIVATE -isystem ${Boost_INCLUDE_DIRS})
target_compile_options(${TEST_NAME} PRIVATE -ffp-contract=off)
elseif(MSVC)
target_compile_options(${TEST_NAME} PRIVATE /external:I ${Boost_INCLUDE_DIRS})
endif()
target_compile_options(${TEST_NAME} PRIVATE -ffp-contract=off)

# Compiler warnings for the test executable
target_compile_options(${TEST_NAME} PRIVATE -Wall -Wextra -pedantic -Wno-deprecated-declarations)
Expand All @@ -113,4 +127,4 @@ add_custom_command(
POST_BUILD
COMMENT "Uninstalling cartogram..."
COMMAND xargs rm -vf < install_manifest.txt || echo "Nothing in install_manifest.txt to be uninstalled!"
)
)
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ Gastner MT, Seguy V, More P. _Fast flow-based algorithm for creating density-equ

Data produced by code in this repository are subject to the MIT license found [here](./LICENSE) and should cite the aforementioned paper by Gastner et al. (2018).

While cloning this repository, please ensure you use the `--recurse-submodules` flag like so:
-
git clone --recurse-submodules https://github.com/mgastner/cartogram-cpp.git

## Dependencies

Please note, we only support UNIX-based systems, and have only tested on macOS, Linux, and GNU.

### macOS

#### Installing Homebrew
Expand All @@ -22,25 +28,17 @@ Install [homebrew](brew.sh) by running the following command:

#### Installing dependencies through Homebrew

Install llvm, pkg-config, boost, fftw, cgal, nlohmann-json, and cmake by running the following command:
Install pkg-config, boost, fftw, nlohmann-json, and cmake by running the following command:

brew install llvm@17 libomp pkg-config boost fftw cgal nlohmann-json cmake cairo matplotplusplus
brew install libomp pkg-config boost fftw nlohmann-json cmake cairo

### Debian-based distributions (Ubuntu, Arch Linux etc.)

#### Installing GNU g++-13

Run the following commands to install it:

sudo apt install build-essential manpages-dev software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install gcc-13 g++-13

#### Installing dependencies through apt
#### Installing relevant dependencies through apt:

Install nlohmann-json, cgal, openmp, fftw3, cairo, matplot++, boost, and cmake by running the following command:
Have a look through to apt-requirements.txt if you'd like to see what all will be installed. Then, run the following commands to install all dependencies through apt:

sudo apt install nlohmann-json3-dev libcgal-dev libomp-dev libfftw3-dev libcairo2-dev libmatplot++-dev libboost-all-dev cmake
apt install -y g++-11 build-essential cmake libboost-all-dev nlohmann-json3-dev libomp-dev libfftw3-dev libcairo2-dev

### Installation

Expand All @@ -62,6 +60,7 @@ Using lesser cores than you have is recommended so that your computer still has
- If running `cmake -B build` gives you an error, it is likely that a dependency was not installed correctly. Rerun the appropriate commands above to install the required dependencies and try again.
- If you get an error which mentions permission issues, try running the command that gave you the error with `sudo` prefixed, as done with `sudo make install -C build` above.
- If `cmake` complains that it could not find a particular library, please try uninstalling it and installing it again. After reinstalling it, please also unlink it and link it with the `--force` flag.
- If you get errors related to CGAL, it's likely you have another version of CGAL installed on your computer that is getting chosen instead of the one contained as a submodule within this repository. It's also possible that when cloning this repository, the `--recurse-submodule` flag was missing. Try running `git submodule init` and `git submodule update` in the root directory of the repository.

### Usage

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions external/cgal
Submodule cgal added at 188e51
Loading