Skip to content

Commit a16e261

Browse files
authored
Install Modelica libraries (#269)
1 parent f0c14d8 commit a16e261

11 files changed

Lines changed: 203 additions & 34 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"features": {
88
"ghcr.io/devcontainers-contrib/features/typescript:2": {}
99
}
10-
1110
// Features to add to the dev container. More info: https://containers.dev/features.
1211
// "features": {},
1312

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ jobs:
3232
packages: |
3333
'omc'
3434
'omsimulator'
35+
libraries: |
36+
'Modelica 4.0.0'
37+
'Modelica 3.2.3+maint.om'
3538
- run: echo $OPENMODELICAHOME

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ On Linux apt is used to install OpenModelica, on Windows the installer executabl
2020
- `packages`: OpenModelica APT packages to install. Only used on Linux OS.
2121
- For example `'omc'` for the OpenModelica Compiler or `'omsimulator'` for OMSimulator.
2222
Use one package per line.
23+
- `libraries`: Modelica libraries to install with the [OpenModelica package manager](https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/packagemanager.html).
24+
- One library per line with exact version number. Will install exact match only and all dependencies.
25+
26+
```yml
27+
libraries: |
28+
'Modelica 4.0.0'
29+
'Modelica 3.2.3'
30+
```
2331
2432
## Available OpenModelica versions
2533
@@ -64,22 +72,25 @@ On Linux apt is used to install OpenModelica, on Windows the installer executabl
6472
## Examples
6573
6674
```yaml
67-
- uses: AnHeuermann/setup-openmodelica@v0.4
75+
- uses: AnHeuermann/setup-openmodelica@v0.5
6876
with:
6977
version: '1.20'
7078
packages: |
7179
'omc'
7280
'omsimulator'
81+
libraries: |
82+
'Modelica 4.0.0'
83+
'Modelica 3.2.3+maint.om'
7384
```
7485
7586
```yaml
76-
- uses: AnHeuermann/setup-openmodelica@v0.4
87+
- uses: AnHeuermann/setup-openmodelica@v0.5
7788
with:
7889
version: 'nightly'
7990
```
8091
8192
```yaml
82-
- uses: AnHeuermann/setup-openmodelica@v0.4
93+
- uses: AnHeuermann/setup-openmodelica@v0.5
8394
with:
8495
version: 'stable'
8596
```

__tests__/installer.test.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ switch (osPlat) {
1717
default:
1818
throw new Error(`Platform ${osPlat} is not supported`)
1919
}
20+
commonTests()
2021

2122
async function purgeOMC(): Promise<void> {
2223
const fileContent = fs.readFileSync('/var/log/apt/history.log').toString()
2324
const matches = fileContent.match('Install: .*omc.*')
2425
if (matches != null && matches.length > 0) {
25-
const toRemove = matches[matches.length-1].replace('Install: ','').replace(/:[^\)]*\),*/g, '')
26+
const toRemove = matches[matches.length - 1]
27+
.replace('Install: ', '')
28+
.replace(/:[^\)]*\),*/g, '')
2629
console.log(`Files to remove: ${toRemove}`)
27-
await exec.exec(`/bin/bash -c "sudo apt-get purge ${toRemove} -qy ${'||'} sudo apt-get autoremove -qy"`)
30+
await exec.exec(
31+
`/bin/bash -c "sudo apt-get purge ${toRemove} -qy ${'||'} sudo apt-get autoremove -qy"`
32+
)
2833
}
2934
}
3035

@@ -76,7 +81,9 @@ function linuxTests(): void {
7681
await purgeOMC()
7782
const version = installer.getOMVersion('1.18.0')
7883
expect(version.version).toEqual('1.18.0')
79-
await expect(installer.installOM(['omc'], version, '64')).rejects.toThrow('Distribution jammy not available for OpenModelica version 1.18.0.')
84+
await expect(installer.installOM(['omc'], version, '64')).rejects.toThrow(
85+
'Distribution jammy not available for OpenModelica version 1.18.0.'
86+
)
8087
},
8188
10 * 60000
8289
)
@@ -129,7 +136,6 @@ function linuxTests(): void {
129136
},
130137
10 * 60000
131138
)
132-
133139
}
134140

135141
function windowsTests(): void {
@@ -145,3 +151,14 @@ function windowsTests(): void {
145151
10 * 60000
146152
)
147153
}
154+
155+
function commonTests(): void {
156+
test(
157+
'Install Modelica libraries',
158+
async () => {
159+
const libraries = ['Modelica 4.0.0', 'Modelica 3.2.3+maint.om']
160+
await installer.installLibs(libraries)
161+
},
162+
10 * 60000
163+
)
164+
}

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ inputs:
1818
Each package has to be in a new line. Ignored on Windows.'
1919
required: false
2020
default: 'omc'
21+
libraries:
22+
description: 'Optional list of Modelica libraries to install.
23+
One library per line, separate version number with a space <library> <version>
24+
Example: "Modelica 4.0.0"'
25+
required: false
2126
runs:
2227
using: 'node16'
2328
main: 'dist/index.js'

dist/index.js

Lines changed: 70 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-openmodelica",
3-
"version": "0.4.4",
3+
"version": "0.5.0",
44
"engines": {
55
"node": ">=18.0.0"
66
},

0 commit comments

Comments
 (0)