Fix CI tests and speed up integration tests

- Speed up simulation 10x for integration tests (reduces test time from
  10+ minutes to ~2.5 minutes)
- Add small delays between TCP commands in tests for reliability
- Fix Gitea CI release job (use gitea.ref instead of github.ref)
- Revert write() error-check that was consuming query responses
This commit is contained in:
2025-11-26 11:21:49 +00:00
parent 986f368f75
commit 76db4e442e
3 changed files with 25 additions and 6 deletions

View File

@@ -72,7 +72,7 @@ jobs:
release: release:
name: Release name: Release
needs: [lint, typecheck, test] needs: [lint, typecheck, test]
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(gitea.ref, 'refs/tags/v')
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -90,8 +90,20 @@ jobs:
- name: Build package - name: Build package
run: python -m build run: python -m build
- name: Create Release - name: Upload Release Assets
uses: softprops/action-gh-release@v1 run: |
with: # Create release using Gitea API
files: dist/* TAG_NAME=${GITEA_REF#refs/tags/}
generate_release_notes: true curl -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"${TAG_NAME}\", \"body\": \"Release ${TAG_NAME}\"}" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" || true
# Upload dist files
for file in dist/*; do
curl -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-F "attachment=@${file}" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/tags/${TAG_NAME}/assets?name=$(basename ${file})" || true
done

View File

@@ -125,6 +125,10 @@ def simulation_server() -> Generator[ServerConfig, None, None]:
server_thread = ServerThread(config) server_thread = ServerThread(config)
server_thread.start() server_thread.start()
# Speed up simulation for tests (10x faster)
if server_thread.server is not None:
server_thread.server.time_scale = 10.0
try: try:
yield config yield config
finally: finally:

View File

@@ -73,6 +73,8 @@ class TestInstrumentServer:
# Set temperature setpoint # Set temperature setpoint
writer.write(b"TEMP:SETPOINT 85.0\n") writer.write(b"TEMP:SETPOINT 85.0\n")
await writer.drain() await writer.drain()
# Small delay to ensure server processes command before next one
await asyncio.sleep(0.01)
# Query setpoint # Query setpoint
writer.write(b"TEMP:SETPOINT?\n") writer.write(b"TEMP:SETPOINT?\n")
@@ -212,6 +214,7 @@ class TestSimulationServer:
psu_r, psu_w = await asyncio.open_connection("127.0.0.1", 16201) psu_r, psu_w = await asyncio.open_connection("127.0.0.1", 16201)
psu_w.write(b"VOLT 5.0\n") psu_w.write(b"VOLT 5.0\n")
await psu_w.drain() await psu_w.drain()
await asyncio.sleep(0.01) # Allow server to process
psu_w.write(b"OUTP ON\n") psu_w.write(b"OUTP ON\n")
await psu_w.drain() await psu_w.drain()