From 4aa00086eb2aaa32d5e9572a1d2b5dba474850f6 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Sun, 12 Jan 2025 11:00:30 +0000 Subject: [PATCH] Try new strategy for auto updates (#664) I previously added a CI that the documentation was not dirty. This turns out to be too strict: it's onerous to have contributors install the exactly-matching `nroff` setup required to sync the documentation. Instead, the CI check now commits and pushes the change to the PR (if it's a same-fork PR), and ignores the changes if it's a PR from another fork. The CI will push the PrepareRelease changes on master, if needed. Fixes #653 --- .github/workflows/build.yml | 3 ++- .github/workflows/clang-analyzer.yml | 1 + .github/workflows/dev.yml | 33 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 911a2e76c..059b71fa7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -291,6 +291,7 @@ jobs: # Workaround for incorrect filesystem permissions on /usr/share/aclocal, which # causes the m4 macros to be copied with incorrect permissions. + # https://github.com/actions/runner-images/issues/11212 chmod u=rw,go=r m4/*.m4 - name: Configure @@ -303,7 +304,7 @@ jobs: run: | mkdir tarball-dir tar -C tarball-dir -xzf pcre2-*.tar.gz - # Budge the directory, so we don't back the version number into the + # Budge the directory, so we don't bake the version number into the # `manifest-tarball` file: mv tarball-dir/pcre2-* tarball-dir/pcre2-SNAPSHOT maint/RunManifestTest tarball-dir maint/manifest-tarball diff --git a/.github/workflows/clang-analyzer.yml b/.github/workflows/clang-analyzer.yml index c14236ee0..3c03cfc1d 100644 --- a/.github/workflows/clang-analyzer.yml +++ b/.github/workflows/clang-analyzer.yml @@ -23,6 +23,7 @@ jobs: # turn aborts when it finds that GitHub's CI machine doesn't have ICU. # Just turn off localisation. A future version of the ubuntu-24.04 or # ubuntu-latest runners might not need this workaround. + # https://github.com/actions/runner-images/issues/10989 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1 steps: diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 0a9dea469..9af55fff0 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -448,13 +448,18 @@ jobs: # making a PR, so that everything is kept in-sync. name: Check autogenerated file freshness runs-on: ubuntu-24.04 # TODO: Update to ubuntu-latest when that switches to 24.04 + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: false - fetch-depth: 0 + fetch-depth: 0 # Necessary for maint/PrepareRelease fetch-tags: false + # Check out the unmerged source branch for `pull_request`-triggered runs; + # otherwise use the tip of the branch for `workflow_dispatch` and `pull` triggers. + ref: ${{ github.head_ref || github.ref }} - name: PrepareRelease run: maint/PrepareRelease @@ -465,15 +470,21 @@ jobs: rm -f src/*.generic make src/config.h.generic src/pcre2.h.generic - - name: Working directory clean - run: | + # If we're in a forked repo, it's too onerous to expect contributors to run the + # checks locally to keep these files up to date (since the tool versions are very + # fussy and brittle). + # + # However, we still want to run the steps above, to check that the PrepareRelease + # process is able to run to completion, since it can pick up errors in the man pages. + + - name: Commit and push, if not in a forked repo + if: github.event_name != 'pull_request' || ( ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' ) + run: | if [ -n "`git status --porcelain`" ] ; then - ( - echo "Dirty working tree! Affected files:" - git status --porcelain || true - echo "" - echo "Diff:" - git diff || true - ) >&2 - exit 1 + # Dirty working tree: push it + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add -u + git commit -m "Sync autogenerated files" + git push fi