Skip to content

Commit

Permalink
Install Modelica libraries (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnHeuermann authored Aug 9, 2023
1 parent f0c14d8 commit a16e261
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 34 deletions.
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"features": {
"ghcr.io/devcontainers-contrib/features/typescript:2": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ jobs:
packages: |
'omc'
'omsimulator'
libraries: |
'Modelica 4.0.0'
'Modelica 3.2.3+maint.om'
- run: echo $OPENMODELICAHOME
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ On Linux apt is used to install OpenModelica, on Windows the installer executabl
- `packages`: OpenModelica APT packages to install. Only used on Linux OS.
- For example `'omc'` for the OpenModelica Compiler or `'omsimulator'` for OMSimulator.
Use one package per line.
- `libraries`: Modelica libraries to install with the [OpenModelica package manager](https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/packagemanager.html).
- One library per line with exact version number. Will install exact match only and all dependencies.

```yml
libraries: |
'Modelica 4.0.0'
'Modelica 3.2.3'
```
## Available OpenModelica versions
Expand Down Expand Up @@ -64,22 +72,25 @@ On Linux apt is used to install OpenModelica, on Windows the installer executabl
## Examples
```yaml
- uses: AnHeuermann/setup-openmodelica@v0.4
- uses: AnHeuermann/setup-openmodelica@v0.5
with:
version: '1.20'
packages: |
'omc'
'omsimulator'
libraries: |
'Modelica 4.0.0'
'Modelica 3.2.3+maint.om'
```
```yaml
- uses: AnHeuermann/setup-openmodelica@v0.4
- uses: AnHeuermann/setup-openmodelica@v0.5
with:
version: 'nightly'
```
```yaml
- uses: AnHeuermann/setup-openmodelica@v0.4
- uses: AnHeuermann/setup-openmodelica@v0.5
with:
version: 'stable'
```
Expand Down
25 changes: 21 additions & 4 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ switch (osPlat) {
default:
throw new Error(`Platform ${osPlat} is not supported`)
}
commonTests()

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

Expand Down Expand Up @@ -76,7 +81,9 @@ function linuxTests(): void {
await purgeOMC()
const version = installer.getOMVersion('1.18.0')
expect(version.version).toEqual('1.18.0')
await expect(installer.installOM(['omc'], version, '64')).rejects.toThrow('Distribution jammy not available for OpenModelica version 1.18.0.')
await expect(installer.installOM(['omc'], version, '64')).rejects.toThrow(
'Distribution jammy not available for OpenModelica version 1.18.0.'
)
},
10 * 60000
)
Expand Down Expand Up @@ -129,7 +136,6 @@ function linuxTests(): void {
},
10 * 60000
)

}

function windowsTests(): void {
Expand All @@ -145,3 +151,14 @@ function windowsTests(): void {
10 * 60000
)
}

function commonTests(): void {
test(
'Install Modelica libraries',
async () => {
const libraries = ['Modelica 4.0.0', 'Modelica 3.2.3+maint.om']
await installer.installLibs(libraries)
},
10 * 60000
)
}
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ inputs:
Each package has to be in a new line. Ignored on Windows.'
required: false
default: 'omc'
libraries:
description: 'Optional list of Modelica libraries to install.
One library per line, separate version number with a space <library> <version>
Example: "Modelica 4.0.0"'
required: false
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
73 changes: 70 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-openmodelica",
"version": "0.4.4",
"version": "0.5.0",
"engines": {
"node": ">=18.0.0"
},
Expand Down
Loading

0 comments on commit a16e261

Please sign in to comment.