|
| 1 | +name: Lean Python Regression Tests |
| 2 | + |
| 3 | +# Validates a Python.Runtime.dll change against Lean's Python regression |
| 4 | +# algorithms, mirroring Lean's own .github/workflows/regression-tests.yml. |
| 5 | +# We build this repo's Python.Runtime.dll, build Lean against its NuGet |
| 6 | +# QuantConnect.pythonnet reference, drop the freshly built DLL over Lean's |
| 7 | +# test output, and run only the Python regression tests. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + pull_request: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + lean-python-regression: |
| 21 | + runs-on: ubuntu-24.04 |
| 22 | + timeout-minutes: 360 |
| 23 | + steps: |
| 24 | + - name: Checkout pythonnet |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + path: pythonnet |
| 28 | + |
| 29 | + - name: Checkout Lean |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + repository: QuantConnect/Lean |
| 33 | + path: Lean |
| 34 | + |
| 35 | + - name: Liberate disk space |
| 36 | + uses: jlumbroso/free-disk-space@main |
| 37 | + with: |
| 38 | + tool-cache: true |
| 39 | + large-packages: false |
| 40 | + docker-images: false |
| 41 | + swap-storage: false |
| 42 | + |
| 43 | + - name: Define docker helper |
| 44 | + run: | |
| 45 | + echo 'runInContainer() { docker exec test-container "$@"; }' > $HOME/ci_functions.sh |
| 46 | + echo "BASH_ENV=$HOME/ci_functions.sh" >> $GITHUB_ENV |
| 47 | +
|
| 48 | + - name: Start container |
| 49 | + run: | |
| 50 | + docker run -d \ |
| 51 | + --workdir /__w/pythonnet/pythonnet \ |
| 52 | + -v /home/runner/work:/__w \ |
| 53 | + --name test-container \ |
| 54 | + quantconnect/lean:foundation \ |
| 55 | + tail -f /dev/null |
| 56 | +
|
| 57 | + - name: Build Python.Runtime.dll |
| 58 | + run: | |
| 59 | + runInContainer dotnet build pythonnet/src/runtime/Python.Runtime.csproj \ |
| 60 | + -c Release /v:quiet /p:WarningLevel=1 |
| 61 | +
|
| 62 | + - name: Build Lean |
| 63 | + run: | |
| 64 | + runInContainer dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 \ |
| 65 | + Lean/QuantConnect.Lean.sln |
| 66 | +
|
| 67 | + - name: Inject freshly built Python.Runtime.dll into Lean test output |
| 68 | + run: | |
| 69 | + runInContainer cp pythonnet/pythonnet/runtime/Python.Runtime.dll \ |
| 70 | + Lean/Tests/bin/Release/Python.Runtime.dll |
| 71 | +
|
| 72 | + - name: Restrict regression tests to Python only |
| 73 | + run: | |
| 74 | + # Lean's RegressionTests reads the "regression-test-languages" config |
| 75 | + # key (defaults to CSharp + Python). Setting it to Python only makes the |
| 76 | + # test factory emit Python test cases exclusively. The config file is |
| 77 | + # JSONC; Newtonsoft tolerates the inserted line. |
| 78 | + runInContainer sed -i '1a\ "regression-test-languages": ["Python"],' \ |
| 79 | + Lean/Tests/bin/Release/config.json |
| 80 | +
|
| 81 | + - name: Run Lean Python regression tests |
| 82 | + run: | |
| 83 | + runInContainer dotnet test Lean/Tests/bin/Release/QuantConnect.Tests.dll \ |
| 84 | + --blame-hang-timeout 300seconds --blame-crash \ |
| 85 | + --filter "TestCategory=RegressionTests & Name~Python/" \ |
| 86 | + -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\) \ |
| 87 | + TestRunParameters.Parameter\(name=\"reduced-disk-size\", value=\"true\"\) |
0 commit comments