Initialize CI for PullRequest Testing#4767
Conversation
fetching 5 commits hopefully we are then able to compare with the branch to be merged with
correct url to reports
correct url to reports 2.0
removing empty spaces in Modelica.Blocks.Continuous.LimPID
beutlich
left a comment
There was a problem hiding this comment.
The log is pretty verbose and it's not obvious what might be the reason for failure at first sight.
I have saome ideas:
- Can we reduce the log verbosity. Can we have a configurable log verbosity.
- Can we add problem matchers? See for example https://github.com/modelica/ModelicaStandardLibrary/blob/master/.github/moparser.json or https://oneuptime.com/blog/post/2026-01-30-github-actions-problem-matchers/view.
- Can we upload the comparison reports using actions/upload-artifact?
| name: PR_testing | ||
| on: | ||
| # Triggers the workflow on push or pull request events but only for the "main" branch | ||
| pull_request: | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel |
There was a problem hiding this comment.
| name: PR_testing | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the "main" branch | |
| pull_request: | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| name: CI ReSim | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
| jobs: | ||
| prepare: | ||
| runs-on: self-hosted |
There was a problem hiding this comment.
| runs-on: self-hosted | |
| runs-on: [ self-hosted, linux, regression-testing ] |
| prepare: | ||
| runs-on: self-hosted | ||
| steps: | ||
| - name: checkout_pr_repo |
There was a problem hiding this comment.
| - name: checkout_pr_repo | |
| - name: Checkout code |
|
|
||
| testrun_modelica: | ||
| needs: prepare | ||
| runs-on: self-hosted |
There was a problem hiding this comment.
| runs-on: self-hosted | |
| runs-on: [ self-hosted, linux, regression-testing ] |
| needs: prepare | ||
| runs-on: self-hosted | ||
| environment: | ||
| name: link_modelica |
There was a problem hiding this comment.
| name: link_modelica | |
| name: Build libraries |
Not sure, what is meant by "link".
| name: link_modelica | ||
| url: https://serv.ltx.de/prs/${{ github.event.number }}/Modelica/report/PR_comparison_report.html | ||
| steps: | ||
| - name: run modelica |
There was a problem hiding this comment.
| - name: run modelica | |
| - name: Run tests |
| needs: prepare | ||
| runs-on: self-hosted | ||
| environment: | ||
| name: link_modelicatest |
There was a problem hiding this comment.
| name: link_modelicatest | |
| name: Build libraries |
There was a problem hiding this comment.
The enviroment is meant to create\show the links to the reports.
So "Report modelicatest" might be a good name
| name: link_modelicatest | ||
| url: https://serv.ltx.de/prs/${{ github.event.number }}/ModelicaTest/report/PR_comparison_report.html | ||
| steps: | ||
| - name: run modelicatest |
There was a problem hiding this comment.
| - name: run modelicatest | |
| - name: Run tests |
| runs-on: self-hosted | ||
| environment: | ||
| name: link_modelica | ||
| url: https://serv.ltx.de/prs/${{ github.event.number }}/Modelica/report/PR_comparison_report.html |
There was a problem hiding this comment.
Do not use hard-coded URIs for https://serv.ltx.de (here and in other places), instead prefer variables via https://github.com/modelica/ModelicaStandardLibrary/settings/variables/actions. This way LTX can move its server while workflow keeps untouched.
| runs-on: self-hosted | ||
| steps: | ||
| - name: checkout_pr_repo | ||
| run: /home/resimuser/regression_testing/docker/work/run_scripts/prepare_pr.sh ${{ github.event.number }} |
There was a problem hiding this comment.
For the sake of transparancy, can we add all the CI bash scripts to a new folder ReSim in .CI? Otherwise it will be pure magic for library officers. Usually and as best practice the CI scripts are maintained along with the repo under test.
There was a problem hiding this comment.
@beutlich
Thank you for your detailed review !
1.) I know, log is pretty verbose. But it is not really meant to be analyzed. Finding errors (like example Modelica.Blocks.Examples.xxx is not running anymore due to the changes in the PR) can be done in the published reports. The log is more or less to analyze possible errors in the workflow itself by us (LTX). We can reduce the logging once we are sure the workflow is stable. (without any changes inside this repository)
2.) probably we could introduce problem matchers, but may not be necessary due to 1.)
3.) We discussed this in the MAP-LIB meetings. Upload artifacts would induce the need to download the reports (which are not that small) , unzip and then open in a browser. These steps, we want to avoid, making the reports directly clickable by publishing on our server.
4.) Thank you for the very good hint with the variables instead of hard links!
5.)We can publish the main shell scripts called by the CI. But these are mainly running the Modelica tools inside docker containers. And we wont publish our regression testing tool itself, nor the docker files, due to intellectual property. So publishing the scripts is only partially helpful concerning transparency, but would induce a change of these scripts (and such a change in the MSL) in order to add a further Modelica tool (e.g. Simulation X) to the regression testing.
6.) Your proposed naming of the jobs is fine for me.
… publish main scripts in .CI\ReSim folder
|
As requested, i am now:
Please have a look at |
There was a problem hiding this comment.
I did run CodeRabbit on this PR and it pointed out multiple critical issues.
I would suggest to:
- See my mail.
- Replace shared volumes
- Use artifacts (+
docker save/docker load)to pass data from one job to the next.
- Use artifacts (+
- Use GitHub runners instead of self-hosted runners wherever possible to minimize attack surface.
- Split all tools into separate jobs to enable parallelization (some use GitHub runners, some self-hosted runners)
- Make Docker images available to GitHub runners (use GHCR or a private registry and authenticate with secrets)
- Use artifacts to publish results
- Use artifacts to upload to a self-hosted web-server or use something like GitHub pages
| testrun_modelica: | ||
| needs: prepare | ||
| runs-on: [ self-hosted, Linux, regression_testing ] | ||
| environment: | ||
| name: Report modelica | ||
| url: ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/Modelica/report/PR_comparison_report.html | ||
| steps: | ||
| - name: Run tests modelica | ||
| run: ./.CI/ReSim/run_pr.sh ${{ env.EVENT_NUMBER }} ${{ env.PR_SHA }} Modelica ${{ env.TESTING_TOOLS }} |
There was a problem hiding this comment.
Test job is missing a checkout step.
This would only work on self-hosted runners where workspace files persist (generally a bad thing). There seems to be no sanitation of the VM / sandbox in between jobs. On the GitHub runners you would need to use artifacts between jobs.
| environment: | ||
| name: Report modelicatest | ||
| url: ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/report/PR_comparison_report.html | ||
| steps: |
There was a problem hiding this comment.
Test job is also missing a checkout step, see comment above.
|
|
||
| on: | ||
| pull_request_target: | ||
| workflow_dispatch: |
There was a problem hiding this comment.
workflow_dispatch will probably fail due to missing context.
When triggered via workflow_dispatch, github.event.number and github.event.pull_request.base.sha are undefined, causing EVENT_NUMBER and PR_SHA to be empty.
on:
pull_request_target:
workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'PR number'
+ required: true
+ type: number
+ base_sha:
+ description: 'Base commit SHA'
+ required: true
+ type: stringThis also needs an update on the next lines:
env:
PR_SERVER: ${{ vars.LTX_PR_SERVER }}
TESTING_TOOLS: ${{ vars.LTX_TESTING_TOOLS }}
- EVENT_NUMBER: ${{ github.event.number }}
- PR_SHA: ${{ github.event.pull_request.base.sha }}
+ EVENT_NUMBER: ${{ github.event.number || inputs.pr_number }}
+ PR_SHA: ${{ github.event.pull_request.base.sha || inputs.base_sha }}| @@ -0,0 +1,7 @@ | |||
| event_number=$1 | |||
There was a problem hiding this comment.
It's a common practice to add a shebang and to validate arguments in all shell scripts. Also using set -euo pipefail is a good way to ensure that your script fails loud, see https://gist.github.com/imrekoszo/eee95e94389e168a2dffe42bbc058a47.
#!/bin/bash
set -euo pipefail
if [ -z "${1:-}" ]; then
echo "Error: event_number argument is required" >&2
exit 1
fiPersonally I would also add set -x to echo the commands. Makes debugging later on way easier.
And I'm a fan of self documenting scripts, so I would suggest to add a help functions that also severs as the documentation for this script.
| docker cp create_overview_$event_number\_$pkg_name:/shared_data/resim_output/PRs/PR_$event_number/$pkg_name/report /var/www/html/prs/$event_number/$pkg_name | ||
| docker rm create_overview_$event_number\_$pkg_name | ||
| exit $(head -n 1 /var/www/html/prs/$event_number/$pkg_name/report/status.txt) No newline at end of file |
There was a problem hiding this comment.
From @coderabbitai:
Add error handling and validate exit status.
The script assumes status.txt exists and contains a valid numeric exit code. If the file is missing, empty, or contains non-numeric content, the exit command will fail or produce incorrect results. Additionally, if docker cp or docker rm fails, the script continues without reporting the error.
| docker cp create_overview_$event_number\_$pkg_name:/shared_data/resim_output/PRs/PR_$event_number/$pkg_name/report /var/www/html/prs/$event_number/$pkg_name | |
| docker rm create_overview_$event_number\_$pkg_name | |
| exit $(head -n 1 /var/www/html/prs/$event_number/$pkg_name/report/status.txt) | |
| docker cp create_overview_${event_number}_${pkg_name}:/shared_data/resim_output/PRs/PR_${event_number}/${pkg_name}/report "/var/www/html/prs/${event_number}/${pkg_name}" || { | |
| echo "Error: Failed to copy report from container" >&2 | |
| exit 1 | |
| } | |
| docker rm create_overview_${event_number}_${pkg_name} | |
| status_file="/var/www/html/prs/${event_number}/${pkg_name}/report/status.txt" | |
| if [ -f "$status_file" ]; then | |
| status=$(head -n 1 "$status_file") | |
| if [[ "$status" =~ ^[0-9]+$ ]]; then | |
| exit "$status" | |
| else | |
| echo "Error: Invalid status in $status_file: $status" >&2 | |
| exit 1 | |
| fi | |
| else | |
| echo "Error: Status file not found: $status_file" >&2 | |
| exit 1 | |
| fi | |
| mkdir /var/www/html/prs/$event_number | |
| fi | |
| mkdir /var/www/html/prs/$event_number/$pkg_name |
| @@ -0,0 +1,33 @@ | |||
| event_number=$1 | |||
There was a problem hiding this comment.
See previous comment.
| event_number=$1 | |
| #!/bin/bash | |
| set -euo pipefail | |
| if [ $# -lt 4 ]; then | |
| echo "Error: requires 4 arguments: event_number master_hash pkg_name tools" >&2 | |
| exit 1 | |
| fi | |
| event_number=$1 |
This PR adds the yml file to .github/workflows in order to start the CI for testing PullRequests with the ltx-resim tool.
infrastructure to run the CI-tests is currently hosted and maintained by LTX
see PRs #4725 #4763 #4764 #4765 , which are tests of the CI on a separate branch