diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 24498e8..8c6249f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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} diff --git a/.github/workflows/update_graphblas.yml b/.github/workflows/update_graphblas.yml new file mode 100644 index 0000000..b2ecb47 --- /dev/null +++ b/.github/workflows/update_graphblas.yml @@ -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 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index be6bfd8..bacc009 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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: @@ -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 diff --git a/GB_VERSION.txt b/GB_VERSION.txt new file mode 100644 index 0000000..2b0aa21 --- /dev/null +++ b/GB_VERSION.txt @@ -0,0 +1 @@ +8.2.1 diff --git a/latest_suitesparse_graphblas_version.py b/latest_suitesparse_graphblas_version.py new file mode 100644 index 0000000..dbcc310 --- /dev/null +++ b/latest_suitesparse_graphblas_version.py @@ -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)