From 97bfb3a5d6728ffabf9b6bd3316f499ffa1e45f6 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 28 Sep 2023 08:08:28 +0800 Subject: [PATCH 1/8] Only apply fixes for PRs --- .github/workflows/build.yml | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d2df419891..a3093e12afc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,36 +24,26 @@ concurrency: cancel-in-progress: true jobs: - get_ci_fixes: + build: runs-on: ubuntu-latest + container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} steps: - name: Checkout id: checkout uses: actions/checkout@v4 + + - name: Install GH CLI + uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 + if: ${{ github.event_name == 'pull_request' }} + with: + gh-cli-version: 2.32.0 + - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' }} run: | .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} - - name: Store CI fixes in upstream artifact - run: | - mkdir -p upstream - if git format-patch --stdout test_base > ci_fixes.patch; then - cp ci_fixes.patch upstream/ - fi - - uses: actions/upload-artifact@v3 - with: - path: upstream - name: upstream - - build: - runs-on: ubuntu-latest - container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} - needs: [get_ci_fixes] - steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - name: Update system packages id: prepare From 75324e2b88990e03150638466d60eb65e6369d8e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 28 Sep 2023 08:58:31 +0800 Subject: [PATCH 2/8] Install git as well --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3093e12afc..3d9eefaec14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,10 @@ jobs: id: checkout uses: actions/checkout@v4 + - name: Install git + run: sudo apt-get install git-core + if: ${{ github.event_name == 'pull_request' }} + - name: Install GH CLI uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 if: ${{ github.event_name == 'pull_request' }} From 0e7c0a47cfbf4945bc4f0f20f0b6a9f387859c0b Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 28 Sep 2023 11:13:57 +0800 Subject: [PATCH 3/8] reorder commands --- .github/workflows/build.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d9eefaec14..6dba753824d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,9 +32,12 @@ jobs: id: checkout uses: actions/checkout@v4 - - name: Install git - run: sudo apt-get install git-core - if: ${{ github.event_name == 'pull_request' }} + - name: Update system packages + id: prepare + run: | + export PATH="build/bin:$PATH" + eval $(sage-print-system-package-command auto update) + eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git) - name: Install GH CLI uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 @@ -49,13 +52,6 @@ jobs: env: GH_TOKEN: ${{ github.token }} - - name: Update system packages - id: prepare - run: | - export PATH="build/bin:$PATH" - eval $(sage-print-system-package-command auto update) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git) - - name: Add prebuilt tree as a worktree id: worktree run: | From 43194f8f5b3a41a7a15f44ecd50c335d4d5065cf Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 28 Sep 2023 11:20:32 +0800 Subject: [PATCH 4/8] First setup git repo, then apply fixes --- .github/workflows/build.yml | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dba753824d..cb55fb2e49b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,13 +45,6 @@ jobs: with: gh-cli-version: 2.32.0 - - name: Merge CI fixes from sagemath/sage - if: ${{ github.event_name == 'pull_request' }} - run: | - .ci/merge-fixes.sh - env: - GH_TOKEN: ${{ github.token }} - - name: Add prebuilt tree as a worktree id: worktree run: | @@ -81,18 +74,12 @@ jobs: if [ ! -f worktree-image/.gitignore ]; then cp .gitignore worktree-image/; fi (cd worktree-image && git add -A && git commit --quiet --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset --quiet old && git add -N . && git status) - - name: Download upstream artifact - uses: actions/download-artifact@v3 - with: - path: upstream - name: upstream - - - name: Apply CI fixes from sagemath/sage - # After applying the fixes, make sure all changes are marked as uncommitted changes. + - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' }} run: | - if [ -r upstream/ci_fixes.patch ]; then - (cd worktree-image && git commit -q -m "current changes" --allow-empty -a && git am; git reset --quiet old; git add -N .) < upstream/ci_fixes.patch - fi + .ci/merge-fixes.sh + env: + GH_TOKEN: ${{ github.token }} - name: Incremental build, test changed files (sage -t --new) id: incremental From 7b12774131d5f9071c2be36ba34f18e7f37fddae Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 13 Oct 2023 01:17:17 +0000 Subject: [PATCH 5/8] run also on forks, and change docbuild, conda and linter accordingly --- .github/workflows/build.yml | 29 ++++++++-------- .github/workflows/ci-conda.yml | 1 + .github/workflows/doc-build-pdf.yml | 51 ++++++++++------------------- .github/workflows/doc-build.yml | 51 ++++++++--------------------- .github/workflows/lint.yml | 3 ++ 5 files changed, 49 insertions(+), 86 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5208db87e20..66d0ac0c4f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,23 +31,29 @@ jobs: runs-on: ubuntu-latest container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} steps: + - name: Install git + uses: ConorMacBride/install-package@v1.1.0 + with: + brew: git + apt: git + - name: Checkout id: checkout uses: actions/checkout@v4 - - name: Update system packages - id: prepare - run: | - export PATH="build/bin:$PATH" - eval $(sage-print-system-package-command auto update) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git) - - name: Install GH CLI uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} with: gh-cli-version: 2.32.0 + - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} + run: | + .ci/merge-fixes.sh + env: + GH_TOKEN: ${{ github.token }} + - name: Add prebuilt tree as a worktree id: worktree run: | @@ -77,13 +83,6 @@ jobs: if [ ! -f worktree-image/.gitignore ]; then cp .gitignore worktree-image/; fi (cd worktree-image && git add -A && git commit --quiet --allow-empty -m "old" -a && git tag -f old && git reset --hard new && git reset --quiet old && git add -N . && git status) - - name: Merge CI fixes from sagemath/sage - if: ${{ github.event_name == 'pull_request' }} - run: | - .ci/merge-fixes.sh - env: - GH_TOKEN: ${{ github.token }} - - name: Incremental build, test changed files (sage -t --new) id: incremental run: | diff --git a/.github/workflows/ci-conda.yml b/.github/workflows/ci-conda.yml index 75babf3ab8c..1957c5352c6 100644 --- a/.github/workflows/ci-conda.yml +++ b/.github/workflows/ci-conda.yml @@ -34,6 +34,7 @@ jobs: - uses: actions/checkout@v4 - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index 0413954210b..d93a252ecb0 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -21,43 +21,39 @@ concurrency: cancel-in-progress: true jobs: - get_ci_fixes: + build-docs-pdf: runs-on: ubuntu-latest + container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} steps: + - name: Install git + uses: ConorMacBride/install-package@v1.1.0 + with: + brew: git + apt: git + - name: Checkout id: checkout uses: actions/checkout@v4 + + - name: Install GH CLI + uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} + with: + gh-cli-version: 2.32.0 + - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} - - name: Store CI fixes in upstream artifact - run: | - mkdir -p upstream - if git format-patch --stdout test_base > ci_fixes.patch; then - cp ci_fixes.patch upstream/ - fi - - uses: actions/upload-artifact@v3 - with: - path: upstream - name: upstream - - build-docs-pdf: - runs-on: ubuntu-latest - container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} - needs: [get_ci_fixes] - steps: - - name: Checkout - uses: actions/checkout@v4 - name: Update system packages run: | export PATH="build/bin:$PATH" eval $(sage-print-system-package-command auto update) eval $(sage-print-system-package-command auto --yes --no-install-recommends install zip) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive) - + eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install texlive) - name: Add prebuilt tree as a worktree id: worktree @@ -90,19 +86,6 @@ jobs: # Keep track of changes to built HTML new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") - - name: Download upstream artifact - uses: actions/download-artifact@v3 - with: - path: upstream - name: upstream - - - name: Apply CI fixes from sagemath/sage - # After applying the fixes, make sure all changes are marked as uncommitted changes. - run: | - if [ -r upstream/ci_fixes.patch ]; then - (cd worktree-image && git commit -q -m "current changes" --allow-empty -a && git am; git reset --quiet old; git add -N .) < upstream/ci_fixes.patch - fi - - name: Incremental build id: incremental run: | diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 355e07ab78e..0bc7762f081 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -16,39 +16,29 @@ concurrency: cancel-in-progress: true jobs: - get_ci_fixes: + build-docs: runs-on: ubuntu-latest + container: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets:dev steps: + - name: Update system packages + run: | + apt-get update && apt-get install -y git zip + - name: Checkout - id: checkout uses: actions/checkout@v4 + + - name: Install GH CLI + uses: dev-hanz-ops/install-gh-cli-action@v0.1.0 + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} + with: + gh-cli-version: 2.32.0 + - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} - - name: Store CI fixes in upstream artifact - run: | - mkdir -p upstream - if git format-patch --stdout test_base > ci_fixes.patch; then - cp ci_fixes.patch upstream/ - fi - - uses: actions/upload-artifact@v3 - with: - path: upstream - name: upstream - - build-docs: - runs-on: ubuntu-latest - container: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets:dev - needs: [get_ci_fixes] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Update system packages - run: | - apt-get update && apt-get install -y git zip - name: Add prebuilt tree as a worktree id: worktree @@ -81,19 +71,6 @@ jobs: # Keep track of changes to built HTML new_version=$(cat src/VERSION.txt); (cd /sage/local/share/doc/sage/html/en && find . -name "*.html" | xargs sed -i '/class="sidebar-brand-text"/s/Sage [0-9a-z.]* /Sage '$new_version' /'; git init && (echo "*.svg binary"; echo "*.pdf binary") >> .gitattributes && (echo ".buildinfo"; echo '*.inv'; echo '.git*'; echo '*.svg'; echo '*.pdf'; echo '*.png'; echo 'searchindex.js') > .gitignore; git add -A && git commit --quiet -m "old") - - name: Download upstream artifact - uses: actions/download-artifact@v3 - with: - path: upstream - name: upstream - - - name: Apply CI fixes from sagemath/sage - # After applying the fixes, make sure all changes are marked as uncommitted changes. - run: | - if [ -r upstream/ci_fixes.patch ]; then - (cd worktree-image && git commit -q -m "current changes" --allow-empty -a && git am; git reset --quiet old; git add -N .) < upstream/ci_fixes.patch - fi - - name: Incremental build id: incremental run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 79ca26827b1..3c94b6fb729 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: @@ -40,6 +41,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: @@ -59,6 +61,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Merge CI fixes from sagemath/sage + if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | .ci/merge-fixes.sh env: From b5ee73563417f1b11b7a39f99fd39155c4875bf4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 13 Oct 2023 01:26:17 +0000 Subject: [PATCH 6/8] add safe directory git config --- .github/workflows/build.yml | 1 + .github/workflows/doc-build-pdf.yml | 1 + .github/workflows/doc-build.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66d0ac0c4f5..8705f1f7e29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,7 @@ jobs: - name: Merge CI fixes from sagemath/sage if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index d93a252ecb0..e2b91f8a6ac 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -44,6 +44,7 @@ jobs: - name: Merge CI fixes from sagemath/sage if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 0bc7762f081..2b258dea842 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -36,6 +36,7 @@ jobs: - name: Merge CI fixes from sagemath/sage if: ${{ github.event_name == 'pull_request' || github.event.repository.fork }} run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" .ci/merge-fixes.sh env: GH_TOKEN: ${{ github.token }} From e61d55739e6321e78f368a868ca56712e8ba2444 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 13 Oct 2023 01:35:08 +0000 Subject: [PATCH 7/8] manually install git --- .github/workflows/build.yml | 16 +++++++++++----- .github/workflows/doc-build-pdf.yml | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8705f1f7e29..64d59c786ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,11 +31,17 @@ jobs: runs-on: ubuntu-latest container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} steps: - - name: Install git - uses: ConorMacBride/install-package@v1.1.0 - with: - brew: git - apt: git + - name: Install git (macos) + if: runner.os == 'macOS' + run: | + brew update + brew install git + + - name: Install git (linux) + if: runner.os == 'Linux' + run: | + apt update + apt install -y git - name: Checkout id: checkout diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index e2b91f8a6ac..3cbaa03c0fc 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -25,11 +25,17 @@ jobs: runs-on: ubuntu-latest container: ghcr.io/sagemath/sage/sage-${{ github.event.inputs.platform || 'ubuntu-focal-standard' }}-with-targets:${{ github.event.inputs.docker_tag || 'dev'}} steps: - - name: Install git - uses: ConorMacBride/install-package@v1.1.0 - with: - brew: git - apt: git + - name: Install git (macos) + if: runner.os == 'macOS' + run: | + brew update + brew install git + + - name: Install git (linux) + if: runner.os == 'Linux' + run: | + apt update + apt install -y git - name: Checkout id: checkout From c729118fc6a7227146174077692852f2d20ac99c Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 13 Oct 2023 01:53:20 +0000 Subject: [PATCH 8/8] add --allow-unrelated-histories --- .ci/merge-fixes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/merge-fixes.sh b/.ci/merge-fixes.sh index 1fb8267df0e..cd4e768a978 100755 --- a/.ci/merge-fixes.sh +++ b/.ci/merge-fixes.sh @@ -19,7 +19,7 @@ else $GH pr checkout -b pr-$a $a git fetch --unshallow --all git checkout -q test_head - if git merge --no-edit --squash -q pr-$a; then + if git merge --no-edit --squash --allow-unrelated-histories -q pr-$a; then echo "::endgroup::" if git commit -q -m "Merge https://github.com/$REPO/pull/$a" -a --no-allow-empty; then echo "Merged #$a"