Skip to content

Commit

Permalink
chore(ci): Updating title checks and avoiding requests
Browse files Browse the repository at this point in the history
  • Loading branch information
davisp committed Feb 26, 2025
1 parent e74a74e commit 8423f3d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
37 changes: 15 additions & 22 deletions .github/actions/install-tiledb/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ inputs:
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Requests
run: pip install requests
shell: bash
- name: Detect Version
id: version
env:
Expand Down Expand Up @@ -74,17 +67,17 @@ runs:
shell: python
run: |
import os
import requests
import urllib.request
version = os.environ["TDB_VERSION"]
platform = os.environ["TDB_PLATFORM"]
BASE_URL = "https://github.com/TileDB-Inc/TileDB/releases/download/{}/releases.csv"
resp = requests.get(BASE_URL.format(version))
resp.raise_for_status()
with urllib.request.urlopen(BASE_URL.format(version)) as resp:
releases = resp.read().decode("utf-8")
candidates = []
for line in resp.text.splitlines():
for line in releases.splitlines():
bits = line.split(",")
if platform.upper() == bits[0].upper():
candidates.append((bits[1], bits[2]))
Expand All @@ -110,18 +103,18 @@ runs:
shell: python
run: |
import os
import requests
import urllib.request
version = os.environ["TDB_VERSION"]
linkage = os.environ["TDB_LINKAGE"]
platform = os.environ["TDB_PLATFORM"]
URL = "https://github.com/TileDB-Inc/tiledb-rs/releases/download/nightlies/releases.csv"
resp = requests.get(URL)
resp.raise_for_status()
with urllib.request.urlopen(URL) as resp:
releases = resp.read().decode("utf-8")
candidates = []
for line in resp.text.splitlines():
for line in releases.splitlines():
bits = line.split(",")
if platform.upper() != bits[0].upper():
Expand Down Expand Up @@ -153,9 +146,11 @@ runs:
CUSTOM_SHA256: ${{ steps.custom-tarball.outputs.sha256 }}
shell: python
run: |
import os
import requests
import hashlib
import os
import shutil
import urllib.request
url = os.environ["UPSTREAM_URL"] or os.environ["CUSTOM_URL"]
expected_sha256 = os.environ["UPSTREAM_SHA256"] or os.environ["CUSTOM_SHA256"]
Expand All @@ -169,11 +164,9 @@ runs:
exit(1)
fname = os.path.basename(url)
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open(fname, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
with urllib.request.urlopen(url) as resp:
with open(fname, 'wb') as handle:
shutil.copyfileobj(resp, handle)
with open(fname, 'rb') as handle:
digest = hashlib.file_digest(handle, "sha256")
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,38 @@ jobs:
if: ${{ github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout tiledb-rs
uses: actions/checkout@v4
- name: "Check Title Format"
shell: python
env:
PR_TITLE: ${{ github.event.pull_request.title }}
GIT_SHA: ${{ github.sha }}
run: |
import os
import re
import subprocess as sp
PAT = re.compile(r"^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)")
# We're checking both the PR title and the subject of the last commit
# to the PR. The reason for also checking the commit is that when a
# PR has a single commit, its the commit subject that is used by
# default which means it'll break our changelog generation scripts.
if not PAT.match(os.environ["PR_TITLE"]):
print("The pull request title does not match Conventional Commits syntax")
print("See: https://www.conventionalcommits.org/en/v1.0.0/")
exit(1)
# Read the subject of the last commit in the branch.
subject = sp.check_output(["git", "log", "--format=%B", "-n", "1", os.environ["GIT_SHA"]])
subject = subject.strip()
if not PAT.match(subject):
print("The last commit on this PR branch does not match Conventional Commits syntax")
print("See: https://www.conventionalcommits.org/en/v1.0.0/")
exit(1)
check-api-coverage:
name: "Check API Coverage"
runs-on: ubuntu-latest
Expand Down

0 comments on commit 8423f3d

Please sign in to comment.