Skip to content

Commit 92218e5

Browse files
authored
Windows support (#21)
* Fixes for Windows - Update path - Tests running on Windows 🎉 * Update all the things * Removing linter
1 parent 8a5fe01 commit 92218e5

23 files changed

Lines changed: 1372 additions & 580 deletions

.github/linters/.markdown-lint.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/linters/.yaml-lint.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ on:
1212
jobs:
1313
test-typescript:
1414
name: TypeScript Tests
15-
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, windows-latest]
18+
fail-fast: false
19+
20+
runs-on: ${{ matrix.os }}
1621
permissions:
1722
contents: read
1823

@@ -28,7 +33,21 @@ jobs:
2833

2934
- name: Update pip
3035
run: |
31-
pip install --upgrade pip
36+
python -m pip install --upgrade pip
37+
38+
- name: Install Python packages (Windows only)
39+
if: matrix.os == 'windows-latest'
40+
shell: pwsh
41+
run: |
42+
pip install --user `
43+
datetime `
44+
matplotlib `
45+
monotonic `
46+
natsort `
47+
joblib `
48+
ompython `
49+
simplejson `
50+
psutil
3251
3352
- name: Cache pip dependencies
3453
uses: actions/cache@v4
@@ -66,12 +85,16 @@ jobs:
6685
run: npm run lint
6786

6887
- name: Test
69-
id: npm-ci-test
70-
run: npm run ci-test
88+
id: npm-test
89+
run: npm run test
7190

7291
test-action:
7392
name: GitHub Actions Test
74-
runs-on: ubuntu-latest
93+
strategy:
94+
matrix:
95+
os: [ubuntu-latest, windows-latest]
96+
fail-fast: false
97+
runs-on: ${{ matrix.os }}
7598
timeout-minutes: 60
7699
permissions:
77100
contents: write

.github/workflows/linter.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,8 @@ __tests__/runner/*
102102
.vscode
103103
*.code-workspace
104104

105+
# Python
106+
/.venv/
107+
105108
/OpenModelicaLibraryTesting/
106-
/html/
109+
/html/

README.md

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ the test report.
1010
The action will set output variables that can be checked how many tests passed
1111
simulation and verification. It will fail if at least one test is failing.
1212

13+
## Table of Contents
14+
15+
- [Inputs](#inputs)
16+
- [Outputs](#outputs)
17+
- [Example usage](#example-usage)
18+
- [Artifacts](#artifacts)
19+
- [Demo](#demo)
20+
- [Development](#development)
21+
- [License](#license)
22+
- [Acknowledgments](#acknowledgments)
23+
1324
## Inputs
1425

1526
### `library`
@@ -59,6 +70,27 @@ Character to separate model names in reference files.
5970
E.g. for `Modelica.Blocks.Examples.PID_Controller.mat` it would be `'.'`\
6071
Default: `'.'`
6172
73+
## Outputs
74+
75+
The action will fail if one test fails. In addition the following outputs can be
76+
used to determine the testing results.
77+
78+
### `simulation-tests-passing`
79+
80+
`'True'` if all simulation tests are passing, `'False'` otherwise.
81+
82+
### `n-simulation-passing`
83+
84+
Number of successful simulation tests.
85+
86+
### `verification-tests-passing`
87+
88+
`'True'` if all verification tests are passing, `'False'` otherwise.
89+
90+
### `n-verification-passing`
91+
92+
Number of successful verification tests.
93+
6294
## Example usage
6395
6496
```yaml
@@ -97,27 +129,6 @@ jobs:
97129
pages-root-url: 'https://USERNAME.github.io/REPOSITORY/'
98130
```
99131
100-
## Outputs
101-
102-
The action will fail if one test fails. In addition the following outputs can be
103-
used to determine the testing results.
104-
105-
## `simulation-tests-passing`
106-
107-
`'True'` if all simulation tests are passing, `'False'` otherwise.
108-
109-
## `n-simulation-passing`
110-
111-
Number of successful simulation tests.
112-
113-
## `verification-tests-passing`
114-
115-
`'True'` if all verification tests are passing, `'False'` otherwise.
116-
117-
## `n-verification-passing`
118-
119-
Number of successful verification tests.
120-
121132
## Artifacts
122133
123134
### HTML Results
@@ -128,7 +139,7 @@ pages.
128139
129140
```bash
130141
unzip MyLibrary.html.zip -d html
131-
python3 -m http.server -d html
142+
python -m http.server -d html
132143
```
133144
134145
#### GitHub Pages
@@ -169,7 +180,7 @@ jobs:
169180
170181
### SQlite
171182
172-
For future test the SQlite data base `sqlite3.db` is achieved.
183+
For future tests the SQlite data base `sqlite3.db` is archived.
173184
174185
## Demo
175186
@@ -203,6 +214,30 @@ The HTML results can be hosted with GitHub Pages, for this example they can be
203214
found at
204215
[OpenModelica.github.io/openmodelica-library-testing-action][gh-pages-link].
205216
217+
## Development
218+
219+
To install and build run:
220+
221+
```bash
222+
npm install
223+
npm run package
224+
```
225+
226+
Testing will install some Python packages. It's useful to setup a virtual Python
227+
environment in your shell before starting the tests:
228+
229+
```bash
230+
python -m venv .venv
231+
source .venv/bin/activate
232+
npm run test
233+
```
234+
235+
> [!TIP]
236+
> On Windows use Conda to choose a Python interpreter and then setup a virtual
237+
> environment.
238+
> Use PowerShell to activate `.\.venv\Scripts\activate` the environment.
239+
> Msys2 doesn't install Python packages via pip, so it won't work with this script.
240+
206241
## License
207242
208243
This action is licensed with the OSMC Public License v1.8, see

__tests__/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/clone/
22
/tmp-collect/
33
/tmp-configs/
4+
/tmp-msys/
45
github_step_summary.md
5-
MyLibrary_0.1.0.html
6+
MyLibrary_0.1.0.html

__tests__/config.test.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Unit tests for src/config.ts
33
*/
44

5+
import * as os from 'os'
56
import * as fs from 'fs'
67
import * as path from 'path'
78
import { expect } from '@jest/globals'
@@ -14,36 +15,42 @@ describe('config.ts', () => {
1415
afterEach(() => fs.rmSync(tempTestDir, { recursive: true, force: true }))
1516

1617
it('Generate minimal configuration', async () => {
17-
const modelicaFile = '/path/to/MyLibrary/package.mo'
18-
const config: Configuration = {
19-
library: 'MyLibrary',
20-
libraryVersion: 'main',
21-
loadFileCommands: [`loadFile("${path.resolve(modelicaFile)}")`]
18+
let modelicaFile: string
19+
if (os.platform() === 'win32') {
20+
modelicaFile = path.join('C:', 'path', 'to', 'MyLibrary', 'package.mo')
21+
} else {
22+
modelicaFile = path.join('/path', 'to', 'MyLibrary', 'package.mo')
2223
}
23-
24-
expect(config).toEqual({
24+
const config = new Configuration({
2525
library: 'MyLibrary',
2626
libraryVersion: 'main',
27-
loadFileCommands: ['loadFile("/path/to/MyLibrary/package.mo")']
27+
loadFileCommands: [`loadFile("${modelicaFile}")`]
2828
})
29+
30+
const expectedPath =
31+
os.platform() === 'win32'
32+
? 'C:/path/to/MyLibrary/package.mo'
33+
: '/path/to/MyLibrary/package.mo'
34+
expect(config.loadFileCommands).toEqual([`loadFile("${expectedPath}")`])
2935
})
3036

3137
it('Generate minimal configuration file', async () => {
3238
const file = path.join(tempTestDir, 'testConfigSimple.json')
33-
const modelicaFile = '/path/to/MyLibrary/package.mo'
34-
const config: Configuration = {
39+
const modelicaFile = path.join('path', 'to', 'MyLibrary', 'package.mo')
40+
const config = new Configuration({
3541
library: 'MyLibrary',
3642
libraryVersion: 'main',
37-
loadFileCommands: [`loadFile("${path.resolve(modelicaFile)}")`]
38-
}
43+
loadFileCommands: [`loadFile("${modelicaFile}")`]
44+
})
3945

4046
await genConfigFile(file, [config])
4147
expect(fs.existsSync(file)).toBe(true)
4248
})
4349

4450
it('Generate extensive configuration file', async () => {
4551
const file = path.join(tempTestDir, 'testConfig.json')
46-
const config: Configuration = {
52+
const modelicaFile = path.join('path', 'to', 'MyLibrary', 'package.mo')
53+
const config = new Configuration({
4754
library: 'MyLibrary',
4855
libraryVersion: 'main',
4956
libraryVersionNameForTests: 'v1.0.0-def',
@@ -69,7 +76,7 @@ describe('config.ts', () => {
6976
optlevel: '-Os -march=native',
7077
alarmFlag: '--alarm',
7178
abortSlowSimulation: '',
72-
loadFileCommands: ['loadFile("${resolve(modelicaFile)}")'],
79+
loadFileCommands: [`loadFile("${modelicaFile}")`],
7380
extraCustomCommands: ['setCommandLineOptions("-d=-NLSanalyticJacobian")'],
7481
environmentSimulation: [
7582
['publicData', '$libraryLocation/Tables/'],
@@ -84,7 +91,7 @@ describe('config.ts', () => {
8491
]
8592
],
8693
configExtraName: 'noopt'
87-
}
94+
})
8895

8996
await genConfigFile(file, [config])
9097
expect(fs.existsSync(file)).toBe(true)

0 commit comments

Comments
 (0)