Skip to content

Commit c274d7c

Browse files
committed
ci: use continue-on-error in the weekly_download workflow
1 parent 867e837 commit c274d7c

File tree

2 files changed

+54
-40
lines changed

2 files changed

+54
-40
lines changed

.github/workflows/weekly_download.yml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,46 @@ name: Weekly download
22

33
on:
44
schedule:
5-
- cron: "0 0 * * 1" # every Monday at 00:00 UTC
5+
- cron: "0 0 * * 1" # every Monday at 00:00 UTC
66
workflow_dispatch:
77

8-
98
jobs:
109
download:
1110
runs-on: ubuntu-latest
1211
steps:
13-
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
14-
id: app-token
15-
with:
16-
app-id: ${{ vars.ELEMENTSINTERACTIVE_BOT_APP_ID }}
17-
private-key: ${{ secrets.ELEMENTSINTERACTIVE_BOT_PRIVATE_KEY }}
18-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19-
with:
20-
fetch-depth: 0
21-
token: ${{ steps.app-token.outputs.token }}
22-
ref: ${{ github.head_ref }}
23-
- name: Install uv
24-
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
12+
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
13+
id: app-token
14+
with:
15+
app-id: ${{ vars.ELEMENTSINTERACTIVE_BOT_APP_ID }}
16+
private-key: ${{ secrets.ELEMENTSINTERACTIVE_BOT_PRIVATE_KEY }}
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18+
with:
19+
fetch-depth: 0
20+
token: ${{ steps.app-token.outputs.token }}
21+
ref: ${{ github.head_ref }}
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
24+
25+
- name: Install the project
26+
run: uv sync --locked --only-group download
27+
28+
- name: Download Pypi packages
29+
continue-on-error: true
30+
run: |
31+
uv run --no-project dependencies/scripts/download_packages.py download pypi
32+
33+
- name: Download NPM packages
34+
continue-on-error: true
35+
run: |
36+
uv run --no-project dependencies/scripts/download_packages.py download npm
2537
26-
- name: Install the project
27-
run: uv sync --locked --only-group download
38+
- name: Configure git
39+
run: |
40+
git config user.name "github-actions[bot]"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
2842
29-
- name: Download packages from trusted sources
30-
run: |
31-
uv run --no-project dependencies/scripts/download_packages.py download pypi || echo 'Failed to download trusted pypi packages'
32-
uv run --no-project dependencies/scripts/download_packages.py download npm || echo 'Failed to download trusted npm packages'
33-
34-
- name: Configure git
35-
run: |
36-
git config user.name "github-actions[bot]"
37-
git config user.email "github-actions[bot]@users.noreply.github.com"
38-
39-
- name: Push changes to repo
40-
run: |
41-
git add .
42-
git commit -m "chore: Weekly update of trusted packages"
43-
git push origin HEAD:main
43+
- name: Push changes to repo
44+
run: |
45+
git add .
46+
git commit -m "chore: Weekly update of trusted packages"
47+
git push origin HEAD:main

dependencies/scripts/download_packages.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,23 @@
1919
)
2020

2121

22+
class ServerError(Exception):
23+
"""Custom exception for HTTP 5xx errors."""
24+
25+
26+
# Directory name
2227
DEPENDENCIES_DIR = "dependencies"
28+
29+
# Sources
2330
TOP_PYPI_SOURCE = "https://hugovk.github.io/top-pypi-packages/top-pypi-packages.min.json"
2431
TOP_NPM_SOURCE = "https://packages.ecosyste.ms/api/v1/registries/npmjs.org/packages"
32+
33+
# Retry configuration constants
34+
RETRY_EXCEPTIONS = (httpx.TransportError, httpx.TimeoutException, ServerError)
35+
RETRY_ATTEMPTS = 10
36+
RETRY_WAIT_JITTER = 1
37+
RETRY_WAIT_EXP_BASE = 2
38+
RETRY_WAIT_MAX = 8
2539
TIMEOUT = 90
2640

2741

@@ -33,10 +47,6 @@ def parse_pypi(data: dict[str, Any]) -> set[str]:
3347
return {row["project"] for row in data["rows"]}
3448

3549

36-
class ServerError(Exception):
37-
"""Custom exception for HTTP 5xx errors."""
38-
39-
4050
@dataclass(frozen=True)
4151
class Ecosystem:
4252
url: str
@@ -94,11 +104,11 @@ def download(
94104

95105

96106
@stamina.retry(
97-
on=(httpx.TransportError, httpx.TimeoutException, ServerError),
98-
attempts=10,
99-
wait_jitter=1,
100-
wait_exp_base=2,
101-
wait_max=8,
107+
on=RETRY_EXCEPTIONS,
108+
attempts=RETRY_ATTEMPTS,
109+
wait_jitter=RETRY_WAIT_JITTER,
110+
wait_exp_base=RETRY_WAIT_EXP_BASE,
111+
wait_max=RETRY_WAIT_MAX,
102112
)
103113
def get_packages(
104114
base_url: str, parser: Callable[[dict[str, Any]], set[str]], params: dict[str, Any] | None = None

0 commit comments

Comments
 (0)