-
Notifications
You must be signed in to change notification settings - Fork 190
Initialize CI for PullRequest Testing #4767
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
Changes from all commits
f509569
2bab916
45b4fbc
daf4de9
ea52fe5
3a4586b
854138f
ade1b0c
3787f03
5d0440c
66e8dc4
5062534
daf479f
fbae83c
72a7897
48a0f19
5cdacb9
b9afba6
c7922ae
27b6eea
7b2861a
826763a
5063ec5
1b23d6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| event_number=$1 | ||
| # checkout the pull request | ||
| docker run --name compile_msl --rm --volume shared_data:/shared_data wsm_image /shared_data/run_scripts/git_pr_pull.sh $event_number | ||
| # compile msl binaries | ||
| docker run --name compile_msl --rm --volume shared_data:/shared_data wsm_image /shared_data/run_scripts/compile_msl.sh /shared_data/repos/pr_testing/ModelicaStandardLibrary | ||
| # delete old PRs with same number (in case of a new commit on a PR) | ||
| docker run --name compile_msl --rm --volume shared_data:/shared_data dymola_image /shared_data/run_scripts/delete_old_PRs.sh $event_number | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| event_number=$1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| master_hash=$2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| pkg_name=$3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Run Modelica in all tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| tools=$4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| for tool in $tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| uppertool=$( echo $tool | tr 'a-z' 'A-Z') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker run --rm --name $tool\_pr_compare_$event_number\_$pkg_name --volume shared_data:/shared_data $tool\_image python /shared_data/run_scripts/$uppertool\_PR_compare.py $master_hash $event_number $pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| #docker run --rm --name dymola_pr_compare_$event_number\_$pkg_name --volume shared_data:/shared_data dymola_image python /shared_data/run_scripts/Dymola_PR_compare.py $master_hash $event_number $pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #docker run --rm --name om_pr_compare_$event_number\_$pkg_name --volume shared_data:/shared_data om_image python /shared_data/run_scripts/OM_PR_compare.py $master_hash $event_number $pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #docker run --rm --name wsm_pr_compare_$event_number\_$pkg_name --volume shared_data:/shared_data wsm_image python /shared_data/run_scripts/WSM_PR_compare.py $master_hash $event_number $pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # create an overview over all tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker run --name create_overview_$event_number\_$pkg_name --volume shared_data:/shared_data om_image python /shared_data/run_scripts/overview_report.py $event_number $pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # clear published directory (web server) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -d "/var/www/html/prs/$event_number/$pkg_name" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf "/var/www/html/prs/$event_number/$pkg_name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -d "/var/www/html/prs/$event_number" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir /var/www/html/prs/$event_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir /var/www/html/prs/$event_number/$pkg_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # copy data to webserver directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: CI ReSim | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| workflow_dispatch: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When triggered via 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 }} |
||
|
|
||
| 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 }} | ||
|
|
||
| jobs: | ||
| prepare: | ||
| runs-on: [ self-hosted, Linux, regression_testing ] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| sparse-checkout: './.CI/ReSim' | ||
|
|
||
| - name: Checkout code in docker | ||
| run: ./.CI/ReSim/prepare_pr.sh ${{ env.EVENT_NUMBER }} | ||
|
|
||
| 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 }} | ||
|
Comment on lines
+24
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test job is missing a checkout step. |
||
|
|
||
|
|
||
| testrun_modelicatest: | ||
| needs: prepare | ||
| runs-on: [ self-hosted, Linux, regression_testing ] | ||
| environment: | ||
| name: Report modelicatest | ||
| url: ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/report/PR_comparison_report.html | ||
| steps: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test job is also missing a checkout step, see comment above. |
||
| - name: Run tests modelicatest | ||
| run: ./.CI/ReSim/run_pr.sh ${{ env.EVENT_NUMBER }} ${{ env.PR_SHA }} ModelicaTest ${{ env.TESTING_TOOLS }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a common practice to add a shebang and to validate arguments in all shell scripts. Also using
set -euo pipefailis a good way to ensure that your script fails loud, see https://gist.github.com/imrekoszo/eee95e94389e168a2dffe42bbc058a47.Personally I would also add
set -xto 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.