Skip to content

Commit 266849c

Browse files
committed
allow workflow to access draft releases
1 parent 48a8dcf commit 266849c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
- name: Install requirements
5252
run: uv pip install --system . --group test ${{ matrix.installs }}
5353
- name: Run tests
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5456
run: pytest --cov=MCEq --cov-branch --cov-report=xml -n 3
5557
- name: Upload coverage reports to Codecov
5658
uses: codecov/codecov-action@v5

src/MCEq/config.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,23 @@ def get_file_checksum(self):
407407
return self.sha256_hash.hexdigest()
408408

409409

410-
def _download_file(url, outfile):
410+
def _download_file(url, outfile, github_token=None):
411411
"""Downloads the MCEq database from github"""
412412

413413
import math
414414

415415
import requests
416416
from tqdm import tqdm
417417

418+
headers = {}
419+
if github_token:
420+
headers["Authorization"] = f"token {github_token}"
421+
418422
# Streaming, so we can iterate over the response.
419-
r = requests.get(url, stream=True)
423+
r = requests.get(url, stream=True, headers=headers)
424+
425+
if r.status_code != 200:
426+
raise Exception(f"Download failed with status {r.status_code}")
420427

421428
# Total size in bytes.
422429
total_size = int(r.headers.get("content-length", 0))
@@ -455,7 +462,11 @@ def _download_file(url, outfile):
455462
print(f"Downloading for mceq database file {mceq_db_fname}.")
456463
if debug_level >= 2:
457464
print(url)
458-
_download_file(url, filepath_to_database)
465+
466+
import os
467+
468+
github_token = os.environ.get("GITHUB_TOKEN")
469+
_download_file(url, filepath_to_database, github_token=github_token)
459470

460471
old_database = "mceq_db_lext_dpm191_v12.h5"
461472
filepath_to_old_database = data_dir / old_database

0 commit comments

Comments
 (0)