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

Package source files and update actions #1254

Merged
merged 49 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b60c3b4
added target package_source to create tar-ball
Davknapp Sep 24, 2024
9835f96
Started cmake-tarball test
Davknapp Sep 24, 2024
1aead09
Update indentation of workflow file
Davknapp Sep 24, 2024
16ff88e
split workflow
Davknapp Sep 24, 2024
6b3a73e
Remove duplication
Davknapp Sep 24, 2024
44267bd
Update build_cmake_tarball.yml
Davknapp Sep 24, 2024
397f9a4
Merge branch 'main' into Cpack
Davknapp Sep 24, 2024
2c5c61a
rename workflows
Davknapp Sep 24, 2024
c0d06f1
Update name
Davknapp Sep 24, 2024
9d96e1f
update indentation
Davknapp Sep 24, 2024
a269246
do not use system sc&p4est to test tarball creation
Davknapp Sep 24, 2024
64d7fb5
Merge remote-tracking branch 'origin/Cpack' into Cpack
Davknapp Sep 24, 2024
367145e
only start wf if the previous one is completed
Davknapp Sep 24, 2024
f31518a
update path to look for tar-ball
Davknapp Sep 24, 2024
dd02d0d
update paths
Davknapp Sep 24, 2024
8bf1119
specify to upload the packaged source
Davknapp Sep 24, 2024
7ce22dd
use artifact from triggering wf
Davknapp Sep 24, 2024
f2030c5
run-id -> run_id
Davknapp Sep 24, 2024
14f3db6
documentation is wrong: run_id -> run-id
Davknapp Sep 24, 2024
553c40e
Add debug output
Davknapp Sep 24, 2024
8408e10
remove typo
Davknapp Sep 24, 2024
2d1d070
update on-success/on-failure logic
Davknapp Sep 24, 2024
a30b2fe
do not start workflow on push/pull logic
Davknapp Sep 24, 2024
8ace647
Update workflow dependencies
Davknapp Sep 25, 2024
467c397
retry dependencies
Davknapp Sep 25, 2024
c655873
update branch restrictions
Davknapp Sep 25, 2024
0e7f8fa
Update create_from_cmake_tarball.yml
Davknapp Sep 25, 2024
2e69cc3
Update build_cmake_tarball.yml
Davknapp Sep 25, 2024
c9330ca
Update build_cmake_tarball.yml
Davknapp Sep 25, 2024
54234ea
Update workflow run
Davknapp Sep 25, 2024
307eea0
Merge remote-tracking branch 'origin/Cpack' into Cpack
Davknapp Sep 25, 2024
0cfe391
UPdate triggering event
Davknapp Sep 25, 2024
4291fe4
write version-file
Davknapp Sep 25, 2024
168780a
Change write location
Davknapp Sep 25, 2024
3b99849
Read version from file when building from tar
Davknapp Sep 26, 2024
c56a8c2
update build
Davknapp Sep 26, 2024
bec4dad
Update triggering workflow for build_tar
Davknapp Sep 26, 2024
9542fea
remove branch restriction
Davknapp Sep 26, 2024
0a65275
Run workflow on different branches than default
Davknapp Sep 26, 2024
9ab473a
Discard dependencies
Davknapp Sep 26, 2024
25ded76
dont use system libs
Davknapp Sep 26, 2024
87aa2f9
update tarball location
Davknapp Sep 26, 2024
b27b205
create dir tarballs
Davknapp Sep 26, 2024
f2e960d
Change location to find cmake
Davknapp Sep 26, 2024
abbae2d
correction
Davknapp Sep 26, 2024
3b8c684
Update location of verstion.txt
Davknapp Sep 26, 2024
445604a
Remove obsolete workflow
Davknapp Sep 26, 2024
381cd5d
Merge branch 'main' into Cpack
Davknapp Sep 27, 2024
84e78d9
Apply suggestions from review
Davknapp Sep 27, 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
165 changes: 165 additions & 0 deletions .github/workflows/build_cmake_tarball.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CMake Tarball

# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2024 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#
# This github CI script constructs a tarball and checks if it is build correctly.
#

env:
MAKEFLAGS: "-j2 V=0"


on:
push:
branches:
- main
- develop
- CI-*tarball* # for testing this script, all feature branches with "tarball" in their name
pull_request:
branches:
- main
- develop
workflow_dispatch:

jobs:
build:

if: (github.event_name == 'schedule' && github.repository == 'DLR-AMR/t8code') || (github.event_name != 'schedule')
runs-on: ubuntu-20.04
container: dlramr/t8code-ubuntu:t8-dependencies
timeout-minutes: 90
steps:
#
# Setup and bootstrap
#
- uses: actions/checkout@v4
with:
fetch-tags: true # required to get version tags
fetch-depth: 0 # required to get all history, especially the version tags
- name: install sudo
run: apt update && apt install sudo
# On the github Ubuntu 20.04, sudo is not available by default
# we need it, however, to update/upgrade our packages.
- name: Update packages
run: sudo apt-get update && sudo apt-get upgrade -y
# This step is necessary to get the newest package data
- name: disable ownership checks
run: git config --global --add safe.directory '*'
- name: init submodules
run: git submodule init
- name: update submodules
run: git submodule update
- name: bootstrap
run: ./bootstrap
#
# T8CODE
# with p4est and sc as internal dependencies which is needed for make dist
#
#
- name: less-test option
if: ${{ inputs.LESS_TESTS }}
run: export LESS_TEST_OPTION="-DT8CODE_ENABLE_LESS_TESTS=ON"
&& echo LESS_TEST_OPTION="$LESS_TEST_OPTION" >> $GITHUB_ENV
- name: build config variables
run: export CONFIG_OPTIONS="${LESS_TEST_OPTION} -GNinja -DT8CODE_USE_SYSTEM_SC=OFF -DT8CODE_USE_SYSTEM_P4EST=OFF -DT8CODE_BUILD_PEDANTIC=ON -DT8CODE_ENABLE_MPI=$MPI -DCMAKE_BUILD_TYPE=$BUILD_TYPE"
&& echo CONFIG_OPTIONS="$CONFIG_OPTIONS" >> $GITHUB_ENV
- name: cmake
run: mkdir build && cd build && cmake ../ $CONFIG_OPTIONS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: config.log
path: build/config.log
# Start building tarball
- name: Install pandoc
uses: nikeee/setup-pandoc@v1
- name: Test pandoc
run: pandoc --version
# Build the tarball
- name: Make tarball
run: cd build && ninja GenerateVersionFile && ninja package_source && mkdir tarballs && mv package/*Source.tar.gz tarballs
# Upload the tarball
- name: upload tarball
uses: actions/upload-artifact@v4
with:
name: tarballs
path: build/tarballs

test-tarball:
needs: build
runs-on: ubuntu-20.04
container: dlramr/t8code-ubuntu:t8-dependencies
timeout-minutes: 90
steps:
- name: install sudo
run: apt update && apt install sudo
# On the github Ubuntu 20.04, sudo is not available by default
# we need it, however, to update/upgrade our packages.
- name: Update packages
run: sudo apt-get update && sudo apt-get upgrade -y
# This step is necessary to get the newest package data
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: tarballs
path: tarballs
- name: Extract tarball
run: tar xzf tarballs/*.tar.gz -C $RUNNER_TEMP
- name: update Github_env
run: export TAR_DIR="$RUNNER_TEMP/`basename tarballs/*.tar.gz .tar.gz`" &&
echo TAR_DIR="$TAR_DIR" >>$GITHUB_ENV

# build config vars
- name: less-test-option
if: github.event_name == 'pull_request'
run: export LESS_TEST_OPTION="-DT8CODE_ENABLE_LESS_TESTS=ON"
&& echo LESS_TEST_OPTION="$LESS_TEST_OPTION" >> $GITHUB_ENV
- name: build config variables
run: export CONFIG_OPTIONS="${LESS_TEST_OPTION} -GNinja -DT8CODE_USE_SYSTEM_SC=OFF -DT8CODE_USE_SYSTEM_P4EST=OFF -DT8CODE_BUILD_PEDANTIC=ON -DT8CODE_ENABLE_MPI=$MPI -DCMAKE_BUILD_TYPE=$BUILD_TYPE"
&& echo CONFIG_OPTIONS="$CONFIG_OPTIONS" >> $GITHUB_ENV
- name: Check vars
run: echo "[$CONFIG_DEBUG]"
- name: configure from Tarball
run: mkdir build_tar && cd build_tar && cmake $TAR_DIR $CONFIG_OPTIONS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: build_tar.log
path: build_tar/config.log
- name: build
run: cd build_tar && ninja
- name: install
run: cd build_tar && ninja install
- name: check serial
run: cd build_tar && ctest -R _serial
- name: check parallel
run: cd build_tar && ctest -R _parallel
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: build_tar.log
path: build_tar/test-suite.log


2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ endif()
if ( T8CODE_BUILD_DOCUMENTATION )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/doc )
endif()

include (cmake/CPackConfig.cmake)
51 changes: 51 additions & 0 deletions cmake/CPackConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
set(CPACK_PACKAGE_VENDOR "DLR-SC AMR")
set(CPACK_PACKAGE_NAME "T8CODE")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Parallel algorithms and data structures for tree-based AMR with arbitrary element shapes.")
set(CPACK_PACKAGE_VERSION_MAJOR ${T8CODE_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${T8CODE_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${T8CODE_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package)
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/t8code_logo.png)

# Define a variable for the version file
set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/version.txt")


# Custom command to generate the version file
add_custom_command(
OUTPUT ${VERSION_FILE}
COMMAND ${CMAKE_COMMAND} -E echo "Version ${T8CODE_VERSION_MAJOR}.${T8CODE_VERSION_MINOR}.${T8CODE_VERSION_PATCH}" > ${VERSION_FILE}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt # Change as needed
)

# Create a custom target to ensure the version file is generated
add_custom_target(GenerateVersionFile ALL DEPENDS ${VERSION_FILE})

set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_INCLUDE_FILES ${VERSION_FILE})
set(CPACK_SOURCE_IGNORE_FILES .git/ .github/ .vscode/ _CPack_Packages/
.gitmodules .gitignore
${PROJECT_BINARY_DIR}/
Makefile.in
aclocal.m4
autom4te.cache/
build/
bin/
configure
DartConfiguration.tcl
CMakeCache.txt
build/
build-aux/
configure
config.log
compile_commands.json
)

set(CPACK_PACKAGE_NAME "T8CODE")
set(CPACK_VERBATIM_VARIABLES TRUE)


include(CPack)

72 changes: 47 additions & 25 deletions cmake/GitProjectVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
find_package( Git REQUIRED )

# See `scr/t8_version.h` for the documentation of following definitions.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
# See `scr/t8_version.h` for the documentation of following definitions.

execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
COMMAND cut -c 2-
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE T8CODE_VERSION_RAW
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_RAW}
COMMAND cut -d- -f1
OUTPUT_VARIABLE T8CODE_VERSION_NUMBERS
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_RAW}
COMMAND cut -d- -f2-
OUTPUT_VARIABLE T8CODE_VERSION_POINT
OUTPUT_STRIP_TRAILING_WHITESPACE )

# To reuse the version in other CMakeLists.
else()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/version.txt")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" VERSION_CONTENT)
# Extract the version number
string(REGEX MATCH "Version ([0-9])\.([0-9]+)\.([0-9]+)" VERSION_MATCH "${VERSION_CONTENT}" )
if (VERSION_MATCH)
# The version number will be in ${CMAKE_MATCH_1}
set(T8CODE_VERSION_NUMBERS "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
set(T8CODE_VERSION_RAW "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
message(STATUS "Extracted Version: ${T8CODE_VERSION_NUMBERS}")
else()
message(WARNING "Version number not found in version.txt")
endif()
else()
message(WARNING "Version information not found")
endif()
endif()


execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
COMMAND cut -c 2-
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE T8CODE_VERSION_RAW
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_RAW}
COMMAND cut -d- -f1
OUTPUT_VARIABLE T8CODE_VERSION_NUMBERS
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_RAW}
COMMAND cut -d- -f2-
OUTPUT_VARIABLE T8CODE_VERSION_POINT
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_NUMBERS}
COMMAND cut -d. -f1
OUTPUT_VARIABLE T8CODE_VERSION_MAJOR
OUTPUT_STRIP_TRAILING_WHITESPACE )
COMMAND cut -d. -f1
OUTPUT_VARIABLE T8CODE_VERSION_MAJOR
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_NUMBERS}
COMMAND cut -d. -f2
OUTPUT_VARIABLE T8CODE_VERSION_MINOR
OUTPUT_STRIP_TRAILING_WHITESPACE )
COMMAND cut -d. -f2
OUTPUT_VARIABLE T8CODE_VERSION_MINOR
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND echo ${T8CODE_VERSION_NUMBERS}
COMMAND cut -d. -f3
OUTPUT_VARIABLE T8CODE_VERSION_PATCH
OUTPUT_STRIP_TRAILING_WHITESPACE )

# To reuse the version in other CMakeLists.
COMMAND cut -d. -f3
OUTPUT_VARIABLE T8CODE_VERSION_PATCH
OUTPUT_STRIP_TRAILING_WHITESPACE )
set(T8_VERSION ${T8CODE_VERSION_NUMBERS} CACHE INTERNAL "")