Skip to content

Commit dda7a5a

Browse files
authored
Adding option to install omc-diff on Linux (#273)
1 parent 1cefb10 commit dda7a5a

12 files changed

Lines changed: 120 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ jobs:
3535
libraries: |
3636
'Modelica 4.0.0'
3737
'Modelica 3.2.3+maint.om'
38+
omc-diff: true
3839
- run: echo $OPENMODELICAHOME

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
The MIT License (MIT)
32

43
Copyright (c) 2018 GitHub, Inc. and contributors
@@ -20,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2019
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2120
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2221
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
THE SOFTWARE.
22+
THE SOFTWARE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ On Linux apt is used to install OpenModelica, on Windows the installer executabl
8181
libraries: |
8282
'Modelica 4.0.0'
8383
'Modelica 3.2.3+maint.om'
84+
omc-diff: true
8485
```
8586
8687
```yaml
@@ -117,6 +118,14 @@ $ npm run package
117118
$ npm test
118119
```
119120

121+
## License
122+
123+
This action is licensed under the MIT license, see [LICENSE.md](./LICENSE.md).
124+
OpenModelica and all OpenModelica tools are licensed under
125+
[GNU Affero General Public License version 3](https://www.gnu.org/licenses/agpl-3.0.en.html)
126+
or the
127+
[OSMC (Open Source Modelica Consortium) Public License (OSMC-PL) version 1.8](https://openmodelica.org/osmc-pl/osmc-pl-1.8.txt).
128+
120129
## Acknowledgments
121130

122131
This package was developed as part of the [Proper Hybrid Models for Smarter Vehicles (PHyMoS)](https://phymos.de/en/) project,

__tests__/installer.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ function linuxTests(): void {
136136
},
137137
10 * 60000
138138
)
139+
140+
test(
141+
'Install omc-diff',
142+
async () => {
143+
await installer.installOmcDiff(true)
144+
const fileExists = fs.existsSync('/usr/bin/omc-diff')
145+
expect(fileExists).toBe(true)
146+
},
147+
10 * 60000
148+
)
139149
}
140150

141151
function windowsTests(): void {

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
One library per line, separate version number with a space <library> <version>
2424
Example: "Modelica 4.0.0"'
2525
required: false
26+
omc-diff:
27+
description: 'Install OpenModelica omc-diff tool.'
28+
required: false
29+
default: false
2630
runs:
2731
using: 'node16'
2832
main: 'dist/index.js'

dist/index.js

Lines changed: 42 additions & 4 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.5.0",
3+
"version": "0.6.0",
44
"engines": {
55
"node": ">=18.0.0"
66
},

src/installer.ts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as core from '@actions/core'
22
import * as exec from '@actions/exec'
33

4+
import {cwd} from 'process'
45
import * as fs from 'fs'
56
import * as os from 'os'
67
import * as path from 'path'
7-
import {cwd} from 'process'
88
import * as semver from 'semver'
9-
10-
import json from './versions.json'
119
import * as util from './util'
10+
import json from './versions.json'
1211

1312
export type VersionType = {
1413
version: string
@@ -331,3 +330,40 @@ ${installPackages.join('\n')}`
331330

332331
return filename
333332
}
333+
334+
/**
335+
* Install OpenModelica omc-diff program.
336+
*
337+
* @param useSudo true if root rights are required.
338+
*/
339+
export async function installOmcDiff(useSudo: boolean): Promise<void> {
340+
341+
switch (osPlat) {
342+
case 'linux':
343+
break
344+
case 'win32':
345+
core.info(`Windows version of OpenModelica already installs omc-diff.`)
346+
return
347+
default:
348+
throw new Error(
349+
`omc-diff not available for platform ${osPlat}. Open a feature request on https://github.com/AnHeuermann/omc-diff.`
350+
)
351+
}
352+
353+
const sudo: string = useSudo ? 'sudo' : ''
354+
355+
// Download executable from https://github.com/AnHeuermann/omc-diff/
356+
const url =
357+
'https://github.com/AnHeuermann/omc-diff/releases/download/v0.1/linux-64.tar.gz'
358+
const file = url.split('/').pop()
359+
if (file === undefined) {
360+
throw new Error(`Something wrong with the url`)
361+
}
362+
await exec.exec(`wget ${url}`)
363+
364+
// Extract .tar.gz
365+
await exec.exec(`${sudo} tar -xvf ${file} -C /usr/bin/`)
366+
367+
// Clean up
368+
fs.rmSync(file)
369+
}

0 commit comments

Comments
 (0)