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

Add Github Actions CI #285

Merged
merged 36 commits into from Oct 10, 2019
Merged

Add Github Actions CI #285

merged 36 commits into from Oct 10, 2019

Conversation

DaanDeMeyer
Copy link
Contributor

Opening the pull request so I can start testing the configuration. I've started by taking reproc's Github Actions configuration and removing everything reproc related. Once that works I'll start adding all doctest related configuration.

@DaanDeMeyer
Copy link
Contributor Author

Current status can be followed here: https://github.com/DaanDeMeyer/doctest/actions

@DaanDeMeyer
Copy link
Contributor Author

Do you want each platform to use its native build system? I'm using Ninja everywhere at the moment which is extremely convenient but it does reduce the testing surface as we're only building with a single CMake generator.

On the other hand, doctest is a header-only library so the build system used to compile tests and examples shouldn't matter to the end user.

(I'm strongly in favor of just using Ninja everywhere as it makes my life a whole lot easier)

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented Sep 10, 2019

Are clang 3.5, 3.6 and 3.7 required for CI? LLVM does not provide Xenial apt repositories for those versions. If we want those I'll have to start juggling with ubuntu versions in the LLVM apt repository url's which is not impossible but makes stuff a little bit more complex.

EDIT: nvm, Canonical bundles those in its own package repositories so I can just get them from there.

@DaanDeMeyer
Copy link
Contributor Author

Do I have to keep all the sanitizer builds separate? There's a comment in the Travis config on knowing exactly what caused the test run to fail but can't you see that from the sanitizer output?

@onqtam
Copy link
Member

onqtam commented Sep 11, 2019

Hmmm I missed your comments here.

  • Using only ninja - absolutely!
  • if some compiler versions are a problem they could be skipped.
  • about the sanitizers - I don't understand the problem. If a sanitizer build fails for some reason the entire build should fail. If a sanitizer fails because of some bug in the compiler/sanitizer itself then that sanitizer is disabled for that build job. I mean... each build job in travis is for a specific compiler. Then for that compiler there are a bunch of builds which are done one after the other (debug/release, 32/64 bit, with sanitizers, etc.) and if any of them fails the whole build should fail, and sometimes some sanitizers are buggy in their integration with the host compiler.

@DaanDeMeyer
Copy link
Contributor Author

Yes, but currently you seem to do a separate build for each specific sanitizer in travis.yml (https://github.com/onqtam/doctest/blob/f13a00cc27ed3c1ec4f755572ab7556c4cb01716/.travis.yml#L372). I was wondering if I couldn't just do a single build with all sanitizers (asan, tsan and ubsan) combined (per compiler of course).

@onqtam
Copy link
Member

onqtam commented Sep 11, 2019

I think ASAN and UBSAN can be combined, but am really not sure about TSAN... But I'm also not sure we need debug vs release builds with the sanitizers... perhaps debug is enough?

@DaanDeMeyer
Copy link
Contributor Author

I'm wondering if we can't just go one step further and do a single build with everything enabled (including static analysis later). For reproc I just do a debug build in CI instead of both debug and release. Is it often that there are differences in debug/release builds in terms of test or build results?

@onqtam
Copy link
Member

onqtam commented Sep 11, 2019

the most common differences between debug/release have been warnings, so both build types are important.

@DaanDeMeyer
Copy link
Contributor Author

I'm kind of in an annoying situation where I don't want to make separate jobs for debug/release builds as it causes the job count to balloon but doing both in the same job requires an annoying amount of duplication because I can't use the same steps for Windows and POSIX due to Github Actions limitations and as a result have to add 3 steps each time I want to do something extra in a single job instead of a single one.

I've reported the issue (https://github.community/t5/GitHub-Actions/Support-global-environment-variables/m-p/30894#M601) but I'm not sure if or when it will be fixed.

@onqtam
Copy link
Member

onqtam commented Sep 12, 2019

Well for the duplication perhaps we could use a template engine to generate the actual github actions config file... Perhaps I should familiarize myself with the config format... I really don't have useful input at this point.

@DaanDeMeyer
Copy link
Contributor Author

I've made another post (https://github.community/t5/GitHub-Actions/Support-saving-environment-variables-between-steps/td-p/31373) detailing what would be needed to remove all duplication. For now, I'm going to wait and see if I get a positive reply there. While we can always work around the issue if needed, if the Github Actions team is open to fixing this it would results in a very simple CI script compared to the alternatives so I want to wait a while to see what happens.

@onqtam
Copy link
Member

onqtam commented Sep 20, 2019

Let me know whenever this is ready for a review - seems to pass now :)

@DaanDeMeyer
Copy link
Contributor Author

Still need to add a lot of stuff. I've been on vacation this week so I didn't really have time to finish it yet.

There's still a bit of duplication involved since we have to configure, build and test quite a few configurations so I might look into moving stuff into an actual Action so we can build a cross product of combinations with Javascript and reuse code for all those combinations.

@DaanDeMeyer
Copy link
Contributor Author

Also, while we do have 20 concurrent jobs, it does take quite a while for the second batch of remaining jobs to start after the first 20 complete so if we can remove some combinations in order to get the total amount of jobs down to 20 that would reduce waiting times for CI to complete somewhat.

Of course, it depends on whether there are configurations that can be dropped. If they are all important, there's always the chance that the speed of Github Actions improves later on as its still in beta.

@onqtam
Copy link
Member

onqtam commented Sep 20, 2019

I just checked and there are 31 different compiler jobs, so if all other actions/steps/builds are within a single per-compiler job then we would be left with 31 jobs in total, so 2 batches of GitHub Actions. I'm not sure it's worth optimizing around the '20' parallel jobs of Actions since that number could change in any direction in the future, and dropping compilers isn't ideal since we want as much testing as possible to minimize client issues/reports.

@onqtam
Copy link
Member

onqtam commented Sep 22, 2019

I just force-pushed into dev (after rebasing it on top of master and rebranching dev from master) and it seems that didn't play well with this PR and there are some conflicts, but I don't think there was any overlap besides with the filter_2 test, so hopefully it's easy to fix. Let me know if I should do something about it. Perhaps my git practices are questionable...

@onqtam
Copy link
Member

onqtam commented Oct 5, 2019

The most important thing is to compile and run the tests on as much compilers/platforms as possible. Sanitizers don't need to be enabled everywhere - there are plenty of toolchain issues which are just a waste of time and effort... Most projects settle with 1-2 configurations/compilers being tested with sanitizers and even if we disable some sanitizers for 1/2 of the compilers it would still be more than enough - so feel free to cut out the configs which are problematic, and for those which still require the gold linker - use that if it's easy.

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented Oct 5, 2019

I'm going to try a little bit more with this one as tests failing with sanitizers enabled on LTS Ubuntu with all major versions of GCC does not seem exactly confidence inspiring even if its an edge case feature.

I setup a Ubuntu bionic container using systemd-nspawn and managed to reproduce the issue in there. It turns out the tests aren't being registered simply because the call to dlopen is failing in main.cpp in executable_plugin_and_dll. I still need to find out exactly why this is the case when sanitizers are enabled in GCC (and why it only happens on Ubuntu).

@onqtam
Copy link
Member

onqtam commented Oct 5, 2019

FYI someone has already had a problem with GCC/sanitizers/plugins: #201

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented Oct 5, 2019

Adding -static-libasan to the compiler flags fixes the issue. I'm guessing the dlopen search paths when using sanitizers somehow differ from what's done normally.

Anyway, I'll just add -static-libasan to the compiler flags.

@DaanDeMeyer
Copy link
Contributor Author

address/undefined behaviour sanitizers are now enabled where possible. Should I add TSAN as well? I've always wondered why that one was needed for doctest.

@onqtam
Copy link
Member

onqtam commented Oct 5, 2019

TSAN is necessary for the concurrency.cpp tests where there are asserts and logging from multiple threads. TSAN once even helped catch a bug

@DaanDeMeyer
Copy link
Contributor Author

I think everything except coverage and static analysis is now running. Sanitizers are disabled on quite a few older compiler versions because those gave issues (See the Configure steps for the sanitizers). I also threw out the GCC 6 build on macOS as the concurrency test was flaky on that configuration. I also noticed we're now testing with a lot less xcode versions as the older ones Travis provides are not available on the Github Actions vm's.

I recommend that we add static analysis later via CMake's integrated support for clang-tidy and cppcheck. I do the same in reproc (https://github.com/DaanDeMeyer/reproc/blob/4818cd138fceb6d3cb5ffd97634f7f9cad6e805f/cmake/reproc.cmake#L108) for clang-tidy and it's pretty trivial to set up. The advantage is that clang-tidy can seamlessly run on every build configuration during the build. This does increase build times but I don't think that's a big problem in this case as doctest builds pretty fast.

This means that this is now ready for a review. I think the best way to go about this is you leave a comment on anything you don't immediately understand so I can add extra comments where needed. I already added quite a few comments but there might be stuff that I take for granted because I've been busy with this for quite a while.

@onqtam
Copy link
Member

onqtam commented Oct 7, 2019

I'll take a look after at least 1 week since I have a really tight deadline for a presentation. I'll let you know as soon as possible. On the point about static analysis - I completely agree. Thanks for the effort - great work!

@onqtam
Copy link
Member

onqtam commented Oct 10, 2019

it would be good to have --version called on the current compiler (whatever it is - I guess for cl.exe it's a different switch or it could just be called directly without a switch) at the start of each build after installing the compiler - just to be absolutely pedantic and aware which compiler version was used.

@onqtam
Copy link
Member

onqtam commented Oct 10, 2019

it would be good to have --version called on the current compiler (whatever it is - I guess for cl.exe it's a different switch or it could just be called directly without a switch) at the start of each build after installing the compiler - just to be absolutely pedantic and aware which compiler version was used.

nevermind - it's all in the detailed logs of the build because of the cmake config step :)

  • The CXX compiler identification is MSVC ... for VS
  • The CXX compiler identification is GNU for gcc and something similar for clang

Thanks for the great work! Squashing and merging!

@onqtam onqtam merged commit 154067f into doctest:dev Oct 10, 2019
@DaanDeMeyer
Copy link
Contributor Author

I did notice that out of habit I did everything with 2 spaces indentation while the rest of doctest uses 4 space indentation. Do you want me to switch everything to 4 spaces? I'd also recommend adopting a .editorconfig file in the repository which allows most editors to pick up this stuff automatically.

@onqtam
Copy link
Member

onqtam commented Oct 11, 2019

4 spaces sounds good (the 2 spaces thing I tried to stick to in travis.yml annoyed me quite a bit and I never even tried with 4 spaces...)

an editorconfig file would be fine as well :)

@onqtam onqtam changed the title WIP: Add Github Actions CI Add Github Actions CI Oct 26, 2019
onqtam pushed a commit that referenced this pull request Dec 16, 2019
Add Github Actions CI!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants