Skip to content

Commit 70fe204

Browse files
authored
Manage GraphBLAS version with GB_VERSION.txt file (#114)
* Manage GraphBLAS version with GB_VERSION.txt file Also include a script to fetch latest upstream GraphBLAS version, as well as a workflow that can auto-update this file on a schedule. * Add shebang and drop unnecessary variable
1 parent decaf15 commit 70fe204

File tree

5 files changed

+101
-11
lines changed

5 files changed

+101
-11
lines changed

.github/workflows/test.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
# os: ["ubuntu-latest"]
2020
# source: ["source"]
2121
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
22-
graphblas-version: ["8.2.1"]
2322
steps:
2423
- name: Checkout
2524
uses: actions/checkout@v4
@@ -38,19 +37,19 @@ jobs:
3837
- name: GraphBLAS (from conda-forge)
3938
if: (contains(matrix.source, 'conda-forge'))
4039
run: |
41-
conda install graphblas=${{ matrix.graphblas-version }}
40+
conda install graphblas=$(cat GB_VERSION.txt)
4241
- name: GraphBLAS (from source)
4342
if: (contains(matrix.source, 'source'))
4443
run: |
4544
# From release (does not work with beta versions)
46-
GRAPHBLAS_PREFIX=${CONDA_PREFIX} bash suitesparse.sh refs/tags/${{ matrix.graphblas-version }}.0
45+
GRAPHBLAS_PREFIX=${CONDA_PREFIX} bash suitesparse.sh refs/tags/$(cat GB_VERSION.txt).0
4746
4847
# From tag
49-
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/archive/refs/tags/v${{ matrix.graphblas-version }}.tar.gz | tar xzf -
50-
# pushd GraphBLAS-${{ matrix.graphblas-version }}/build
48+
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/archive/refs/tags/v$(cat GB_VERSION.txt).tar.gz | tar xzf -
49+
# pushd GraphBLAS-$(cat GB_VERSION.txt)/build
5150
5251
# From branch
53-
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/tarball/${{ matrix.graphblas-version }} | tar xzf -
52+
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/tarball/$(cat GB_VERSION.txt) | tar xzf -
5453
# pushd DrTim*/build
5554
5655
# echo ${CONDA_PREFIX}
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Checks for latest SuiteSparse:GraphBLAS version on GitHub and creates a PR to update the version used by this repo.
2+
name: Check for GraphBLAS updates
3+
4+
# In addition to permissions below, must explicitly allow GitHub Actions to create pull requests.
5+
# This setting can be found in a repository's settings under Actions > General > Workflow permissions.
6+
# https://github.com/peter-evans/create-pull-request#workflow-permissions
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
on:
12+
# Note: Workflow must run at least once to appear in workflows list.
13+
# Push to the bot's branch to trigger workflow.
14+
push:
15+
branches: [ auto_update_gb_version ]
16+
17+
# Note: Workflow must exist in main branch for workflow dispatch option to appear
18+
workflow_dispatch:
19+
20+
# Enable cron to check for updates once a day:
21+
# schedule:
22+
# - cron: '0 0 * * *'
23+
24+
jobs:
25+
gb_version_check:
26+
name: Check for GraphBLAS update
27+
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' || github.repository == 'alugowski/python-suitesparse-graphblas'
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: "3.11"
37+
38+
- name: Get latest GraphBLAS version
39+
run: |
40+
python latest_suitesparse_graphblas_version.py > GB_VERSION.txt
41+
echo "GB_VERSION=$(cat GB_VERSION.txt)" >> $GITHUB_ENV
42+
shell: bash
43+
44+
- name: Create Pull Request
45+
uses: peter-evans/create-pull-request@v5
46+
with:
47+
# See documentation: https://github.com/peter-evans/create-pull-request
48+
# Action behavior: https://github.com/peter-evans/create-pull-request#action-behaviour
49+
# TL;DR: create a PR if there is a diff and keep it up to date with changes as they arrive.
50+
#
51+
# To trigger tests with this PR set up a Personal Access Token as in the docs above.
52+
# token: ${{ secrets.PAT }}
53+
add-paths: GB_VERSION.txt
54+
commit-message: Update to GraphBLAS ${{ env.GB_VERSION }}
55+
title: Update to SuiteSparse:GraphBLAS ${{ env.GB_VERSION }}
56+
body: |
57+
Auto-generated by `update_graphblas.yml`
58+
59+
Close then reopen this PR to trigger tests. See [here](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) for why automatic triggers do not work.
60+
branch: auto_update_gb_version
61+
delete-branch: true

.github/workflows/wheels.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ jobs:
5252
build_wheels:
5353
name: Wheels - ${{ matrix.cibw_archs }} ${{ matrix.arch_note}} - ${{ matrix.os }}
5454
runs-on: ${{ matrix.os }}
55-
env:
56-
# graphblas version to use if another one is not provided
57-
default-graphblas-version: "8.2.1"
58-
5955
strategy:
6056
fail-fast: false
6157
matrix:
@@ -123,7 +119,13 @@ jobs:
123119
# Ask suitesparse.sh to compile in the fastest way possible and provide a GB version to build
124120
run: |
125121
echo "SUITESPARSE_FASTEST_BUILD=1" >> $GITHUB_ENV
126-
echo "GB_VERSION_REF=refs/tags/${{ env.default-graphblas-version }}.0" >> $GITHUB_ENV
122+
shell: bash
123+
124+
- name: Setup GraphBLAS version from GB_VERSION.txt
125+
# Use GraphBLAS version specified in GB_VERSION.txt unless specified in a git tag (next workflow step).
126+
# Git tag method required for uploads to PyPI.
127+
if: github.event_name != 'release' && github.event.inputs.upload_dest != 'PyPI'
128+
run: echo "GB_VERSION_REF=refs/tags/$(cat GB_VERSION.txt).0" >> $GITHUB_ENV
127129
shell: bash
128130

129131
- name: Setup GraphBLAS version from git tag

GB_VERSION.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.2.1
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Find and print the latest version of SuiteSparse:GraphBLAS as published in this repo:
5+
https://github.com/DrTimothyAldenDavis/GraphBLAS
6+
"""
7+
8+
import json
9+
from urllib.error import URLError
10+
from urllib.request import urlopen
11+
12+
# fetch release data from GraphBLAS repo
13+
for _ in range(5):
14+
try:
15+
with urlopen(
16+
"https://api.github.com/repos/DrTimothyAldenDavis/GraphBLAS/releases/latest"
17+
) as url:
18+
latest_release = json.load(url)
19+
break
20+
except URLError:
21+
# sleep before trying again
22+
from time import sleep
23+
24+
sleep(1)
25+
26+
version = latest_release["tag_name"].lstrip("v")
27+
print(version)

0 commit comments

Comments
 (0)