Skip to content

Commit 4b51023

Browse files
Alexey Pleshakovqrort
Alexey Pleshakov
authored andcommitted
Add "Publish UTBot" workflow
1 parent a9db5f3 commit 4b51023

26 files changed

+519
-43
lines changed

.github/workflows/build-utbot.yml

+9-14
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,24 @@ jobs:
2020
UTBOT_INSTALL_DIR: /utbot_distr/install
2121
GRPC_PATH: /utbot_distr/install
2222
CLI_PATH: /utbot_distr/cli
23+
DOCKER_TAG: 20-10-2021
24+
ARTIFACT_DIR: utbot-artifact
2325
steps:
24-
- name: Install git
25-
run: |
26-
apt install -y software-properties-common
27-
apt update
28-
add-apt-repository -y ppa:git-core/ppa
29-
apt update
30-
apt install -y git
3126
- name: Checkout repository
3227
uses: actions/checkout@v2
3328
with:
3429
submodules: recursive
3530
- name: build UTBot and run unit tests
3631
run: |
37-
source docker/building_dependencies/runtime_env.sh
38-
chmod +x build.sh
39-
./build.sh
40-
cd server/build
41-
chmod +x UTBot_UnitTests
42-
./UTBot_UnitTests info --log `pwd`
32+
chmod +x docker/action-scripts/build-and-unit-tests.sh
33+
./docker/action-scripts/build-and-unit-tests.sh
4334
shell: bash
4435
- uses: actions/upload-artifact@v2
4536
if: failure()
4637
with:
4738
name: UTBot unit tests logs
48-
path: server/build/logs
39+
path: server/build/logs
40+
- name: build VSCode plugin
41+
run: |
42+
chmod +x docker/action-scripts/build-vsix.sh
43+
./docker/action-scripts/build-vsix.sh

.github/workflows/publish-utbot.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish UTBot as an archive
2+
3+
on:
4+
push:
5+
# branches: [main]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-18.04
10+
env:
11+
# Environment for the job and for the container is, sadly, duplicated
12+
# https://github.com/docker/compose/issues/1837
13+
VERSION: ${{ format('1.0.{0}', github.run_number) }}
14+
ARTIFACT_DIR: utbot-artifact
15+
container:
16+
# It is impossible to parametrize image via workflow environment,
17+
# so its name is hard-coded.
18+
# https://github.com/actions/runner/issues/480
19+
image: ghcr.io/unittestbot/utbotcpp/base_env:20-10-2021
20+
credentials:
21+
username: ${{ github.actor }}
22+
password: ${{ secrets.GITHUB_TOKEN }}
23+
env:
24+
UTBOT_ALL: /utbot_distr
25+
UTBOT_INSTALL_DIR: /utbot_distr/install
26+
GRPC_PATH: /utbot_distr/install
27+
CLI_PATH: /utbot_distr/cli
28+
VERSION: ${{ format('1.0.{0}', github.run_number) }}
29+
ARTIFACT_DIR: utbot-artifact
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v2
33+
with:
34+
submodules: recursive
35+
- name: build VSCode plugin
36+
run: |
37+
chmod +x docker/action-scripts/build-vsix.sh
38+
./docker/action-scripts/build-vsix.sh
39+
- name: build UTBot
40+
run: |
41+
chmod +x docker/action-scripts/build-utbot.sh
42+
./docker/action-scripts/build-utbot.sh
43+
shell: bash
44+
- name: prepare UTBot release for Ubuntu
45+
run: |
46+
chmod +x docker/action-scripts/prepare-ubuntu-release.sh
47+
./docker/action-scripts/prepare-ubuntu-release.sh
48+
- uses: actions/upload-artifact@v2
49+
with:
50+
name: utbot-release-${{ env.VERSION }}
51+
path: ${{ env.ARTIFACT_DIR }}

.gitmodules

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[submodule "klee"]
2-
path = klee
2+
path = submodules/klee
33
url = https://github.com/UnitTestBot/klee.git
44
[submodule "Bear"]
5-
path = Bear
5+
path = submodules/Bear
66
url = https://github.com/UnitTestBot/Bear.git
77
[submodule "loguru"]
8-
path = loguru
8+
path = submodules/loguru
99
url = https://github.com/emilk/loguru.git
1010
[submodule "json"]
11-
path = json
11+
path = submodules/json
1212
url = https://github.com/astoeckel/json.git
1313
[submodule "ordered-map"]
14-
path = ordered-map
14+
path = submodules/ordered-map
1515
url = https://github.com/Tessil/ordered-map
1616
[submodule "parallel-hashmap"]
17-
path = parallel-hashmap
17+
path = submodules/parallel-hashmap
1818
url = https://github.com/greg7mdp/parallel-hashmap

DEVNOTE.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ To build UTBot from sources:
2323

2424
5. `cd` into `UTBotCpp` directory and run `build.sh` — it is the script that builds KLEE UTBot and runs UTBot unit tests
2525
6. Navigate to `UTBotCpp/server/build` directory and launch the binary with `./utbot server` command. Now the server is running.
26-
7. Launch VS Code on your local machine. Use VS Code [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) to get access to the docker insides. Navigate to `UTBotCpp/vscode-plugin` directory and press F5. This will build and run UTBot VS Code plugin.
27-
8. A new VS Code window will open; this window will have UTBot VS Code plugin enabled. In this new folder, open `UTBotCpp/integration-tests/c-example` directory.
28-
9. When UTBot Quickstart Wizard requests you to enter server host and port, specify `localhost` and UTBot server run port, respectively.
26+
7. Launch VS Code on your local machine. Use VS Code [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) to get access to the docker insides. Navigate to `UTBotCpp/vscode-plugin` directory and run `build.sh` script.
27+
8. Press F5 (*Run Extension*). This will run UTBot VS Code plugin.
28+
9. A new VS Code window will open; this window will have UTBot VS Code plugin enabled. In this new folder, open `UTBotCpp/integration-tests/c-example` directory.
29+
10. When UTBot Quickstart Wizard requests you to enter server host and port, specify `localhost` and UTBot server run port, respectively.
2930
![Oops, something went wrong! Please look at wizardInstall.gif](media/wizardInstall.gif "UTBot Wizard Demo")
30-
6. Select project path as `/home/utbot/UTBotCpp/integration-tests/c-example`;
31-
7. You are now ready to experience UTBot capabilities! You can view possible commands in Command Palette (Press F1 and type in UTBot).
31+
11. Select project path as `/home/utbot/UTBotCpp/integration-tests/c-example`;
32+
12. You are now ready to experience UTBot capabilities! You can view possible commands in Command Palette (Press F1 and type in UTBot).
3233

3334
If you want to change UTBot test generation preferences, you can edit them in File > Preferences > Settings > Extensions > UnitTestBot.
3435
After UTBot configuration, you can select your source directories with the tab on the VSCode toolbar on the left. Then, you can generate tests with the use of Command Palette. Press **F1** and type in "UTBot": You will see tests generation options.

build.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
set -e
77
set -o pipefail
88
pwd=$PWD
9-
chmod +x $pwd/klee/build.sh $pwd/Bear/build.sh $pwd/server/build.sh
10-
cd $pwd/klee && ./build.sh
11-
cd $pwd/Bear && ./build.sh
9+
chmod +x $pwd/submodules/klee/build.sh $pwd/submodules/Bear/build.sh $pwd/server/build.sh
10+
cd $pwd/submodules/klee && ./build.sh
11+
cd $pwd/submodules/Bear && ./build.sh
1212
cd $pwd/server && ./build.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
5+
#
6+
7+
chmod +x docker/action-scripts/build-utbot.sh
8+
./docker/action-scripts/build-utbot.sh
9+
cd server/build
10+
chmod +x UTBot_UnitTests
11+
./UTBot_UnitTests info --log `pwd`

docker/action-scripts/build-utbot.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
5+
#
6+
7+
source docker/building_dependencies/runtime_env.sh
8+
chmod +x build.sh
9+
./build.sh

docker/action-scripts/build-vsix.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
5+
#
6+
7+
source docker/building_dependencies/runtime_env.sh
8+
cd vscode-plugin
9+
echo $VERSION
10+
npm version $VERSION --allow-same-version
11+
utbot_dir="$(dirname $PWD)"
12+
npm install -g vsce --unsafe
13+
npm install --unsafe
14+
npm rebuild grpc --runtime=electron --target=7.3.0
15+
chmod +x protoc.sh && ./protoc.sh $utbot_dir/server/proto $utbot_dir/vscode-plugin/src/proto-ts
16+
npm run compile
17+
vsce package --no-yarn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
chmod +x docker/building_dependencies/install_packages/debian.sh && ./docker/building_dependencies/install_packages/debian.sh
4+
chmod +x docker/building_dependencies/clean_release.sh && ./docker/building_dependencies/clean_release.sh
5+
6+
mkdir $ARTIFACT_DIR
7+
chmod 777 $ARTIFACT_DIR
8+
9+
UTBOT_DISTR_FOLDER=$ARTIFACT_DIR/utbot_distr
10+
if [ -d "$UTBOT_DISTR_FOLDER" ]; then rm -rf $UTBOT_DISTR_FOLDER; fi
11+
12+
cp -r /utbot_distr $UTBOT_DISTR_FOLDER
13+
cp -a docker/release_distribution_scripts/. $UTBOT_DISTR_FOLDER/
14+
echo $VERSION > $ARTIFACT_DIR/version.txt
15+
16+
mv vscode-plugin/*.vsix $ARTIFACT_DIR/utbot_plugin.vsix
17+
mv docker/unpack_and_run_utbot.sh $ARTIFACT_DIR/unpack_and_run_utbot.sh
18+
19+
cd $ARTIFACT_DIR
20+
tar -czf utbot_distr.tar.gz utbot_distr
21+
rm -rf utbot_distr
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
3+
#
4+
5+
# This script clears out all the unnecessary files from the release build
6+
7+
# Need just clang-10, llvm-cov, llvm-profdata and cmake in $UTBOT_INSTALL_DIR/bin
8+
cd $UTBOT_INSTALL_DIR/bin && find -type f \( -name "*" ! -name "llvm-cov" ! -name "llvm-profdata" ! -name "llvm-nm" ! -name "clang" ! -name "clang++" ! -name "clang-10" ! -name cmake \) -delete
9+
10+
# Delete all broken links. Don't need to delete clang which is a link (not broken) to clang-10
11+
find $UTBOT_INSTALL_DIR/bin/ -xtype l -delete
12+
13+
# Delete all regular files in $UTBOT_INSTALL_DIR/lib except gold plugin, but not recursively
14+
cd $UTBOT_INSTALL_DIR/lib && find -maxdepth 1 -type f \( -name "*" ! -name "LLVMgold.so" ! -name "libz3.so*" \) -delete
15+
16+
#TODO some libs are needed:
17+
# Only certain libs should remain in $UTBOT_INSTALL_DIR/lib/clang/10.0.0/lib/linux
18+
#cd $UTBOT_INSTALL_DIR/lib/clang/10.0.0/lib/linux && find -maxdepth 1 -type f \( -name "*" ! -name "libclang_rt.ubsan_standalone-x86_64.a" ! -name "libclang_rt.ubsan_standalone_cxx-x86_64.a" ! -name "libclang_rt.profile-x86_64.a" \) -delete
19+
20+
rm -rf $UTBOT_ALL/klee/bin
21+
22+
# There should be just some klee libraries in klee/lib
23+
cd $UTBOT_ALL/klee/lib && find -type f \( -name "*" ! -name "libkleeRuntimeFp64_Debug+Asserts.bca" ! -name "libkleeRuntimeFp64_Debug+Asserts.bca" ! -name "libkleeRuntimeKLEELibc64_Debug+Asserts.bca" ! -name "libkleeRuntimeKLEELibc64_Debug+Asserts.bca" ! -name "libkleeRuntimeFreestanding64_Debug+Asserts.bca" ! -name "libkleeRuntimeIntrinsic64_Debug+Asserts.bca" ! -name "libkleeRuntimePOSIX64_Debug+Asserts.bca" ! -name "klee-uclibc.bca" \) -delete
24+
25+
# Previous command removed only regular files, need to remove also symlincs and then empty directories
26+
find $UTBOT_ALL/klee -type l -delete
27+
find $UTBOT_ALL/klee -type d -empty -delete
28+
29+
rm -rf $UTBOT_ALL/tsl
30+
rm -rf $UTBOT_ALL/parallel_hashmap
31+
rm -rf $UTBOT_ALL/cli
32+
rm -rf $UTBOT_ALL/json
33+
# we use klee libc
34+
rm -rf $UTBOT_ALL/uclibc/
35+
rm -rf $UTBOT_ALL/node_modules
36+
37+
# there should be error, it's okay, directory remains with some files
38+
# dpkg should remain because it is useful for apt update
39+
mv $UTBOT_ALL/debs-install/usr/share/dpkg ~ && rm -rf $UTBOT_ALL/debs-install/usr/share && mv ~/dpkg $UTBOT_ALL/debs-install/usr/share
40+
41+
rm -rf $UTBOT_INSTALL_DIR/include
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
3+
#
4+
5+
# This script downloads debian packages.
6+
# It installs libc6-dev package (which is dev version of libc) into $UTBOT_ALL/debian-libc-dev-install and other packages into $UTBOT_ALL/debs-install
7+
8+
set -e
9+
set -o pipefail
10+
11+
# Downloading apt-rdepends tool which can get all the dependencies for a package
12+
apt-get update && apt-get -y --no-install-recommends install apt-rdepends && apt-get update
13+
rm -rf /tmp/debian_dependencies && mkdir -p /tmp/debian_dependencies && cd /tmp/debian_dependencies
14+
# expand_aliases is used to support alias command properly in bash script
15+
shopt -s expand_aliases
16+
# A grep command which clears out the output of apt-rdepends
17+
alias grepdepends='grep -v "^ " | grep -v "^libc-dev$" | grep -v "^debconf-2.0$" | grep -v "^libc6$" | grep -v "^libunwind8-dev$" | grep -v "^awk$"'
18+
# Get all the dependencies of utbot
19+
apt-rdepends libsqlite3-dev libgoogle-perftools-dev libssl-dev python3-pip gzip make gcc-9 g++-9 | grepdepends > all.txt
20+
# Get all the dependencies of libc6-dev
21+
apt-rdepends libc6-dev | grepdepends > debian-libc-dev.txt
22+
# Get all the dependencies of utbot except all the dependencies of libc6-dev
23+
diff --new-line-format="" --unchanged-line-format="" <(sort all.txt) <(sort debian-libc-dev.txt) > all_without_libc-dev.txt || :
24+
25+
# A function which downloads all the dependencies from text file and extracts them.
26+
# Prerequisites: file path/to/file.txt exists
27+
# Arguments:
28+
# $1 = path/to/file The first argument is a path to a file without the .txt extension
29+
# The extracted packages will be located in $UTBOT_ALL/path/to/file-install directory
30+
get_debian_packages() {
31+
# Create a directory for .deb packages
32+
rm -rf $1 && mkdir -p $1 && cd $1
33+
# Download .deb packages
34+
apt-get download $(cat ../$1.txt)
35+
cd ..
36+
37+
# Extract all the .deb packages into $UTBOT_ALL/$1-install directory
38+
for filename in $1/*.deb; do
39+
dpkg-deb -x "$filename" $UTBOT_ALL/$1-install
40+
done
41+
}
42+
43+
# Get all packages except libc6-dev
44+
get_debian_packages all_without_libc-dev
45+
rm -rf $UTBOT_ALL/debs-install
46+
mv $UTBOT_ALL/all_without_libc-dev-install $UTBOT_ALL/debs-install
47+
# Get libc6-dev package and it's dependencies
48+
get_debian_packages debian-libc-dev
49+
50+
# Creating links to the current versions of gcc and python
51+
cd $UTBOT_ALL/debs-install/usr/bin
52+
ln -s python3 python
53+
ln -s gcov-9 gcov
54+
ln -s g++-9 g++
55+
ln -s gcc-9 gcc
56+
57+
# Setup python packages
58+
pip3 install --target=$UTBOT_ALL/debs-install/usr/local/lib/python3.4/dist-packages/ --ignore-installed typing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
5+
#
6+
7+
# This script launches cli for UTBot online
8+
#arguments: (generate | run) (path to project) (path to snippet)
9+
10+
if [ "$#" -ne 3 ] || { [ "$1" != "generate" ] && [ "$1" != "run" ]; };
11+
then
12+
echo "Illegal number of parameters. Check: (generate | run) (path-project) (path-snippet)"
13+
exit 1;
14+
fi
15+
16+
# Identify the directory where the current script is located
17+
export CURRENT_FOLDER="$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd )"
18+
# Get full path a script that launches UTBot
19+
RUN_SYSTEM_SCRIPT_PATH=$CURRENT_FOLDER/utbot_run_system.sh
20+
UTBOT_CLI_OPTIONS="$1 --project-path $2 file --file-path $3"
21+
# Launching cli
22+
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_OPTIONS

0 commit comments

Comments
 (0)