From 5ca9d234e1e3cc09dba76938f235753837c807a1 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Thu, 25 May 2023 15:49:24 +0200 Subject: [PATCH] Use curl with HTTP/2/3 in CircleCI too --- .circleci/config.yml | 9 +++++++++ README.md | 1 + checks/core/http_versions.py | 11 ++++++++++- telescope/app.py | 2 +- telescope/config.py | 1 + 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5feec7ff..a4674720 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,13 @@ 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 - @@ -27,6 +34,8 @@ jobs: - run: name: Test command: make tests + environment: + CURL_BINARY_PATH: /home/circleci/.local/bin/curl docker-build-test-publish: docker: diff --git a/README.md b/README.md index 50dae7eb..902200b3 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/checks/core/http_versions.py b/checks/core/http_versions.py index a7b76753..658131b0 100644 --- a/checks/core/http_versions.py +++ b/checks/core/http_versions.py @@ -3,6 +3,7 @@ """ import subprocess +from telescope import config from telescope.typings import CheckResult @@ -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()) diff --git a/telescope/app.py b/telescope/app.py index bac73a4a..1b269bfe 100644 --- a/telescope/app.py +++ b/telescope/app.py @@ -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() diff --git a/telescope/config.py b/telescope/config.py index 3c79680d..d9bbd491 100644 --- a/telescope/config.py +++ b/telescope/config.py @@ -73,6 +73,7 @@ "check.result": {"handlers": ["console"], "level": "INFO"}, }, } +CURL_BINARY_PATH = config("CURL_BINARY_PATH", default="curl") def interpolate_env(d):