rewrite QwenPreamble: self-aware, tighter, plan-act-verify for 3.8 #278
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: Windows | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| tags: ['[0-9]+.[0-9]+.[0-9]+'] | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| # git-bash on the Windows runner. The Windows default (pwsh) does not | |
| # propagate non-zero exit codes from native exes like nimble, so a failed | |
| # build/test is swallowed and the job runs on into packaging, which then | |
| # fails for a misleading reason (missing artifact). Same workaround as | |
| # release.yml. | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: jiro4989/setup-nim-action@v2 | |
| with: | |
| nim-version: stable | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| parent-nim-install-directory: $HOME | |
| nim-install-directory: nim-toolchain | |
| - name: Install dependencies | |
| # sandwall is not on the public package registry; install it from | |
| # its git URL first so --depsOnly can resolve it from the local store. | |
| run: | | |
| nimble install -y https://github.com/capocasa/sandwall | |
| nimble install -y --depsOnly | |
| - name: Compute build flags | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| # autoupdate on releases only | |
| echo "BUILD_FLAGS=-d:autoUpdate" >> "$GITHUB_ENV" | |
| fi | |
| - name: Build | |
| run: nimble build -y -d:release ${{ env.BUILD_FLAGS }} | |
| - name: Stage OpenSSL DLLs for test binaries | |
| # The tty tests spawn the real 3code binary (built -d:ssl), which | |
| # dlopens libssl/libcrypto by Nim's hardcoded names. Stock Windows | |
| # ships neither; without them next to the exe the child dies with | |
| # STATUS_DLL_INIT_FAILED (0xC0000142). Place them next to the root | |
| # binary and the test build dir so both load. cacert.pem feeds | |
| # SSL_CERT_FILE for the stub provider's local TLS path. | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest -Uri https://nim-lang.org/download/dlls.zip -OutFile dlls.zip | |
| Expand-Archive -Path dlls.zip -DestinationPath dlls | |
| New-Item -ItemType Directory -Path build -Force | Out-Null | |
| Copy-Item dlls/libssl-1_1-x64.dll, dlls/libcrypto-1_1-x64.dll, dlls/cacert.pem . | |
| Copy-Item dlls/libssl-1_1-x64.dll, dlls/libcrypto-1_1-x64.dll, dlls/cacert.pem build/ | |
| echo "SSL_CERT_FILE=$PWD/cacert.pem" >> "$GITHUB_ENV" | |
| - name: Build stub binary for tty tests | |
| # The tty tests spawn the 3code stub binary (built -d:providerStub) | |
| # as their child. Build it once here so every test reuses the same | |
| # binary instead of each test triggering a full rebuild. | |
| run: | | |
| nim c -d:ssl -d:providerStub --threads:on --path:src -o:build/3code_stub.exe src/threecode.nim | |
| - name: Run tests | |
| # Run the tty category via testament. Tests that hang or fail under | |
| # ConPTY are disabled with `disabled: "win"` in their discard | |
| # blocks (see test_tty_functional, test_spinner_race_stress, | |
| # test_429_typing_during_backoff, test_interrupt_prestream_freeze, | |
| # test_interrupt_network_connect, test_resize_ticker, | |
| # test_broken_stdout_exit). The remaining tests pass on Windows. | |
| # | |
| # git-bash does not reliably propagate nimble's non-zero exit code, | |
| # so run testament directly and propagate $? explicitly. | |
| run: | | |
| # Smoke-check: the built 3code binary loads its DLLs standalone. | |
| ./3code.exe -v || { echo "3code.exe failed to start"; exit 1; } | |
| if command -v testament >/dev/null 2>&1; then | |
| testament --print --megatest:off cat tty | |
| exit $? | |
| else | |
| echo "testament not found; falling back to nim c -r" | |
| for f in tests/tty/test_*.nim; do | |
| nim c -r --path:src --path:tests "$f" || true | |
| done | |
| fi | |
| timeout-minutes: 20 | |
| - name: Package (Windows) - bundle OpenSSL DLLs alongside .exe | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Path 3code-windows-amd64 | Out-Null | |
| Copy-Item 3code.exe 3code-windows-amd64/ | |
| Copy-Item README.md, LICENSE 3code-windows-amd64/ | |
| # Stock Windows ships no OpenSSL. Nim's std/net dlopens libssl / | |
| # libcrypto by hardcoded names; without these DLLs alongside | |
| # 3code.exe, any TLS code path dies with | |
| # could not load: (libcrypto-1_1-x64|libeay64).dll | |
| # Use the canonical Nim Windows DLL bundle from nim-lang.org; | |
| # it also ships a cacert.pem that we point SSL_CERT_FILE at. | |
| # The "Stage OpenSSL DLLs" step already downloaded + extracted | |
| # dlls/ earlier; reuse it instead of re-downloading (the second | |
| # Expand-Archive fails on the existing cacert.pem). Re-fetch only | |
| # if staging was skipped (e.g. running this job standalone). | |
| if (-not (Test-Path dlls/libssl-1_1-x64.dll)) { | |
| Invoke-WebRequest -Uri https://nim-lang.org/download/dlls.zip -OutFile dlls.zip | |
| Expand-Archive -Path dlls.zip -DestinationPath dlls -Force | |
| } | |
| Copy-Item dlls/libssl-1_1-x64.dll, dlls/libcrypto-1_1-x64.dll, dlls/cacert.pem 3code-windows-amd64/ | |
| # Capture the version from the staged binary (needs the DLLs | |
| # alongside it to launch) so it can be checked without running | |
| # the binary on its target OS. | |
| & 3code-windows-amd64/3code.exe -v | Set-Content -Encoding ascii 3code-windows-amd64/VERSION | |
| Compress-Archive -Path 3code-windows-amd64 -DestinationPath 3code-windows-amd64.zip | |
| - name: Upload artifact (GitHub Actions) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 3code-windows-amd64 | |
| path: 3code-windows-amd64.zip | |
| - name: Upload artifact to 3code.capocasa.dev | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| curl -f -H "Authorization: Bearer ${{ secrets.RELEASE_SECRET }}" -F "file=@3code-windows-amd64.zip" \ | |
| https://3code.capocasa.dev/main/builds/upload.nim | |