Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,363 changes: 375 additions & 988 deletions .CI/Jenkinsfile

Large diffs are not rendered by default.

599 changes: 599 additions & 0 deletions .CI/common.groovy

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions .CI/report.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// The report stage of .CI/Jenkinsfile, which turns the results of the runs into
// the pages published on libraries.openmodelica.org. Loaded next to
// .CI/common.groovy and reached as `report.<function>()`.
//
// The branches a page covers are the GITBRANCHES* of the stage's environment;
// the functions here read them from `env` rather than taking them as arguments,
// so that the lists stay where the pipeline declares them.

/**
* The three configuration files together: the standard libraries, the outdated
* ones and the nonstandard ones. Passing them to one report.py run is what
* makes a "combined" page.
*/
def allConfigs() {
return 'configs/conf.json configs/conf-old.json configs/conf-nonstandard.json'
}

/**
* Every branch a run of all-reports.py and all-plots.py covers.
*/
def allBranches() {
return [env.GITBRANCHES,
env.GITBRANCHES_FMI,
env.GITBRANCHES_NEWINST,
env.GITBRANCHES_DAE,
env.GITBRANCHES_NEWBACKEND_DAE,
env.GITBRANCHES_CPP,
env.GITBRANCHES_WASM_JIT,
// The jobs that are a table of their own rather than one of the lists above.
'conversion',
'heavy_tests',
'generateSymbolicJacobian',
'gbode',
'cvode',
'ida'].join(' ')
}

/**
* The workspace the pages are built in: the ones of the previous run are
* removed, the OpenModelica clone that all-reports.py reads the commits from is
* updated, and the omcversion rows of runs that produced no results are dropped.
*/
def prepare() {
sh 'rm -rf *.html history'
sh '''
if ! test -d OpenModelica; then
git clone https://openmodelica.org/git-readonly/OpenModelica.git
fi
cd OpenModelica
git fetch
'''
sh './clean-empty-omcversion-dates.py'
}

/**
* The per-library reports and the plots of every branch.
*/
def reportsAndPlots() {
sh "./all-reports.py --email --omcgitdir=OpenModelica ${allBranches()}"
sh "./all-plots.py ${allBranches()}"
}

/**
* One overview page. report.py always writes overview.html, so a page is that
* file under the name the publisher uploads it as.
*
* @param name: File name of the page, e.g. `overview-fmi.html`.
* @param branches: The branches it holds a column for.
* @param configs: The configuration files it covers, the standard libraries
* by default.
*/
def overview(String name, String branches, String configs = 'configs/conf.json') {
sh "./report.py --branches='${branches}' ${configs}"
sh "mv overview.html ${name}"
}

/**
* The four pages a set of branches gets: the standard libraries, all three
* configurations combined, the outdated libraries and the nonstandard ones.
* `suffix` is what tells the four sets apart, e.g. `-fmi`.
*/
def overviewSet(String suffix, String branches) {
overview("overview${suffix}.html", branches)
overview("overview-combined${suffix}.html", branches, allConfigs())
overview("overview-old-libs${suffix}.html", branches, 'configs/conf-old.json')
overview("overview-nonstandard-libs${suffix}.html", branches, 'configs/conf-nonstandard.json')
}

/**
* Every overview page of the report stage.
*/
def overviews() {
def standard = "${env.GITBRANCHES} ${env.GITBRANCHES_WASM_JIT}"
overview('overview-combined.html', standard, allConfigs())
overview('overview-old-libs.html', standard, 'configs/conf-old.json')
overview('overview-nonstandard-libs.html', standard, 'configs/conf-nonstandard.json')
overview('overview-special-jobs.html', "${env.GITBRANCHES_SPECIAL} conversion")
overview('overview-generateSymbolicJacobian.html', 'generateSymbolicJacobian')
overview('overview-heavy_tests.html', 'heavy_tests', 'configs/heavy_tests.json')
overview('overview-cvode.html', 'cvode master')
overview('overview-gbode.html', 'gbode master')
overview('overview-ida.html', 'ida master')
// The three ways one wasm artifact is simulated, against master: they share
// an export, so only the simulation and the verification tell them apart.
overview('overview-wasm-jit.html', "${env.GITBRANCHES_WASM_JIT} master")
overview('overview-c++.html', env.GITBRANCHES_CPP)

overviewSet('-oldinst', env.GITBRANCHES_NEWINST)
overviewSet('-fmi', env.GITBRANCHES_FMI)
overviewSet('-dae', env.GITBRANCHES_DAE)
overviewSet('-newbackend-dae', env.GITBRANCHES_NEWBACKEND_DAE)

// Last, and the one page that keeps the name report.py gives it: overview.html
// is what the site links to.
sh "./report.py --branches='${env.GITBRANCHES}' configs/conf.json"
}

/**
* Uploads the pages, after saying how many of them there are and which.
*/
def publish() {
sh 'date'
sh 'find overview*.html history -type f | wc -l'
sh 'find overview*.html history'

sshPublisher(publishers: [sshPublisherDesc(configName: 'LibraryTestingReports', transfers: [sshTransfer(sourceFiles: 'overview*.html,history/**')])])
}

/**
* The report of one pull request run, which the report stage above does not
* cover: that one compares a branch against its own previous run, which a pull
* request has none of.
*
* @param pullRequest: The number of the tested pull request.
* @param baseline: The branch its results are compared against.
* @param comment: Post the summary as a comment on the pull request. Needs
* the github-token credential; whoever the token belongs to
* is who the comment comes from.
*/
def pullRequestReport(String pullRequest, String baseline, boolean comment) {
sh 'rm -rf history'
def prReport = "./pr-report.py '${pullRequest}' --baseline='${(baseline ?: 'master').trim()}'"
if (comment) {
withCredentials([string(credentialsId: 'github-token', variable: 'GITHUB_TOKEN')]) {
sh "${prReport} --comment"
}
} else {
sh prReport
}
// The summary is in the build log as well, so a run without a token still
// leaves it somewhere to copy from.
sh 'cat history/pr-*/00_comment.md'

sshPublisher(publishers: [sshPublisherDesc(configName: 'LibraryTestingReports', transfers: [sshTransfer(sourceFiles: 'history/**')])])
}

return this
4 changes: 2 additions & 2 deletions .github/workflows/check_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Python3
uses: actions/setup-python@v5
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0

- name: Validate JSON files
run: |
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/lint-groovy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Lint Groovy

on:
pull_request:
push:
branches:
- master

jobs:
npm-groovy-lint:
name: Lint .CI/Jenkinsfile and .CI/common.groovy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Java
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: temurin
java-version: '21'

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22'

- name: Install npm-groovy-lint
run: npm install --global npm-groovy-lint@18

# Lints every Jenkinsfile and *.groovy of the repository (the default file
# pattern), with the rules in .groovylintrc.json. A syntax error, which is
# otherwise found by a Jenkins build that is already running, is reported
# here as an error; warnings fail the job as well, and the info-level
# findings that remain are style this repository does not follow.
- name: Run npm-groovy-lint
run: npm-groovy-lint --loglevel warning --failon warning --no-insight
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup OpenModelica
uses: OpenModelica/setup-openmodelica@v1
uses: OpenModelica/setup-openmodelica@dd6dc5fdb91c936dd3ab328902808c8a5421f146 # v1.1.0
with:
version: ${{ matrix.omc-version }}
packages: |
Expand All @@ -45,7 +45,7 @@ jobs:
fi

- name: Setup Python3
uses: actions/setup-python@v5
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
Expand Down Expand Up @@ -81,15 +81,15 @@ jobs:
fi

- name: Archive sqlite3.db
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: ${{ matrix.os }}-${{ matrix.omc-version }}-sqlite3.db
path: |
sqlite3.db

- name: Archive HTML
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: ${{ matrix.os }}-${{ matrix.omc-version }}-MyLibrary.html
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__
/*.files
/*.html
/*.json
!/.groovylintrc.json
/converted-libraries
/MyLibrary*/
/ReferenceFiles/
Expand Down
32 changes: 32 additions & 0 deletions .groovylintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": "recommended-jenkinsfile",
"rules": {
"DuplicateNumberLiteral": {
"enabled": false
},
"DuplicateStringLiteral": {
"enabled": false
},
"Indentation": {
"spacesPerIndentLevel": 2
},
"LineLength": {
"enabled": false
},
"MethodParameterTypeRequired": {
"enabled": false
},
"MethodSize": {
"enabled": false
},
"ParameterCount": {
"maxParameters": 15
},
"UnnecessaryElseStatement": {
"enabled": false
},
"UnnecessaryGString": {
"enabled": false
}
}
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ OpenModelica
[issue tracker](https://github.com/OpenModelica/OpenModelica/issues/new/choose)
and ask us to do it for you.

### The pipeline

[.CI/Jenkinsfile](.CI/Jenkinsfile) holds the stages; what they do is a function in
[.CI/common.groovy](.CI/common.groovy), or in [.CI/report.groovy](.CI/report.groovy)
for the pages published from the results. The `setup` stage loads both, and the
others reach them as `common.<function>()` and `report.<function>()`. All of it is
linted on every pull request by
[.github/workflows/lint-groovy.yml](.github/workflows/lint-groovy.yml), so a
Jenkinsfile that does not parse is found before a build runs it.

### The image the OSMC jobs run in

Every job of [.CI/Jenkinsfile](.CI/Jenkinsfile) runs in one docker image, built
Expand Down
Loading