Skip to content

Commit

Permalink
Use curl with HTTP/2/3 in CircleCI too
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed May 30, 2023
1 parent 6664e05 commit 5ca9d23
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ jobs:
steps:
- checkout

- run:
name: Get curl with HTTP2 and HTTP3 support
command: |
wget https://github.com/stunnel/static-curl/releases/download/8.1.1/curl-static-amd64-8.1.1.tar.xz
tar -xvf curl-*.tar.xz
mv curl /home/circleci/.local/bin/curl
- run:
name: Use latest poetry
command: curl -sSL https://install.python-poetry.org | python3 -

- run:
name: Test
command: make tests
environment:
CURL_BINARY_PATH: /home/circleci/.local/bin/curl

docker-build-test-publish:
docker:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Server configuration is done via environment variables:

* ``GITHUB_TOKEN``: Github [Personal Access Token value](https://github.com/settings/tokens) to avoid rate-limiting (default: disabled)
* ``GOOGLE_APPLICATION_CREDENTIALS``: Absolute path to credentials file for BigQuery authentication (eg. `` `pwd`/key.json``, default: disabled)
* ``CURL_BINARY_PATH``: path to ``curl`` command (default: ``curl``)

Configuration can be stored in a ``.env`` file:

Expand Down
11 changes: 10 additions & 1 deletion checks/core/http_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import subprocess

from telescope import config
from telescope.typings import CheckResult


Expand All @@ -15,7 +16,15 @@ async def run(url: str, versions: list[str] = ["1", "1.1", "2", "3"]) -> CheckRe
supported_versions = set()
for flag in CURL_VERSION_FLAGS:
result = subprocess.run(
["curl", "-sI", flag, url, "-o/dev/null", "-w", "%{http_version}\n"],
[
config.CURL_BINARY_PATH,
"-sI",
flag,
url,
"-o/dev/null",
"-w",
"%{http_version}\n",
],
capture_output=True,
)
supported_versions.add(result.stdout.strip().decode())
Expand Down
2 changes: 1 addition & 1 deletion telescope/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async def heartbeat(request):
checks = {}
# Check that `curl` has HTTP2 and HTTP3 for `checks.core.http_versions`
curl_cmd = subprocess.run(
["curl", "--version"],
[config.CURL_BINARY_PATH, "--version"],
capture_output=True,
)
output = curl_cmd.stdout.strip().decode()
Expand Down
1 change: 1 addition & 0 deletions telescope/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"check.result": {"handlers": ["console"], "level": "INFO"},
},
}
CURL_BINARY_PATH = config("CURL_BINARY_PATH", default="curl")


def interpolate_env(d):
Expand Down

0 comments on commit 5ca9d23

Please sign in to comment.