Skip to content

Commit 984d181

Browse files
committed
Release workflow (#1)
* Switch to release workflow Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Fix DynamicVersion Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Fix PackageComps Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Fix install location and switch to tmt Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> * Configure tmt tests Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de> --------- Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
1 parent 48562ae commit 984d181

39 files changed

+316
-136
lines changed

.github/workflows/test.yaml

-13
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,3 @@ jobs:
1616
- uses: actions/checkout@v3
1717
- uses: actions/setup-python@v4
1818
- uses: pre-commit/action@v3.0.0
19-
20-
ctest:
21-
runs-on: ubuntu-latest
22-
needs: [ pre-commit ]
23-
steps:
24-
- uses: actions/checkout@v3
25-
with:
26-
fetch-depth: 0
27-
- uses: lukka/get-cmake@latest
28-
- name: Run CMake configuration for ${{ matrix.toolchain }} toolchain
29-
uses: lukka/run-cmake@v10.3
30-
with:
31-
workflowPreset: default

.packit.yaml

+28-45
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,46 @@ update_release: false
1313
upstream_tag_template: v{version}
1414

1515
jobs:
16-
## TODO: Temporary setup until release workflow is configured
16+
- job: tests
17+
trigger: pull_request
18+
targets:
19+
- fedora-development
1720
- job: copr_build
18-
trigger: commit
19-
branch: main
21+
trigger: pull_request
2022
owner: lecris
2123
project: CMakeExtraUtils
2224
update_release: true
2325
release_suffix: "{PACKIT_RPMSPEC_RELEASE}"
2426
targets:
27+
- fedora-development
28+
- job: tests
29+
trigger: commit
30+
branch: main
31+
targets:
32+
- fedora-development
2533
- fedora-development-x86_64
2634
- fedora-latest-x86_64
2735
- fedora-development-aarch64
2836
- fedora-latest-aarch64
29-
- job: tests
37+
- job: copr_build
3038
trigger: commit
39+
branch: main
40+
owner: lecris
41+
project: nightly
3142
targets:
32-
- fedora-development
33-
## TODO: Disabled until release workflow is configured
34-
# - job: tests
35-
# trigger: pull_request
36-
# targets:
37-
# - fedora-development
38-
# - job: copr_build
39-
# trigger: pull_request
40-
# owner: lecris
41-
# project: CMakeExtraUtils
42-
# update_release: true
43-
# release_suffix: "{PACKIT_RPMSPEC_RELEASE}"
44-
# targets:
45-
# - fedora-development
46-
# - job: tests
47-
# trigger: commit
48-
# targets:
49-
# - fedora-development
50-
# - fedora-development-x86_64
51-
# - fedora-latest-x86_64
52-
# - fedora-development-aarch64
53-
# - fedora-latest-aarch64
54-
# - job: copr_build
55-
# trigger: commit
56-
# branch: main
57-
# owner: lecris
58-
# project: nightly
59-
# targets:
60-
# - fedora-development-x86_64
61-
# - fedora-latest-x86_64
62-
# - fedora-development-aarch64
63-
# - fedora-latest-aarch64
64-
# - job: copr_build
65-
# trigger: release
66-
# owner: lecris
67-
# project: releases
68-
# targets:
69-
# - fedora-development-x86_64
70-
# - fedora-latest-x86_64
71-
# - fedora-development-aarch64
72-
# - fedora-latest-aarch64
43+
- fedora-development-x86_64
44+
- fedora-latest-x86_64
45+
- fedora-development-aarch64
46+
- fedora-latest-aarch64
47+
- job: copr_build
48+
trigger: release
49+
owner: lecris
50+
project: release
51+
targets:
52+
- fedora-development-x86_64
53+
- fedora-latest-x86_64
54+
- fedora-development-aarch64
55+
- fedora-latest-aarch64
7356
## TODO: Disabled until released on src.fedoraproject.org
7457
# - job: propose_downstream
7558
# trigger: release

CMakeLists.txt

+4-12
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,13 @@ project(CMakeExtraUtils
1616

1717
# Basic options
1818
option(CMAKEEXTRAUTILS_INSTALL "CMakeExtraUtils: Install files" ${PROJECT_IS_TOP_LEVEL})
19-
option(CMAKEEXTRAUTILS_TESTS "CMakeExtraUtils: Build unit tests" ${PROJECT_IS_TOP_LEVEL})
20-
21-
# Tests
22-
if (CMAKEEXTRAUTILS_TESTS)
23-
enable_testing()
24-
add_subdirectory(test)
25-
endif ()
2619

2720

2821
# Install package files
2922
if (CMAKEEXTRAUTILS_INSTALL)
3023
# Install for find_package
31-
# At least one language has to be defined for GNUInstallDirs
32-
enable_language(CXX)
3324
include(CMakePackageConfigHelpers)
25+
# Will show developer warning, but can't supress it :(
3426
include(GNUInstallDirs)
3527
# Package files
3628
write_basic_package_version_file(
@@ -42,18 +34,18 @@ if (CMAKEEXTRAUTILS_INSTALL)
4234
configure_package_config_file(
4335
cmake/CMakeExtraUtilsConfig.cmake.in
4436
CMakeExtraUtilsConfig.cmake
45-
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CMakeExtraUtils
37+
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
4638
)
4739
install(FILES
4840
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfigVersion.cmake
4941
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfig.cmake
50-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CMakeExtraUtils
42+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
5143
)
5244
# Bundled cmake files
5345
install(FILES
5446
cmake/DynamicVersion.cmake
5547
cmake/PackageComps.cmake
56-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CMakeExtraUtils
48+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
5749
)
5850
endif ()
5951

cmake/CMakePresets-defaults.json

-11
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
}
1414
}
1515
],
16-
"testPresets": [
17-
{
18-
"name": "default",
19-
"displayName": "Default test preset",
20-
"configurePreset": "default"
21-
}
22-
],
2316
"workflowPresets": [
2417
{
2518
"name": "default",
@@ -28,10 +21,6 @@
2821
{
2922
"type": "configure",
3023
"name": "default"
31-
},
32-
{
33-
"type": "test",
34-
"name": "default"
3524
}
3625
]
3726
}

cmake/DynamicVersion.cmake

+15-5
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ function(dynamic_version)
104104
TMP_FOLDER ${ARGS_TMP_FOLDER}
105105
)
106106
if (DEFINED ARGS_FALLBACK_VERSION)
107-
list(DynamicVersion_ARGS APPEND
107+
list(APPEND DynamicVersion_ARGS
108108
FALLBACK_VERSION ${ARGS_FALLBACK_VERSION})
109109
endif ()
110110
if (DEFINED ARGS_FALLBACK_HASH)
111-
list(DynamicVersion_ARGS APPEND
111+
list(APPEND DynamicVersion_ARGS
112112
FALLBACK_HASH ${ARGS_FALLBACK_HASH})
113113
endif ()
114114
if (ARGS_ALLOW_FAILS)
115-
list(DynamicVersion_ARGS APPEND ALLOW_FAILS)
115+
list(APPEND DynamicVersion_ARGS ALLOW_FAILS)
116116
endif ()
117117
# Normalize DynamicVersion_ARGS to be passed as string
118118
list(JOIN DynamicVersion_ARGS "\\;" DynamicVersion_ARGS)
@@ -127,7 +127,9 @@ function(dynamic_version)
127127

128128
# Copy all configured files
129129
foreach (file IN ITEMS .DynamicVersion.json .version .git_describe .git_commit)
130-
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
130+
if (EXISTS ${file})
131+
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
132+
endif ()
131133
endforeach ()
132134

133135
# Check configuration state
@@ -246,13 +248,21 @@ function(get_dynamic_version)
246248
endif ()
247249

248250

251+
if (NOT EXISTS ${ARGS_GIT_ARCHIVAL_FILE})
252+
# If git_archival.txt is missing, project is ill-formed
253+
message(${error_message_type}
254+
"DynamicVersion: Missing file .git_archival.txt\n"
255+
" .git_archival.txt: ${ARGS_GIT_ARCHIVAL_FILE}")
256+
return()
257+
endif ()
258+
249259
# Get version dynamically from git_archival.txt
250260
file(STRINGS ${ARGS_GIT_ARCHIVAL_FILE} describe-name
251261
REGEX "^describe-name:.*")
252262
if (NOT describe-name)
253263
# If git_archival.txt does not contain the field "describe-name:", it is ill-formed
254264
message(${error_message_type}
255-
"DynamicVersion: Missing file or string \"describe-name\" in .git_archival.txt\n"
265+
"DynamicVersion: Missing string \"describe-name\" in .git_archival.txt\n"
256266
" .git_archival.txt: ${ARGS_GIT_ARCHIVAL_FILE}")
257267
return()
258268
endif ()

cmake/PackageComps.cmake

+14-1
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,19 @@ function(export_component)
580580
set(LIB_TYPE_Choices "")
581581
list(APPEND LIB_TYPE_Choices static shared)
582582

583+
# Include GNUInstallDirs if not done already
584+
if (NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
585+
include(GNUInstallDirs)
586+
endif ()
587+
588+
# Choose appropriate target install location
589+
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
590+
if (NOT ENABLED_LANGUAGES)
591+
set(install_prefix ${CMAKE_INSTALL_DATAROOTDIR})
592+
else ()
593+
set(install_prefix ${CMAKE_INSTALL_LIBDIR})
594+
endif ()
595+
583596
cmake_parse_arguments(ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}" ${ARGN})
584597

585598
if (NOT DEFINED ARGS_PROJECT)
@@ -621,7 +634,7 @@ function(export_component)
621634
install(EXPORT ${ARGS_TARGET}
622635
FILE ${TargetFile}
623636
NAMESPACE ${ARGS_PROJECT}::
624-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${ARGS_PROJECT}
637+
DESTINATION ${install_prefix}/cmake/${ARGS_PROJECT}
625638
COMPONENT ${ARGS_PROJECT}_Development)
626639
export(EXPORT ${ARGS_TARGET}
627640
FILE ${TargetFile}

distro/cmake-extra-utils.spec

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ A collection of helpful cmake scripts
3535
%files
3636
%license LICENSE
3737
%doc README.md
38-
%{_libdir}/cmake/CMakeExtraUtils
38+
%{_datadir}/cmake/CMakeExtraUtils
3939

4040
%changelog
4141
%autochangelog

distro/tmt/plans/full.fmf

-10
This file was deleted.

distro/tmt/setup/packages.yaml

-7
This file was deleted.

distro/tmt/test/find_package/main.fmf

-2
This file was deleted.

distro/tmt/test/find_package/test.sh

-5
This file was deleted.

test/CMakeLists.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: d0157f38cf8e369c91ef3b144609b402ce9d18ff
2+
node-date: 2023-03-30T17:33:08+02:00
3+
describe-name: v0.1.2
4+
ref-names: v0.1.2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
cmake_minimum_required(VERSION 3.25)
2-
project(Test_find_package LANGUAGES NONE)
32

43
find_package(CMakeExtraUtils REQUIRED)
54

65
include(DynamicVersion)
6+
dynamic_version()
7+
8+
project(Test_DynamicVersion
9+
VERSION ${PROJECT_VERSION}
10+
LANGUAGES NONE)

test/DynamicVersion/archive/main.fmf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Common test variables
2+
tag:
3+
- DynamicVersion
4+
- archive
5+
6+
# Define tests
7+
/basic:
8+
summary: Basic configuration
9+
test: ./test_basic.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -eux
2+
3+
tmp=$(mktemp -d)
4+
rsync -r ./ $tmp
5+
cd $tmp
6+
cmake -B ./build .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
find_package(CMakeExtraUtils REQUIRED)
4+
5+
include(DynamicVersion)
6+
dynamic_version(FALLBACK_VERSION 0.1.2)
7+
8+
project(Test_DynamicVersion
9+
VERSION ${PROJECT_VERSION}
10+
LANGUAGES NONE)

test/DynamicVersion/fallback/main.fmf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Common test variables
2+
tag:
3+
- DynamicVersion
4+
- fallback
5+
6+
# Define tests
7+
/basic:
8+
summary: Basic configuration
9+
test: ./test_basic.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -eux
2+
3+
tmp=$(mktemp -d)
4+
rsync -r ./ $tmp
5+
cd $tmp
6+
cmake -B ./build .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
find_package(CMakeExtraUtils REQUIRED)
4+
5+
include(DynamicVersion)
6+
dynamic_version()
7+
8+
project(Test_DynamicVersion
9+
VERSION ${PROJECT_VERSION}
10+
LANGUAGES NONE)

test/DynamicVersion/git_repo/main.fmf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Common test variables
2+
tag:
3+
- DynamicVersion
4+
- git_repo
5+
6+
# Define tests
7+
/not_git:
8+
summary: Fail if not a git archive
9+
test: ./test_not_git.sh
10+
result: xfail
11+
/no_tag:
12+
summary: Fail if do not have tag to calculate
13+
test: ./test_no_tag.sh
14+
result: xfail
15+
/basic:
16+
summary: Test basic setup
17+
test: ./test_basic.sh
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -eux
2+
3+
tmp=$(mktemp -d)
4+
rsync -r ./ $tmp
5+
cd $tmp
6+
git init
7+
git add CMakeLists.txt
8+
git commit -m "Initial commit"
9+
git tag v0.0.0
10+
cmake -B ./build .

0 commit comments

Comments
 (0)