Skip to content
Merged
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
8 changes: 6 additions & 2 deletions .ci-scripts/install-pony-tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import hashlib
import json
import os
import re
import subprocess
import tempfile
Expand All @@ -21,22 +22,25 @@ def get(url, token=None, accept=None):

def release(tool, filename):
base = f"https://api.github.com/repos/ponylang/{tool}/releases"
token = os.environ.get("GITHUB_TOKEN")
url = base + "/latest"
while url:
if url == base + "/latest":
try:
with get(url) as response:
with get(url, token) as response:
releases = [json.load(response)]
except urllib.error.HTTPError as err:
if err.code != 404:
raise
releases = []
url = base + "?per_page=20"
else:
with get(url) as response:
with get(url, token) as response:
releases = json.load(response)
link = re.search(r'<([^>]+)>; rel="next"', response.headers.get("Link", ""))
url = link[1] if link else None
if url and not url.startswith("https://api.github.com/"):
raise ValueError(f"Unexpected release pagination URL for {tool}")
for item in releases:
if item["prerelease"] or item["draft"]:
continue
Expand Down
54 changes: 54 additions & 0 deletions .ci-scripts/test-install-pony-tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import io
import json
import os
import runpy
import unittest
import urllib.request
from pathlib import Path
from unittest.mock import patch


release = runpy.run_path(str(Path(__file__).with_name("install-pony-tools.py")))["release"]
base = "https://api.github.com/repos/ponylang/corral/releases"
first = base + "?per_page=20"
next_page = "https://api.github.com/repositories/96358645/releases?page=2"
archive = "https://github.com/ponylang/corral/releases/download/1/corral.zip"


def page(items, next_url=None):
response = io.BytesIO(json.dumps(items).encode())
response.headers = {"Link": f'<{next_url}>; rel="next"'} if next_url else {}
return response


class ReleaseRequests(unittest.TestCase):
def test_credentials_on_metadata_requests(self):
assets = [
{"name": "corral.zip" + suffix, "state": "uploaded", "browser_download_url": archive + suffix}
for suffix in ("", ".sha512")
]
item = {"draft": False, "prerelease": False, "assets": assets}
for token in ("", "job-token"):
with self.subTest(token=token), patch.dict(os.environ, GITHUB_TOKEN=token):
responses = [page(dict(item, assets=[])), page([], next_page), page([item]), io.BytesIO(b"a" * 128)]
with patch.object(urllib.request, "urlopen", side_effect=responses) as fetch:
url, _, _, download_token = release("corral", "corral.zip")
self.assertEqual(url, archive)
self.assertIsNone(download_token)
auth = f"Bearer {token}" if token else None
requests = [(r.args[0].full_url, r.args[0].get_header("Authorization")) for r in fetch.call_args_list]
self.assertEqual(requests, [
(base + "/latest", auth), (first, auth), (next_page, auth), (archive + ".sha512", None)
])

def test_rejects_off_site_release_pagination(self):
responses = [page({"draft": True, "prerelease": False}), page([], "https://example.org/releases?page=2")]
with patch.dict(os.environ, GITHUB_TOKEN="job-token"):
with patch.object(urllib.request, "urlopen", side_effect=responses) as fetch:
with self.assertRaisesRegex(ValueError, "Unexpected release pagination URL"):
release("corral", "corral.zip")
self.assertEqual(fetch.call_count, 2)


if __name__ == "__main__":
unittest.main()
2 changes: 2 additions & 0 deletions .github/workflows/breakage-against-windows-ponyc-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v6.0.2
- name: Install pony tools
env:
GITHUB_TOKEN: ${{ github.token }}
run: python .ci-scripts/install-pony-tools.py x86-64-pc-windows-msvc nightly release
- name: Test with most recent ponyc nightly
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ jobs:
runs-on: windows-2025-vs2026
steps:
- uses: actions/checkout@v6.0.2
- name: Test CI installer release lookups
run: python .ci-scripts/test-install-pony-tools.py
- name: install pony tools
run: python .ci-scripts/install-pony-tools.py x86-64-pc-windows-msvc nightly nightly
- name: Test with most recent ponyc release
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}

x86-64-apple-darwin-release:
permissions:
contents: read
name: Build and upload x86-64-apple-darwin
runs-on: macos-15-intel
needs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v6.0.2
- name: install pony tools
env:
GITHUB_TOKEN: ${{ github.token }}
run: python3 .ci-scripts/install-pony-tools.py x86-64-apple-darwin nightly release
- name: brew install dependencies
run: |
Expand All @@ -108,13 +112,17 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}

arm64-apple-darwin-release:
permissions:
contents: read
name: Build and upload arm64-apple-darwin
runs-on: macos-26
needs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v6.0.2
- name: install pony tools
env:
GITHUB_TOKEN: ${{ github.token }}
run: python3 .ci-scripts/install-pony-tools.py arm64-apple-darwin nightly release
- name: brew install dependencies
run: |
Expand All @@ -130,13 +138,17 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}

x86-64-pc-windows-msvc-release:
permissions:
contents: read
name: Build and upload x86-64-pc-windows-msvc-release
runs-on: windows-2025-vs2026
needs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v6.0.2
- name: install pony tools
env:
GITHUB_TOKEN: ${{ github.token }}
run: python .ci-scripts/install-pony-tools.py x86-64-pc-windows-msvc nightly release
- name: Build and upload
run: |
Expand All @@ -160,13 +172,17 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}

arm64-pc-windows-msvc-release:
permissions:
contents: read
name: Build and upload arm64-pc-windows-msvc-release
runs-on: windows-11-arm
needs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v6.0.2
- name: install pony tools
env:
GITHUB_TOKEN: ${{ github.token }}
run: python .ci-scripts/install-pony-tools.py arm64-pc-windows-msvc nightly release
- name: Build and upload
run: |
Expand Down
Loading