Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage GraphBLAS version with GB_VERSION.txt file #114

Merged
merged 2 commits into from
Nov 1, 2023
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
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
# os: ["ubuntu-latest"]
# source: ["source"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
graphblas-version: ["8.2.1"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -38,19 +37,19 @@ jobs:
- name: GraphBLAS (from conda-forge)
if: (contains(matrix.source, 'conda-forge'))
run: |
conda install graphblas=${{ matrix.graphblas-version }}
conda install graphblas=$(cat GB_VERSION.txt)
- name: GraphBLAS (from source)
if: (contains(matrix.source, 'source'))
run: |
# From release (does not work with beta versions)
GRAPHBLAS_PREFIX=${CONDA_PREFIX} bash suitesparse.sh refs/tags/${{ matrix.graphblas-version }}.0
GRAPHBLAS_PREFIX=${CONDA_PREFIX} bash suitesparse.sh refs/tags/$(cat GB_VERSION.txt).0

# From tag
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/archive/refs/tags/v${{ matrix.graphblas-version }}.tar.gz | tar xzf -
# pushd GraphBLAS-${{ matrix.graphblas-version }}/build
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/archive/refs/tags/v$(cat GB_VERSION.txt).tar.gz | tar xzf -
# pushd GraphBLAS-$(cat GB_VERSION.txt)/build

# From branch
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/tarball/${{ matrix.graphblas-version }} | tar xzf -
# curl -L https://github.com/DrTimothyAldenDavis/GraphBLAS/tarball/$(cat GB_VERSION.txt) | tar xzf -
# pushd DrTim*/build

# echo ${CONDA_PREFIX}
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/update_graphblas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Checks for latest SuiteSparse:GraphBLAS version on GitHub and creates a PR to update the version used by this repo.
name: Check for GraphBLAS updates

# In addition to permissions below, must explicitly allow GitHub Actions to create pull requests.
# This setting can be found in a repository's settings under Actions > General > Workflow permissions.
# https://github.com/peter-evans/create-pull-request#workflow-permissions
permissions:
contents: write
pull-requests: write

on:
# Note: Workflow must run at least once to appear in workflows list.
# Push to the bot's branch to trigger workflow.
push:
branches: [ auto_update_gb_version ]

# Note: Workflow must exist in main branch for workflow dispatch option to appear
workflow_dispatch:

# Enable cron to check for updates once a day:
# schedule:
# - cron: '0 0 * * *'

jobs:
gb_version_check:
name: Check for GraphBLAS update
if: github.repository == 'GraphBLAS/python-suitesparse-graphblas' || github.repository == 'alugowski/python-suitesparse-graphblas'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Get latest GraphBLAS version
run: |
python latest_suitesparse_graphblas_version.py > GB_VERSION.txt
echo "GB_VERSION=$(cat GB_VERSION.txt)" >> $GITHUB_ENV
shell: bash

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
# See documentation: https://github.com/peter-evans/create-pull-request
# Action behavior: https://github.com/peter-evans/create-pull-request#action-behaviour
# TL;DR: create a PR if there is a diff and keep it up to date with changes as they arrive.
#
# To trigger tests with this PR set up a Personal Access Token as in the docs above.
# token: ${{ secrets.PAT }}
add-paths: GB_VERSION.txt
commit-message: Update to GraphBLAS ${{ env.GB_VERSION }}
title: Update to SuiteSparse:GraphBLAS ${{ env.GB_VERSION }}
body: |
Auto-generated by `update_graphblas.yml`

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.
branch: auto_update_gb_version
delete-branch: true
12 changes: 7 additions & 5 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ jobs:
build_wheels:
name: Wheels - ${{ matrix.cibw_archs }} ${{ matrix.arch_note}} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
# graphblas version to use if another one is not provided
default-graphblas-version: "8.2.1"

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -119,7 +115,13 @@ jobs:
# Ask suitesparse.sh to compile in the fastest way possible and provide a GB version to build
run: |
echo "SUITESPARSE_FASTEST_BUILD=1" >> $GITHUB_ENV
echo "GB_VERSION_REF=refs/tags/${{ env.default-graphblas-version }}.0" >> $GITHUB_ENV
shell: bash

- name: Setup GraphBLAS version from GB_VERSION.txt
# Use GraphBLAS version specified in GB_VERSION.txt unless specified in a git tag (next workflow step).
# Git tag method required for uploads to PyPI.
if: github.event_name != 'release' && github.event.inputs.upload_dest != 'PyPI'
run: echo "GB_VERSION_REF=refs/tags/$(cat GB_VERSION.txt).0" >> $GITHUB_ENV
shell: bash

- name: Setup GraphBLAS version from git tag
Expand Down
1 change: 1 addition & 0 deletions GB_VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.2.1
27 changes: 27 additions & 0 deletions latest_suitesparse_graphblas_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

"""
Find and print the latest version of SuiteSparse:GraphBLAS as published in this repo:
https://github.com/DrTimothyAldenDavis/GraphBLAS
"""

import json
from urllib.error import URLError
from urllib.request import urlopen

# fetch release data from GraphBLAS repo
for _ in range(5):
try:
with urlopen(
"https://api.github.com/repos/DrTimothyAldenDavis/GraphBLAS/releases/latest"
) as url:
latest_release = json.load(url)
break
except URLError:
# sleep before trying again
from time import sleep

sleep(1)

version = latest_release["tag_name"].lstrip("v")
print(version)