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

Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 and Windows-msys2 workflows #1666

Merged
merged 15 commits into from
Nov 9, 2021

Conversation

maxirmx
Copy link
Member

@maxirmx maxirmx commented Nov 1, 2021

@maxirmx maxirmx requested review from dewyatt and ronaldtse November 1, 2021 21:09
@maxirmx
Copy link
Member Author

maxirmx commented Nov 1, 2021

@ronaldtse
I added Clang builds to Ubuntu jobs and it works.
I would say that it is expected behavior since Clangs team maintains strong compatibility with gcc.
Is that what we are looking for or I misunderstand the task ?

@ronaldtse
Copy link
Contributor

@maxirmx yes it should pass as we know that Thunderbird is using this configuration.

@kaie whom should we seek if we want to know what CI configurations we should test to ensure builds at TB work? Thanks!

@ronaldtse ronaldtse requested a review from ni4 November 2, 2021 06:41
Copy link
Contributor

@ni4 ni4 left a comment

Choose a reason for hiding this comment

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

I'd suggest to remove redundant tests, where we (most likely) do not need to check different compilers.

.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
Clang build and test for the following workflows:
- centos7
- centos8-ossl
- centos8
- debian9
- macos
- ubuntu

Fixed:
- #1670
- #1669
- #1668
- Packaging tests for centos8 (gcc and clang)
@maxirmx maxirmx changed the title Added Clang builds to Ubuntu jobs Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 jobs Nov 6, 2021
@maxirmx
Copy link
Member Author

maxirmx commented Nov 6, 2021

Clang build and test for the following workflows:

  • centos7
  • centos8-ossl
  • centos8
  • debian9
  • macos
  • ubuntu
  • windows (msys)

Fixed:

@maxirmx maxirmx changed the title Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 jobs Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 workflows Nov 6, 2021
* Added clang to msys workflow
* Removed empty lines
* Commented out test we think we do not need
* Added clang build\test to Msys workflow
* Fixed ci scripts issues reported by lint
@maxirmx maxirmx changed the title Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 workflows Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 and Woindows-msys2 workflows Nov 7, 2021
@maxirmx maxirmx changed the title Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 and Woindows-msys2 workflows Added Clang builds to Ubuntu, CentOS7, CentOS8 (+ ossl), MacOS, Debian9 and Windows-msys2 workflows Nov 7, 2021
@maxirmx
Copy link
Member Author

maxirmx commented Nov 7, 2021

@ronaldtse @ni4

I believe this PR is ready for merge. All changes are listed in the previous comment:#1666 (comment)

Some general considerations:

  1. This PR is about changes to YAML and CI shell scripts so that they could generate correct clang configurations. I reduced the number of tests as @ni4 asked in his review but I have some doubts that such reduction is consistent.

  2. CI shell scripts are very difficult to understand, modify and maintain. I believe they need refactoring and using package manager (or managers) as use vcpkg for all platforms #1648 suggests would be a good approach. Investigate streamlining CI processes to reduce time on cross-platform debugging #1508 will also work but it will force using specific (possibly outdated) versions of dependencies.

@ronaldtse
Copy link
Contributor

  1. CI shell scripts are very difficult to understand, modify and maintain. I believe they need refactoring and using package manager (or managers) as use vcpkg for all platforms #1648 suggests would be a good approach. Investigate streamlining CI processes to reduce time on cross-platform debugging #1508 will also work but it will force using specific (possibly outdated) versions of dependencies.

I agree. Let's merge this first and migrate to a package manager?

Copy link
Contributor

@ronaldtse ronaldtse left a comment

Choose a reason for hiding this comment

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

Thank you @maxirmx !

.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/windows.yml Outdated Show resolved Hide resolved
libtool
bzip2
gzip
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra preceding whitespace for these lines?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not agree. I made identation consistent. Without extra whitespace these 4 lines have identation that differs from the code before and after.

Copy link
Contributor

Choose a reason for hiding this comment

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

Those seem to have 2-space indentation before the changes, or do I miss something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it had double spaces before the changes and it has double spaces after changes.
I think there was a version in the middle that had wrong spacing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the version here is the version that has wrong spacing :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with everything you say about spacing and empty lines.

@ronaldtse
Copy link
Contributor

Ping @ni4 @ribose-jeffreylau for one more review.

@ronaldtse
Copy link
Contributor

@maxirmx it's okay to have this merged right now since it is only CI related.

@maxirmx
Copy link
Member Author

maxirmx commented Nov 9, 2021

@ronaldtse
It now has a conflict with #1681
Sorry, I wanted to merge the opposite direction

Copy link
Contributor

@ribose-jeffreylau ribose-jeffreylau left a comment

Choose a reason for hiding this comment

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

@maxirmx I left some comments above. Thanks!

export CC=gcc
export CXX=g++
export CC=${CC-gcc}
export CXX=${CXX-g++}
Copy link
Contributor

Choose a reason for hiding this comment

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

If $CC (and $CXX) are set to empty strings, after CC=${CC-gcc}, $CC would still remain as empty strings. Is this intended? (similar with $CXX)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, there is a trailing white space on line 9.

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

This is protection against CC/CXX unset.
CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

Actually it is an interesting issue related to CI logic consistency.
CI logic is distributed accross YAML-shell scripts-cmake If thess shell scripts are always called from GHA you can ensure that CC and other variablle are set in YAML. Would you like to rely on this scenario only or hacve some extra logic that make scripts work reliably without GHA ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I didn't know about cmake's behaviour on empty string CC :) Thanks!

Before your reply, I would have preferred export CC=${CC:-gcc} with the extra colon, so CC would actually explicitly take on the value of "gcc" instead of becoming an empty string when CC is originally unset.

Observe:

$ unset TEST
$ echo "${TEST-this is a test}"
this is a test
$ TEST=
$ echo "${TEST-this is a test}"

$ echo  "${TEST:-this is a test}"
this is a test

Actually it is an interesting issue related to CI logic consistency.
CI logic is distributed accross YAML-shell scripts-cmake If thess shell scripts are always called from GHA you can ensure that CC and other variablle are set in YAML. Would you like to rely on this scenario only or hacve some extra logic that make scripts work reliably without GHA ?

For now, I think we can safely assume that these scripts are always run within GHA, as long as they live inside ci/.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I also put export CC=${CC:-gcc} first but then I relized that if empty string comes from the upstream it does not hurt but may have some idea behind it.

libtool
bzip2
gzip
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the version here is the version that has wrong spacing :)

@@ -522,6 +526,17 @@ linux_install_debian() {
"${build_dependencies_deb[@]}" \
"$@"

if [ "${CC-gcc}" = "clang" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue as above --- with $CC set to empty string, "${CC-gcc}" would still be empty string. Is this intended?

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

mingw64/mingw-w64-x86_64-python3
)

if [ "${CC-gcc}" = "gcc" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

pacman --noconfirm -S --needed "${packages[@]}"

if [ "${CC-gcc}" = "gcc" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

@@ -833,7 +866,7 @@ build_example_pkgconfig() {
pushd "$(mktemp -d)" || return 1

# shellcheck disable=SC2046
gcc "${rnpsrc}/src/examples/generate.c" -ogenerate $(pkg-config --cflags --libs $pkgflags librnp) $gccflags
${CC-gcc} "${rnpsrc}/src/examples/generate.c" -ogenerate $(pkg-config --cflags --libs $pkgflags librnp) $gccflags
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here, when CC is an empty string, ${CC-gcc} would actually remain an empty string. See my comment above.

export PATH="${LOCAL_BUILDS}/rnp-build/lib:${LOCAL_BUILDS}/rnp-build/bin:${LOCAL_BUILDS}/rnp-build/src/lib:$PATH"
if [[ "${CC-gcc}" = "clang" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

@maxirmx maxirmx Nov 9, 2021

Choose a reason for hiding this comment

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

CC="" will force cmake default which will be gcc. If CC is unset it will also force cmake default but it may fail at this line depending on shell settings.

@@ -32,11 +32,22 @@ prepare_build_prerequisites() {
prepare_test_env() {
prepare_build_tool_env

export LD_LIBRARY_PATH="${GPG_INSTALL}/lib:${BOTAN_INSTALL}/lib:${JSONC_INSTALL}/lib:${RNP_INSTALL}/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="${GPG_INSTALL}/lib:${BOTAN_INSTALL}/lib:${JSONC_INSTALL}/lib:${RNP_INSTALL}/lib:${LD_LIBRARY_PATH-}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would an improvement be:

export ...="...:${RNP_INSTALL}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"

so that if $LD_LIBRARY_PATH is an empty string, there would not be a trailing colon?

Copy link
Member Author

Choose a reason for hiding this comment

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

If $LD_LIBRARY_PATH is unset the script won't fail

Copy link
Contributor

Choose a reason for hiding this comment

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

If $LD_LIBRARY_PATH is unset the script won't fail

In which case $LD_LIBRARY_PATH would end up having a trailing : at the end. I'm not familiar with the behaviour of $LD_LIBRARY_PATH with empty components, but if it's what's commonly accepted then I'm fine with it :)

git
automake
autoconf
libtool
automake-wrapper
gnupg2
make
pkg-config
pkg-config
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a trailing white space here.

Comment on lines +183 to +207
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup environment
run: |
. ci/gha/setup-env.inc.sh
ci/install_noncacheable_dependencies.sh
- name: Cache
id: cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_DIR }}
key: ${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{ env.BUILD_MODE }}-gpg-${{ env.GPG_VERSION }}-${{ hashFiles('ci/**') }}-${{ hashFiles('.github/workflows/**') }}
- name: Build cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
set -x
ci/install_cacheable_dependencies.sh
- name: tests
run: |
set -x
ci/run.sh
ls -la "${RNP_INSTALL}/lib/"librnp*.so
! ctest -N | grep 'ruby' > /dev/null
! ls -la src/tests/ | grep 'ruby' > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these lines have been indented by 11 white spaces? Maybe an accident?

@ni4
Copy link
Contributor

ni4 commented Nov 9, 2021

@maxirmx some other side notes:

  • we got used to the branch naming like maxirmx-1129-build-with-clang-cl
  • we also prefer to rebase on master instead of merge, squashing together commits like 'fix of fix', 'fix pr comment'. Interactive rebase makes this easy and straightforward.

@maxirmx
Copy link
Member Author

maxirmx commented Nov 9, 2021

  • we got used to the branch naming like maxirmx-1129-build-with-clang-cl

Does 'ni4-fix-rnp-hash-destructutor' follow this rule ?

@ronaldtse
Copy link
Contributor

@maxirmx we usually use {username}-{topic} as a development branch name under the rnp repo when it is shared. If the PR comes from a forked repository, the branch name isn't important.

@ni4
Copy link
Contributor

ni4 commented Nov 10, 2021

  • we got used to the branch naming like maxirmx-1129-build-with-clang-cl

Does 'ni4-fix-rnp-hash-destructutor' follow this rule ?

In this case there were no issue created for, so, yeah, no issue number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants