Skip to content

Commit 9354128

Browse files
Vladislav Kaluginladisgin
authored andcommitted
Add version to github actions
1 parent 8193d25 commit 9354128

File tree

7 files changed

+57
-24
lines changed

7 files changed

+57
-24
lines changed

.github/workflows/build-utbot.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ jobs:
4444
submodules: recursive
4545
- name: Build UTBot
4646
run: |
47+
export PROJECT_VERSION=$(date '+%Y.%m').$GITHUB_RUN_NUMBER
48+
export RUN_INFO=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
49+
echo $RUN_INFO
4750
chmod +x docker/action-scripts/build-utbot.sh
4851
./docker/action-scripts/build-utbot.sh
49-
5052
- name: Run Unit Tests
5153
run: |
5254
chmod +x docker/action-scripts/unit-tests.sh
@@ -82,9 +84,10 @@ jobs:
8284

8385
- name: build UTBot
8486
run: |
87+
export PROJECT_VERSION=$(date '+%Y.%m').$GITHUB_RUN_NUMBER
88+
export RUN_INFO=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
8589
chmod +x docker/action-scripts/build-utbot.sh
8690
./docker/action-scripts/build-utbot.sh
87-
8891
- name: Run Integration Tests
8992
run: |
9093
chmod +x docker/action-scripts/build-vsix.sh
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Add issues to UTBot C/C++ project
1+
name: Add issue to projects
22

33
on:
44
issues:
@@ -7,10 +7,16 @@ on:
77

88
jobs:
99
add-to-project:
10-
name: Add issue to project
10+
name: Add issue to projects
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/add-to-project@main
13+
- name: Add issue to UTBot C/C++ project
14+
uses: actions/add-to-project@main
1415
with:
1516
project-url: https://github.com/orgs/UnitTestBot/projects/1
1617
github-token: ${{ secrets.COPY_ISSUE_TO_PROJECT }}
18+
- name: Add issue to UTBot Management
19+
uses: actions/add-to-project@main
20+
with:
21+
project-url: https://github.com/orgs/UnitTestBot/projects/5
22+
github-token: ${{ secrets.COPY_ISSUE_TO_PROJECT }}

.github/workflows/publish-utbot.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Publish UTBot as an archive
33
on:
44
push:
55
branches: [main]
6+
create:
7+
tags:
8+
- '*'
69

710
jobs:
811
matrix-prep:
@@ -38,7 +41,6 @@ jobs:
3841
UTBOT_INSTALL_DIR: /utbot_distr/install
3942
GRPC_PATH: /utbot_distr/install
4043
CLI_PATH: /utbot_distr/cli
41-
VERSION: ${{ format('1.0.{0}', github.run_number) }}
4244
ARTIFACT_DIR: utbot-artifact
4345
steps:
4446
- name: Checkout repository
@@ -51,6 +53,15 @@ jobs:
5153
./docker/action-scripts/build-vsix.sh
5254
- name: build UTBot
5355
run: |
56+
re="^[0-9]{4}\.[0-1][0-9](\.[0-9]+){0,1}$"
57+
if [[ $GITHUB_REF_NAME =~ $re ]]; then
58+
export PROJECT_VERSION=$GITHUB_REF_NAME
59+
echo "ARTIFACT_NAME=release-$PROJECT_VERSION" >> $GITHUB_ENV
60+
else
61+
export PROJECT_VERSION=$(date '+%Y.%m').$GITHUB_RUN_NUMBER
62+
echo "ARTIFACT_NAME=dev-$PROJECT_VERSION" >> $GITHUB_ENV
63+
fi
64+
export RUN_INFO=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
5465
chmod +x docker/action-scripts/build-utbot.sh
5566
./docker/action-scripts/build-utbot.sh
5667
shell: bash
@@ -60,7 +71,7 @@ jobs:
6071
./docker/action-scripts/prepare-ubuntu-release.sh
6172
- uses: actions/upload-artifact@v2
6273
with:
63-
name: utbot-release-${{ env.VERSION }}
74+
name: utbot-${{ env.ARTIFACT_NAME }}
6475
path: ${{ env.ARTIFACT_DIR }}
6576

6677
auto_installation_check:
@@ -76,4 +87,4 @@ jobs:
7687
cd $(find . -name utbot-release* -type d -print | head -n1)
7788
chmod +x ./unpack_and_run_utbot.sh
7889
../integration-tests/installation_checks/automated_install_checks.sh ./utbot_distr.tar.gz
79-
../integration-tests/installation_checks/clean.sh
90+
../integration-tests/installation_checks/clean.sh

server/CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
cmake_minimum_required(VERSION 3.10)
2-
project(UnitTestBot DESCRIPTION "Tool that generates unit test by C/C++ source code, trying to reach all branches and maximize code coverage"
3-
HOMEPAGE_URL "https://unittestbot.org")
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(UTBotCpp DESCRIPTION "Tool that generates unit test by C/C++ source code, trying to reach all branches and maximize code coverage"
4+
HOMEPAGE_URL "https://unittestbot.org" VERSION ${PROJECT_VERSION})
45
set(PROJECT_ORG "UnitTestBot")
5-
if (NOT CMAKE_PROJECT_VERSION)
6-
set(CMAKE_PROJECT_VERSION "DevBuild")
7-
endif ()
6+
7+
message("Project: ${PROJECT_NAME}")
8+
message("Organisation: ${PROJECT_ORG}")
9+
message("Homepage: ${CMAKE_PROJECT_HOMEPAGE_URL}")
10+
message("Version: ${CMAKE_PROJECT_VERSION}")
11+
message("Run from: ${RUN_INFO}")
812

913
configure_file(config.h.in config.h @ONLY)
1014

@@ -136,29 +140,29 @@ endif ()
136140
################################################################################
137141
# Library
138142
################################################################################
139-
add_library(UnitTestBotLib STATIC ${ALL_PROTO_GENERATED_SOURCES} ${ALL_SOURCES})
140-
target_include_directories(UnitTestBotLib PUBLIC
143+
add_library(UTBotCppLib STATIC ${ALL_PROTO_GENERATED_SOURCES} ${ALL_SOURCES})
144+
target_include_directories(UTBotCppLib PUBLIC
141145
${CMAKE_CURRENT_SOURCE_DIR}/src
142146
resources
143147
thirdparty/ordered-map)
144148

145-
target_link_libraries(UnitTestBotLib PUBLIC clangTooling clangBasic clangASTMatchers clangRewriteFrontend
149+
target_link_libraries(UTBotCppLib PUBLIC clangTooling clangBasic clangASTMatchers clangRewriteFrontend
146150
gRPC::grpc++_reflection
147151
gRPC::grpc++
148152
protobuf::libprotobuf
149153
loguru
150154
kleeRunner
151155
)
152156
if (ENABLE_PRECOMPILED_HEADERS)
153-
target_precompile_headers(UnitTestBotLib PUBLIC pch.h)
157+
target_precompile_headers(UTBotCppLib PUBLIC pch.h)
154158
endif ()
155159

156160
################################################################################
157161
# Executable
158162
################################################################################
159163
add_llvm_executable(utbot main.cpp)
160164
target_link_libraries(utbot PUBLIC
161-
UnitTestBotLib
165+
UTBotCppLib
162166
loguru
163167
)
164168

@@ -186,7 +190,7 @@ if (ENABLE_UNIT_TESTS)
186190
UTBot_UnitTests
187191
PUBLIC
188192
gtest
189-
UnitTestBotLib
193+
UTBotCppLib
190194
)
191195

192196
if (ENABLE_PRECOMPILED_HEADERS)

server/build.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
mkdir -p build
44
cd build
5-
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_INSTALL_PREFIX=$UTBOT_ALL/server-install ..
5+
6+
if [ -z $PROJECT_VERSION ]; then
7+
PROJECT_VERSION="0.0.0"
8+
fi
9+
10+
if [ -z $RUN_INFO ]; then
11+
RUN_INFO="local"
12+
fi
13+
14+
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_INSTALL_PREFIX=$UTBOT_ALL/server-install -DPROJECT_VERSION=$PROJECT_VERSION -DRUN_INFO=$RUN_INFO ..
615
$UTBOT_CMAKE_BINARY --build .
716
$UTBOT_CMAKE_BINARY --install .

server/config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
#define PROJECT_VERSION "@CMAKE_PROJECT_VERSION@"
77
#define PROJECT_DESCRIPTION "@CMAKE_PROJECT_DESCRIPTION@"
88
#define PROJECT_HOMEPAGE_URL "@CMAKE_PROJECT_HOMEPAGE_URL@"
9-
#define RUN_URL "@RUN_URL@"
9+
#define RUN_INFO "@RUN_INFO@"
1010

1111
#endif // CONFIG_H_IN

server/src/commands/Commands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Commands::MainCommands::MainCommands(CLI::App &app) {
1111
app.set_help_all_flag("--help-all", "Expand all help");
1212
app.add_flag_function("--version", [](int count){
1313
std::cout << PROJECT_NAME << " " << PROJECT_VERSION << std::endl;
14-
if (strlen(RUN_URL)) {
15-
std::cout << "Build by " << RUN_URL << std::endl;
14+
if (strlen(RUN_INFO)) {
15+
std::cout << "Build by " << RUN_INFO << std::endl;
1616
}
1717
exit(0);
1818
}, "Get UTBotCpp version and build detail");

0 commit comments

Comments
 (0)