Skip to content

Ci and deps - #5

Closed
Woll78 wants to merge 29 commits into
spujadas:masterfrom
Woll78:ci-and-deps
Closed

Woll78 wants to merge 29 commits into
spujadas:masterfrom
Woll78:ci-and-deps

Conversation

@Woll78

@Woll78 Woll78 commented Oct 12, 2026

Copy link
Copy Markdown

Summary

Packaging and CI fixes from the code review (finding #5). 3 commits; 281 tests passing.

  • 650fe9e Installed CLI was broken. MANIFEST.in didn't include nexus/data/stops.csv, which is loaded at import. The CLI imports every provider, so an installed departure crashed on any command, including --help. Added the file, plus a test that fails if any package data file isn't covered by MANIFEST.in. Verified by building the wheel and running departure --help from a clean venv.
  • 6e39ec6 Removed stale requirements.txt. A 2020 environment freeze nothing used; installing it would downgrade protobuf to 3.6.1 and break the regenerated protobuf code. Replaced by requirements-dev.txt (package from setup.py + pytest, httpx, build).
  • 78981cf CI runs tests. New Tests workflow on pushes to master and PRs, on Python 3.10 and 3.14: runs pytest, then builds the wheel, installs it and runs departure --help. Publishing now runs it first. Moved off deprecated actions/*@v2 and setup.py sdist bdist_wheel.

Notes

  • Python 3.10 is only verified by this CI run (only 3.14 was available locally).
  • Publishing credentials are unchanged. PyPI requires API tokens (__token__ as username); username/password uploads no longer work. The departure PyPI project belongs to upstream.

Woll78 and others added 29 commits November 20, 2021 14:27
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
POST /shutdown-web-server ran `sudo shutdown -h now` with no
authentication, and the API server is meant to bind to 0.0.0.0, so
anyone on the network could power off the host. It now requires the
DEPARTURE_BOARD_RSHUTDOWN_TOKEN already used for board server shutdown,
compared in constant time, and refuses if the token is not configured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An API failure returned None, which next_trains turned into [], so an
outage was shown as "Pas de service". Other failures left the previous
departures on the board indefinitely, presented as live.

The SNCF API now raises on request errors and non-200 responses. A
failed poll calls a new DataUpdater.update_failed() hook, which for SNCF
shows "Information indisponible" and forgets the last trains so the
next successful poll always replaces the message. A failure inside the
hook is logged and does not stop the polling thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous test mocked api.departures to raise, which passed before
the fix too. It now fails the HTTP request, so it fails if next_trains
ever turns an API error back into "no trains".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fetched

Same fix as SNCF: the API raises on request errors and non-200
responses instead of returning None (shown as "Pas de service"), and a
failed poll shows "Information indisponible" instead of leaving stale
departures on the board.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SOAP faults and HTTP errors from getMissionsNext escaped as zeep or
requests exceptions, and RatpException was caught and ignored in the
data updater; either way the previous departures stayed on the board.
They are now raised as RatpException and a failed poll shows
"Information indisponible". The CLI next command reports the error
instead of a traceback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The NS API returned None on failure, which then crashed parsing the
response, and NSException was caught and ignored in the data updater;
either way the previous departures stayed on the board. The API now
raises NSException and a failed poll shows "Data unavailable".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connection errors were caught and ignored in the data updater, and SOAP
faults escaped to the generic handler; either way the previous services
stayed on the board. The API now raises NationalRailException for HTTP
and SOAP errors, including failure to load the WSDL, and a failed poll
shows "Data unavailable". The CLI next command reports the error
instead of a traceback.

The old test asserting the connection error was swallowed is replaced
by tests of the new behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unified API returned None on failure, which next_trains turned
into no trains (a blank board), or into a partial list missing the
train at the platform when only the second request failed. The API now
raises TflTubeException and a failed poll shows "Data unavailable".

This also stops stoppoints_by_line writing "null" to a line data file
when the download fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the builtin ConnectionError was caught, which requests' errors do
not subclass, so failures escaped to the generic handler and left the
previous buses on the board. The Go North East scrape also had no
timeout, so a hung site blocked the polling thread indefinitely.

The scrape now has a timeout and raises on HTTP errors. If either
operator fails the poll raises NexusBusException and the board shows
"Data unavailable", rather than one operator's buses alone, which
could show "No service" or the wrong next bus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Starting a client set a shared `running` flag to False, slept 1s in an
async handler (blocking the web server), and started a new client. The
old updater could still be mid-poll for up to 15s, so it then pushed
the old station's departures and blanked the board after the new client
had started; as updaters only push on change, the board could stay
blank or wrong. Concurrent start requests could also run two clients.

BoardClient now has start() and stop(), serialised by a lock. Each
client's view model sits behind a gate that stop() closes, so a poll
still in flight can no longer reach the board, and stopping does not
wait for it. Updater threads are daemons so Ctrl-C exits at once.
Handlers that block are plain functions, run in FastAPI's threadpool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The National Rail, SNCF and Nexus board commands logged an invalid
station but started the board anyway, and the RATP board command did
not validate at all. They now exit after reporting the error.

The Nexus board command also passed station_id to DataUpdaterNexusBus,
which takes stop_code, so it crashed on start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MANIFEST.in did not include nexus/data/stops.csv, which is loaded at
import time. The CLI imports every provider, so an installed
`departure` failed on any command, including --help, with
FileNotFoundError. A test now checks every package data file is
covered by MANIFEST.in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
requirements.txt was a 2020 environment freeze that nothing used and
that contradicted setup.py: installing it would downgrade protobuf to
3.6.1 and break the regenerated protobuf code. requirements-dev.txt
installs the package from setup.py plus test and build tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI only published on tags and never ran the tests. A Tests workflow now
runs on pushes to master and on pull requests, on the oldest and newest
supported Python, and checks the built wheel installs and `departure
--help` runs. Publishing runs it first and only uploads if it passes.

The publish job also moves off the deprecated actions/checkout@v2,
setup-python@v2 and `setup.py sdist bdist_wheel`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Woll78 Woll78 closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant