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

AVRO-3423: Add build.sh step to encapsulate all the steps needed during release #1570

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
10dfc37
Add build.sh release
Feb 26, 2022
041cea3
Add quptes
Feb 26, 2022
9728e4e
Call dist drom release if needed
Feb 26, 2022
37969df
Use RELELEASE=1 approach
Feb 26, 2022
d44f97c
Combine dist and release
Feb 26, 2022
01b00b1
Add verify-release
Feb 27, 2022
9cb6f7b
Add ask shell function
Feb 28, 2022
094e4bf
Add disable ask
Feb 28, 2022
24b9597
Add ask to release
Mar 1, 2022
ea34d82
Add ask to release
Mar 1, 2022
58087e9
Add dry run option to build.sh
Mar 8, 2022
1b4bb56
Tweak interop-data-test
Mar 8, 2022
4529ceb
Tweak test
Mar 8, 2022
ca37318
Add build-helper.sh
Mar 8, 2022
cc31d5f
Add execute helper function
Mar 8, 2022
5fb53d3
Add other languages
Mar 8, 2022
c289053
Move lines to end
Mar 8, 2022
cfe026e
Merge branch 'master' into avro-3424-add-build-sh-release-csharp
Mar 8, 2022
df4be9d
AVRO-3424: Add 'release' step for the Rust SDK
martin-g Mar 8, 2022
c9ca4bc
Fix C build.sh
Mar 8, 2022
30ed375
Merge branch 'avro-3424-add-build-sh-release-csharp' of github.com:zc…
Mar 8, 2022
3f09206
Change dir into build.sh folder
Mar 8, 2022
5f7621e
Fix whitespaces
Mar 8, 2022
b7c4e58
Lang specific options are set via env vars for now
Mar 8, 2022
c0cd424
Remove BUILD_DESCRIPTION
Mar 9, 2022
c9ced07
Support extra commands
Mar 9, 2022
c9f26d5
Measure build time
Mar 9, 2022
0e61c64
Nothing to do
Mar 9, 2022
5fc2a2b
Fix shellcheck warnings
Mar 9, 2022
3f127f6
Use globbing instead of find to match files
Mar 9, 2022
7432a4c
aa
martin-g May 12, 2022
4757ead
Merge branch 'master' into avro-3424-add-build-sh-release-csharp
martin-g May 12, 2022
69772c3
AVRO-3423: Update the `dist` and `release` steps for Rust module
martin-g May 13, 2022
6ebfc85
AVRO-3423: Fix Bash Shell syntax. Return true in the function
martin-g May 13, 2022
bdc773c
Merge master
Sep 18, 2023
388daa3
Add command_doc
Sep 18, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/test-lang-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ jobs:
run: ./build.sh interop-data-generate

- name: Run Interop Tests
run: ./build.sh test-interop
run: ./build.sh interop-data-test
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ do
(cd lang/csharp; ./build.sh interop-data-test)
(cd lang/js; ./build.sh interop-data-test)
(cd lang/ruby; ./build.sh interop-data-test)
(cd lang/php; ./build.sh test-interop)
(cd lang/php; ./build.sh interop-data-test)
(cd lang/perl; ./build.sh interop-data-test)

# java needs to package the jars for the interop rpc tests
Expand Down
132 changes: 65 additions & 67 deletions lang/c/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,84 +20,82 @@

set -e # exit on error

cd "$(dirname "$0")" # If being called from another folder, cd into the directory containing this script.

# shellcheck disable=SC1091
source ../../share/build-helper.sh "C"

root_dir=$(pwd)
build_dir="../../build/c"
dist_dir="../../dist/c"
build_dir="$BUILD_ROOT/build/c"
dist_dir="$BUILD_ROOT/dist/c"
version=$(./version.sh project)
tarball="avro-c-$version.tar.gz"
doc_dir="../../build/avro-doc-$version/api/c"
doc_dir="$BUILD_ROOT/build/avro-doc-$version/api/c"

function prepare_build {
clean
mkdir -p $build_dir
(cd $build_dir && cmake $root_dir -DCMAKE_BUILD_TYPE=RelWithDebInfo)
function prepare_build()
{
command_clean
execute mkdir -p "$build_dir"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is execute defined?

Copy link
Contributor Author

@zcsizmadia zcsizmadia Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

share/build-helper.sh in the PR. The main reason behind the execute concept was to be able to have a --dry-run option, where the build.sh just prints out what would be running. The user can copy paste it and run it manually step by step if needed, or just simply checking the steps. Additionally there is a step option, IIRC I implemented it :) Wit enables to user to execute the build scripts step by step.

The build helper is pretty much the common code between all the build scripts and all build scripts include it. It has the execute implementation, the common help, the colored logging, etc.

execute pushd "$build_dir"
execute cmake "$root_dir" -DCMAKE_BUILD_TYPE=RelWithDebInfo
execute popd
}

function clean {
if [ -d $build_dir ]; then
find $build_dir | xargs chmod 755
rm -rf $build_dir
function command_clean()
{
if [ -d "$build_dir" ]; then
execute find "$build_dir" -exec chmod 755 {} +
execute rm -rf "$build_dir"
fi
rm -f VERSION.txt
rm -f examples/quickstop.db
execute rm -f VERSION.txt
execute rm -f examples/quickstop.db
}

for target in "$@"
do

case "$target" in

interop-data-generate)
prepare_build
make -C $build_dir
$build_dir/tests/generate_interop_data "../../share/test/schemas/interop.avsc" "../../build/interop/data"
;;

interop-data-test)
prepare_build
make -C $build_dir
$build_dir/tests/test_interop_data "../../build/interop/data"
;;

lint)
echo 'This is a stub where someone can provide linting.'
;;

test)
prepare_build
make -C $build_dir
make -C $build_dir test
;;
function command_interop-data-generate()
{
prepare_build
execute make -C "$build_dir"
execute "$build_dir/tests/generate_interop_data" "$BUILD_ROOT/share/test/schemas/interop.avsc" "$BUILD_ROOT/build/interop/data"
}

dist)
prepare_build
cp ../../share/VERSION.txt $root_dir
make -C $build_dir docs
# This is a hack to force the built documentation to be included
# in the source package.
cp $build_dir/docs/*.html $root_dir/docs
make -C $build_dir package_source
rm $root_dir/docs/*.html
if [ ! -d $dist_dir ]; then
mkdir -p $dist_dir
fi
if [ ! -d $doc_dir ]; then
mkdir -p $doc_dir
fi
mv $build_dir/$tarball $dist_dir
cp $build_dir/docs/*.html $doc_dir
clean
;;
function command_interop-data-test()
{
prepare_build
execute make -C "$build_dir"
execute "$build_dir/tests/test_interop_data" "$BUILD_ROOT/build/interop/data"
}

clean)
clean
;;
function command_lint()
{
echo 'This is a stub where someone can provide linting.'
}

*)
echo "Usage: $0 {interop-data-generate|interop-data-test|lint|test|dist|clean}"
exit 1
esac
function command_test()
{
prepare_build
execute make -C "$build_dir"
execute make -C "$build_dir" test
}

done
function command_dist()
{
prepare_build
execute cp "$BUILD_ROOT/share/VERSION.txt" "$root_dir"
execute make -C "$build_dir" docs
# This is a hack to force the built documentation to be included
# in the source package.
execute cp "$build_dir"/docs/*.html "$root_dir/docs"
execute make -C "$build_dir" package_source
execute rm "$root_dir"/docs/*.html
if [ ! -d "$dist_dir" ]; then
execute mkdir -p "$dist_dir"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're using mkdir -p we don't need to check if the dir already exists first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger. I followed the original build.sh scripts as much to the letter as possible. At this stage my objective was to be able to easily compare roiginal build shells cripts with the new ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but since you're adding execute doesn't that make it kind of moot?

fi
if [ ! -d "$doc_dir" ]; then
execute mkdir -p "$doc_dir"
fi
execute mv "$build_dir/$tarball" "$dist_dir"
execute cp "$build_dir"/docs/*.html "$doc_dir"
command_clean
}

exit 0
build-run "$@"
202 changes: 120 additions & 82 deletions lang/csharp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,85 +15,123 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -e # exit on error
set -x

cd `dirname "$0"` # connect to root

ROOT=../..
VERSION=`cat $ROOT/share/VERSION.txt`

for target in "$@"
do

case "$target" in

lint)
echo 'This is a stub where someone can provide linting.'
;;

test)
dotnet build --configuration Release Avro.sln

# AVRO-2442: Explicitly set LANG to work around ICU bug in `dotnet test`
LANG=en_US.UTF-8 dotnet test --configuration Release --no-build \
--filter "TestCategory!=Interop" Avro.sln
;;

perf)
pushd ./src/apache/perf/
dotnet run --configuration Release --framework net6.0
;;

dist)
# pack NuGet packages
dotnet pack --configuration Release Avro.sln

# add the binary LICENSE and NOTICE to the tarball
mkdir -p build/
cp LICENSE NOTICE build/

# add binaries to the tarball
mkdir -p build/main/
cp -R src/apache/main/bin/Release/* build/main/
# add codec binaries to the tarball
for codec in Avro.File.Snappy Avro.File.BZip2 Avro.File.XZ Avro.File.Zstandard
do
mkdir -p build/codec/$codec/
cp -R src/apache/codec/$codec/bin/Release/* build/codec/$codec/
done
# add codegen binaries to the tarball
mkdir -p build/codegen/
cp -R src/apache/codegen/bin/Release/* build/codegen/

# build the tarball
mkdir -p ${ROOT}/dist/csharp
(cd build; tar czf ${ROOT}/../dist/csharp/avro-csharp-${VERSION}.tar.gz main codegen LICENSE NOTICE)

# build documentation
doxygen Avro.dox
mkdir -p ${ROOT}/build/avro-doc-${VERSION}/api/csharp
cp -pr build/doc/* ${ROOT}/build/avro-doc-${VERSION}/api/csharp
;;

interop-data-generate)
dotnet run --project src/apache/test/Avro.test.csproj --framework net6.0 ../../share/test/schemas/interop.avsc ../../build/interop/data
;;

interop-data-test)
LANG=en_US.UTF-8 dotnet test --filter "TestCategory=Interop" --logger "console;verbosity=normal;noprogress=true" src/apache/test/Avro.test.csproj
;;

clean)
rm -rf src/apache/{main,test,codegen,ipc,msbuild,perf}/{obj,bin}
rm -rf build
rm -f TestResult.xml
;;

*)
echo "Usage: $0 {lint|test|clean|dist|perf|interop-data-generate|interop-data-test}"
exit 1

esac

done
set -e

shopt -s globstar # enable **/* globbing
shopt -s nullglob # return nothing if no glob match

cd "$(dirname "$0")" # If being called from another folder, cd into the directory containing this script.

# shellcheck disable=SC1091
source ../../share/build-helper.sh "C#"

CSHARP_CODEC_LIBS="Avro.File.Snappy Avro.File.BZip2 Avro.File.XZ Avro.File.Zstandard"
SUPPORTED_SDKS="3.1 5.0 6.0"
DEFAULT_FRAMEWORK="net6.0"
CONFIGURATION="Release"

function command_lint()
{
echo "This is a stub where someone can provide linting."
}

function command_test()
{
execute dotnet build --configuration $CONFIGURATION Avro.sln

# AVRO-2442: Explicitly set LANG to work around ICU bug in `dotnet test`
execute LANG=en_US.UTF-8 dotnet test --configuration "$CONFIGURATION" --no-build --filter "TestCategory!=Interop" Avro.sln
}

function command_perf()
{
execute pushd ./src/apache/perf/
execute dotnet run --configuration "$CONFIGURATION" --framework "$FRAMEWORK"
}

function command_dist()
{
# pack NuGet packages
execute dotnet pack --configuration "$CONFIGURATION" Avro.sln

# add the binary LICENSE and NOTICE to the tarball
execute mkdir -p build/
execute cp LICENSE NOTICE build/

# add binaries to the tarball
execute mkdir -p build/main/
execute cp -R src/apache/main/bin/$CONFIGURATION/* build/main/
# add codec binaries to the tarball
for codec in $CSHARP_CODEC_LIBS
do
execute mkdir -p build/codec/"$codec"/
execute cp -R src/apache/codec/"$codec"/bin/$CONFIGURATION/* build/codec/"$codec"/
done
# add codegen binaries to the tarball
execute mkdir -p build/codegen/
execute cp -R src/apache/codegen/bin/$CONFIGURATION/* build/codegen/

# build the tarball
execute mkdir -p "${BUILD_ROOT}/dist/csharp"
execute pushd build
execute tar czf "${BUILD_ROOT}/../dist/csharp/avro-csharp-${BUILD_VERSION}.tar.gz" main codegen LICENSE NOTICE
execute popd

# build documentation
execute doxygen Avro.dox
execute mkdir -p "${BUILD_ROOT}/build/avro-doc-${BUILD_VERSION}/api/csharp"
execute cp -pr build/doc/* "${BUILD_ROOT}/build/avro-doc-${BUILD_VERSION}/api/csharp"
}

function command_release()
{
[ "$NUGET_SOURCE" ] || NUGET_SOURCE="https://api.nuget.org/v3/index.json"
[ "$NUGET_KEY" ] || fatal "NUGET_KEY not set"

command_dist

# Push packages to nuget.org
for package in ./build/**/*.nupkg
do
ask "Push $package to nuget.org" && execute dotnet nuget push "$package" -k "$NUGET_KEY" -s "$NUGET_SOURCE"
done
}

function command_verify-release()
{
for sdk_ver in $SUPPORTED_SDKS
do
execute docker run -it --rm mcr.microsoft.com/dotnet/sdk:"$sdk_ver" /bin/bash -ce "\
mkdir test-project && \
cd test-project && \
dotnet new console && \
dotnet add package Apache.Avro --version $BUILD_VERSION && \
for codec in $CSHARP_CODEC_LIBS; do \
dotnet add package Apache.\$codec --version $BUILD_VERSION; \
done && \
dotnet build && \
dotnet tool install --global Apache.Avro.Tools --version $BUILD_VERSION && \
export PATH=\$PATH:/root/.dotnet/tools && \
avrogen --help"
done
echo "Verified"
}

function command_interop-data-generate()
{
execute dotnet run --project src/apache/test/Avro.test.csproj --framework $DEFAULT_FRAMEWORK ../../share/test/schemas/interop.avsc ../../build/interop/data
}

function command_interop-data-test()
{
execute LANG=en_US.UTF-8 dotnet test --filter 'TestCategory=Interop' --logger 'console\;verbosity=normal\;noprogress=true' src/apache/test/Avro.test.csproj
}

function command_clean()
{
execute rm -rf src/apache/{main,test,codegen,ipc,msbuild,perf}/{obj,bin}
execute rm -rf build
execute rm -f TestResult.xml
}

build-run "$@"
Loading