Skip to content

Add GitHub workflow to run autoreconf and regen configure on demand #104903

@CAM-Gerlach

Description

@CAM-Gerlach

There was a desire among the core devs to allow easily regenerating the configure script using autoreconf, to avoid having to pull and run a docker image locally, or install and run the correct version of autoreconf manually, as well as avoid any unnecessary churn due to being regenerated in different environments.

We should be able to just use our own GitHub Action, which is basically the pre-commit lite approach minus installing the pre-commit GitHub Application and giving it access rights. We use this approach on the Docrepr project to automate generating consistent updated reference screenshots for visual regression tests and commiting them to a PR, triggered on-demand via a comment. (It's actually somewhat more complex than we'd need, since it has to run on multiple platforms to generate the screenshots for each)

Right now its triggered by a comment, but it would be relatively straightforward to change that to a label or manual dispatch. The other option is to have it run automatically as a precursor to the Build workflow jobs and update the PR's generated configure if its out of date, but that could get a little complicated to set up, be potentially surprising/confusing to contributors, could suffer from race conditions and not really save that much time over an explicit comment, so I suggest we start with an explicit comment trigger (or a label, etc.).

Might also be a good idea to drop-in gh for hub, since its newer and might simplify things a touch (it just might need a couple other tweaks for that, so I didn't do it yet).

Other than that, once the configure.ac is updated to work with Autoconf 2.71 (since that's the version currently used on the ubuntu-22.04 runner, and the standard version these days), we should be able to just drop in the below workflow in to have autoreconf be run in the GitHub Actions CI for a specific PR and commit the results back to the PR automatically. (I can test it on my fork to make sure it works—though as I'm a complete autotools n00b, I'll need help if I run into any autoconf specific problems).

name: Regen Configure

on:
  issue_comment:
    types: [created, edited]

permissions:
  pull-requests: write

jobs:
  regen-configure:
    if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'Please regenerate configure') }}
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Configure hub setting to use HTTPS
        run: git config --global hub.protocol https
      - name: Checkout the branch from the PR that triggered the job
        run: hub pr checkout ${{ github.event.issue.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Regenerate configure
        id: regen
        run: |
          autoreconf -ivf -Werror
          echo "changes=$(git diff-index --quiet HEAD -- && echo 1)" >> $env:GITHUB_OUTPUT
      - name: Commit regenerated configure
        if: steps.regen.outputs.changes == '1'
        run: |
          git config user.name 'github-actions[bot]'
          git config user.email 'github-actions[bot]@users.noreply.github.com'
          git pull
          git add -u
          git commit -m "Regenerate configure"
          git push
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildinfraCI, GitHub Actions, buildbots, Dependabot, etc.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions