Add Lean Python unit tests CI workflow (#142) #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lean Python Regression Tests | |
| # Validates a Python.Runtime.dll change against Lean's Python regression | |
| # algorithms, mirroring Lean's own .github/workflows/regression-tests.yml. | |
| # We build this repo's Python.Runtime.dll, build Lean against its NuGet | |
| # QuantConnect.pythonnet reference, drop the freshly built DLL over Lean's | |
| # test output, and run only the Python regression tests. | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lean-python-regression: | |
| runs-on: self-hosted | |
| container: | |
| image: quantconnect/lean:foundation | |
| options: --cpus 12 --memory 12g | |
| steps: | |
| - name: Checkout pythonnet | |
| uses: actions/checkout@v4 | |
| with: | |
| path: pythonnet | |
| - name: Checkout Lean | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: QuantConnect/Lean | |
| path: Lean | |
| - name: Build Python.Runtime.dll | |
| run: | | |
| dotnet build pythonnet/src/runtime/Python.Runtime.csproj \ | |
| -c Release /v:quiet /p:WarningLevel=1 | |
| - name: Build Lean | |
| run: | | |
| dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 \ | |
| Lean/QuantConnect.Lean.sln | |
| - name: Inject freshly built Python.Runtime.dll into Lean test output | |
| run: | | |
| cp pythonnet/pythonnet/runtime/Python.Runtime.dll \ | |
| Lean/Tests/bin/Release/Python.Runtime.dll | |
| - name: Restrict regression tests to Python only | |
| run: | | |
| # Lean's RegressionTests reads the "regression-test-languages" config | |
| # key (defaults to CSharp + Python). Setting it to Python only makes the | |
| # test factory emit Python test cases exclusively. The config file is | |
| # JSONC; Newtonsoft tolerates the inserted line. | |
| sed -i '1a\ "regression-test-languages": ["Python"],' \ | |
| Lean/Tests/bin/Release/config.json | |
| - name: Run Lean Python regression tests | |
| run: | | |
| dotnet test Lean/Tests/bin/Release/QuantConnect.Tests.dll \ | |
| --blame-hang-timeout 300seconds --blame-crash \ | |
| --filter "TestCategory=RegressionTests & Name~Python/" \ | |
| -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\) \ | |
| TestRunParameters.Parameter\(name=\"reduced-disk-size\", value=\"true\"\) |