Skip to content

Conversation

bjoheimer
Copy link
Collaborator

Translated the Gitlab CI/CD pipeline to GitHub Actions and (hopefully) corrected an error with the test coverage check on the way.
Test coverage still does not fail the pipeline, but there is a TODO that the "exit 1" should be uncommented once the coverage is raised to an appropriate level.

@bjoheimer bjoheimer requested a review from av-runner November 15, 2024 15:57
@bjoheimer bjoheimer self-assigned this Nov 15, 2024
@bjoheimer
Copy link
Collaborator Author

That doesn't work like this. We need to docker this. Especially watch the clang-format version. Should be 18+, otherwise there will be differences between the local pre-commit and CLion reformat and the pipeline.

@bjoheimer
Copy link
Collaborator Author

This ain't it yet, there are two main problems:

  • I cannot install clang-format-18 and clang-tidy-18 on ubuntu 22.04 whatsoever. I am starting to believe this can only be fixed using a docker container.
  • The build artifacts are very weirdly cached. Somehow there is a surviving-sarntal/surviving-sarntal directory and the cmake-build-debug/test cannot be found in either?

Copy link

@MakisH MakisH left a comment

Choose a reason for hiding this comment

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

Hi there! I am looking into this after a hint by @carme-hp. I have a few comments that might help, especially regarding clang-format. Feel free to ask questions!

And yes, providing a Docker or Apptainer container would be great (not sure how easy it would be with graphical applications, maybe Apptainer is easier there). But you can also do that in a follow-up PR.

Comment on lines 61 to 64
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
Copy link

Choose a reason for hiding this comment

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

This seems to be unused at the moment. Are you trying to share something between jobs, or is it just a leftover?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is one of the main issues I am having right now. I am trying to share the cmake-build-debug dir created in the build job so we do not have to build the project again in every job. The dir is needed in the clang-tidy and the test job. However, this does not seem to work the way I want it to as the dir apparently cannot be found in the test job for example:

Run ctest --test-dir cmake-build-debug/test --rerun-failed --output-on-failure Failed to change working directory to "/home/runner/work/surviving-sarntal/surviving-sarntal/cmake-build-debug/test" : No such file or directory Internal ctest changing into directory: /home/runner/work/surviving-sarntal/surviving-sarntal/cmake-build-debug/test Error: Process completed with exit code 1.

Copy link

Choose a reason for hiding this comment

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

Independent of the direction you take next, I think that uploading/downloading artifacts is not intended for this use case.

I think this could be much easier if you indeed ran everything inside a container, because then you could write into a persistent directory (depends a bit on how you run the container).

Another alternative would be to not split multiple jobs, but just have one job with multiple steps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed. The persistent directory is why we will try with docker container next (see comment below) 👍

Comment on lines +73 to +81
# Remove percentage symbol and compare numeric value
COVERAGE_VALUE=$(echo "$COVERAGE" | sed 's/%//')
if [ "$COVERAGE_VALUE" -lt 80 ]; then
echo "Coverage is below 80%! Failing pipeline."
# TODO once the test coverage is high enough, we should fail the pipeline here
# exit 1
else
echo "Coverage is sufficient: $COVERAGE_VALUE%"
fi
Copy link

Choose a reason for hiding this comment

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

You could also store the coverage value in a file and check if the PR increases or decreases the coverage. This would be easier to track than eventually (and cumulatively) dropping below a threshold.

Or run lcov on both branches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is a great idea! I will tackle this once the pipeline is up and running.

Comment on lines +106 to +111
- name: Debug LLVM Binaries
run: |
sudo find /usr /lib /opt -name clang-format-18 -o -name clang-tidy-18
dpkg-query -L clang-format-18 || echo "clang-format-18 not found in package files"
llvm-config --bindir || echo "llvm-config not installed or misconfigured"
echo $PATH
Copy link

Choose a reason for hiding this comment

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

All the clang-format setup looks too complicated. Do you know that you can get any clang-format version from pip?

https://pypi.org/project/clang-format/

You could also use a predefined clang-format action or, even better, use a predefined pre-commit hook. See an example in https://github.com/precice/precice/blob/develop/.pre-commit-config.yaml

Copy link
Collaborator Author

@bjoheimer bjoheimer Nov 21, 2024

Choose a reason for hiding this comment

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

The setup was originally not that complicated. Those are just remnants of my efforts to debug the pipeline and will be removed.
I did not know that I could install clang via pip and I will try this tmrw.
I do have pre-commit hooks in place running clang-format and clang-tidy locally on the changed files. However we agreed on running the two in the pipeline as well on all our src files as there are some errors clang-tidy only catches when looking at all files.

Copy link

Choose a reason for hiding this comment

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

You could still run pre-commit on all files in the CI (pre-commit run -a).
The advantage of integrating pre-commit in the CI is that you avoid duplication and get the same checks that a developer should also get locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is smart. Originally, we had a very weak runner which is why we split up the pre-commit linting into clang-format and clang-tidy. clang-tidy needs a build which took forever on our old runner, so we performed clang-format first so that the pipe "fails fast". However, now performance is no longer an issue, so it is sensible to reuse the pre-commit checks for the reasons you mentioned.

Comment on lines 153 to 156
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
Copy link

Choose a reason for hiding this comment

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

Same comment as above: Do you need this?

Copy link
Collaborator Author

@bjoheimer bjoheimer Nov 20, 2024

Choose a reason for hiding this comment

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

Yes, if it does what I assume it does, I need the compile_commands.json file which is outputted to cmake-build-debug during the build.

bjoheimer and others added 4 commits November 20, 2024 19:01
Update upload-artifact action from v3 to v4 as v3 support runs out

Co-authored-by: Gerasimos Chourdakis <gerasimos.chourdakis@ipvs.uni-stuttgart.de>
@bjoheimer
Copy link
Collaborator Author

bjoheimer commented Nov 21, 2024

Thank you very much for the review. I learned that @av-runner already has some experience with docker and even wrote a dockerfile for this project. We will take a look at this on Monday. Presumably using docker is a good solution. There are also no issues with running the pipeline in the container as we mock all output services in our tests. It should also avoid the problem with caching and reusing dependencies and build files we had so far.

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.

3 participants