Skip to content

Fix packaging checks and simplify CI #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
tox:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version:
- "3.9"
Expand All @@ -21,25 +20,16 @@ jobs:
- "pypy3.9"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: |
python -m pip install --upgrade pip setuptools
pip install --upgrade tox tox-gh-actions
- name: Install h2spec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
.github/workflows/install_h2spec.sh
- name: Initialize tox envs
run: |
tox --parallel auto --notest
- name: Test with tox
run: |
tox --parallel 0
run: mkdir bin && curl -sSL "https://github.com/summerwind/h2spec/releases/latest/download/h2spec_linux_amd64.tar.gz" | tar -xz --directory ./bin && ./bin/h2spec --version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this always work? The original intention of calling the GitHub API using a token was to get around rate-limiting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically this is not using any API endpoint or raw file access, but the convenience public link for releases — that unless flagged by their security is generally unlimited. (They have a ~5k hits/hr limit however I think they don't limit access from their own infra to stuff like packages, containers or releases?) — I'll check the frequency but we've been using this in rust workflows (instead of waiting for cargo builds) for many years, can't remember it ever failing over a rate limit in GHA.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kriechi (Just to make it more traceable: the CI never had used the public release URL, it only ever used the API, unauthenticated: a.) GitHub@9df8f94, b.) Travis@0cb4090… so I don't believe the non-APIv3 way was ever used.)

- name: Install tox
run: pip install tox tox-gh-actions
- name: Run tests on Python ${{ matrix.python-version }}
run: tox
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/install_h2spec.sh

This file was deleted.

5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packaging = [
"check-manifest==0.50",
"readme-renderer==44.0",
"build>=1.2.2,<2",
"twine>=5.1.1,<6",
"twine>=6.1.0,<7",
"wheel>=0.45.0,<1",
]

Expand Down Expand Up @@ -183,9 +183,6 @@ python = """
"""

[tool.tox.env_run_base]
pass_env = [
"GITHUB_*",
]
dependency_groups = ["testing"]
commands = [
["python", "-bb", "-m", "pytest", "--cov-report=xml", "--cov-report=term", "--cov=h2", { replace = "posargs", extend = true }]
Expand Down
16 changes: 8 additions & 8 deletions src/h2/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ def receive_push_promise_in_band(self,
events = self.state_machine.process_input(
StreamInputs.RECV_PUSH_PROMISE,
)
push_event = cast(PushedStreamReceived, events[0])
push_event = cast("PushedStreamReceived", events[0])
push_event.pushed_stream_id = promised_stream_id

hdr_validation_flags = self._build_hdr_validation_flags(events)
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def receive_headers(self,

events = self.state_machine.process_input(input_)
headers_event = cast(
Union[RequestReceived, ResponseReceived, TrailersReceived, InformationalResponseReceived],
"Union[RequestReceived, ResponseReceived, TrailersReceived, InformationalResponseReceived]",
events[0],
)

Expand All @@ -1086,9 +1086,9 @@ def receive_headers(self,
)
# We ensured it's not an information response at the beginning of the method.
cast(
Union[RequestReceived, ResponseReceived, TrailersReceived],
"Union[RequestReceived, ResponseReceived, TrailersReceived]",
headers_event,
).stream_ended = cast(StreamEnded, es_events[0])
).stream_ended = cast("StreamEnded", es_events[0])
events += es_events

self._initialize_content_length(headers)
Expand All @@ -1112,15 +1112,15 @@ def receive_data(self, data: bytes, end_stream: bool, flow_control_len: int) ->
"set to %d", self, end_stream, flow_control_len,
)
events = self.state_machine.process_input(StreamInputs.RECV_DATA)
data_event = cast(DataReceived, events[0])
data_event = cast("DataReceived", events[0])
self._inbound_window_manager.window_consumed(flow_control_len)
self._track_content_length(len(data), end_stream)

if end_stream:
es_events = self.state_machine.process_input(
StreamInputs.RECV_END_STREAM,
)
data_event.stream_ended = cast(StreamEnded, es_events[0])
data_event.stream_ended = cast("StreamEnded", es_events[0])
events.extend(es_events)

data_event.data = data
Expand All @@ -1144,7 +1144,7 @@ def receive_window_update(self, increment: int) -> tuple[list[Frame], list[Event
# this should be treated as a *stream* error, not a *connection* error.
# That means we need to catch the error and forcibly close the stream.
if events:
cast(WindowUpdated, events[0]).delta = increment
cast("WindowUpdated", events[0]).delta = increment
try:
self.outbound_flow_control_window = guard_increment_window(
self.outbound_flow_control_window,
Expand Down Expand Up @@ -1228,7 +1228,7 @@ def stream_reset(self, frame: RstStreamFrame) -> tuple[list[Frame], list[Event]]

if events:
# We don't fire an event if this stream is already closed.
cast(StreamReset, events[0]).error_code = _error_code_from_int(frame.error_code)
cast("StreamReset", events[0]).error_code = _error_code_from_int(frame.error_code)

return [], events

Expand Down