[llvm] [Github] Force files changed step in docs action to use GH API (PR #69763)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 14:45:15 PDT 2023


https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/69763

>From 8de66944bfa2a6791225fda68d73fd1775a63119 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 20 Oct 2023 12:49:56 -0700
Subject: [PATCH 1/3] [Github] Force files changed step in docs action to use
 GH API

This patch forces the files changed step in the test documentation
Github action to use the Github API to look for changed files rather
than using the local git history. Using the local git history takes a
significant amount of time(~30m with no depth limit, ~10m with a depth
limit of 100) while using the GH API is virtually instantaneous. This
uses an extra GH API request, but given the frequency that this action
runs with, that shouldn't be an issue.
---
 .github/workflows/docs.yml | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index d58c7d51e0e44ab..0603dfa3df19b21 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -25,6 +25,15 @@ jobs:
     name: "Test documentation build"
     runs-on: ubuntu-latest
     steps:
+      - name: Get subprojects that have doc changes
+        id: docs-changed-subprojects
+        uses: tj-actions/changed-files at v39
+        with:
+          files_yaml: |
+            llvm:
+              - 'llvm/docs/**'
+            clang:
+              - 'clang/docs/**'
       - name: Fetch LLVM sources
         uses: actions/checkout at v4
         with:
@@ -41,15 +50,6 @@ jobs:
         run: |
           sudo apt-get update
           sudo apt-get install -y cmake ninja-build
-      - name: Get subprojects that have doc changes
-        id: docs-changed-subprojects
-        uses: tj-actions/changed-files at v39
-        with:
-          files_yaml: |
-            llvm:
-              - 'llvm/docs/**'
-            clang:
-              - 'clang/docs/**'
       - name: Build LLVM docs
         if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
         run: |

>From 4258c30e427cc11d211e182725949e455441532f Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 20 Oct 2023 13:06:16 -0700
Subject: [PATCH 2/3] Add comment explaining ordering of steps

---
 .github/workflows/docs.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 0603dfa3df19b21..56d86fd2951cb96 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -25,6 +25,9 @@ jobs:
     name: "Test documentation build"
     runs-on: ubuntu-latest
     steps:
+      # Get changed files before we do a checkout to force the action to use
+      # the GH API to look for changed files and avoid an expensive partial
+      # fetch operation.
       - name: Get subprojects that have doc changes
         id: docs-changed-subprojects
         uses: tj-actions/changed-files at v39

>From fed3105a23a69a1991f4501ccca88235857e7a7f Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 20 Oct 2023 14:38:36 -0700
Subject: [PATCH 3/3] Change approach to fetch depth

---
 .github/workflows/docs.yml | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 56d86fd2951cb96..8eadd382398089a 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -25,9 +25,19 @@ jobs:
     name: "Test documentation build"
     runs-on: ubuntu-latest
     steps:
-      # Get changed files before we do a checkout to force the action to use
-      # the GH API to look for changed files and avoid an expensive partial
-      # fetch operation.
+      # Fetch all the commits in a pull request so that the
+      # docs-changed-subprojects step won't pull them in itself in an extremely
+      # slow manner.
+      - name: Fetch LLVM sources (PR)
+        if: ${{ github.event_name == 'pull_request' }} 
+        uses: actions/checkout at v4
+        with:
+          fetch-depth: ${{ github.event.pull_request.commits }}
+      - name: Fetch LLVM sources (push)
+        if: ${{ github.event_name == 'push' }}
+        uses: actions/checkout at v4
+        with:
+          fetch-depth: 1
       - name: Get subprojects that have doc changes
         id: docs-changed-subprojects
         uses: tj-actions/changed-files at v39
@@ -37,10 +47,6 @@ jobs:
               - 'llvm/docs/**'
             clang:
               - 'clang/docs/**'
-      - name: Fetch LLVM sources
-        uses: actions/checkout at v4
-        with:
-          fetch-depth: 1
       - name: Setup Python env
         uses: actions/setup-python at v4
         with:



More information about the llvm-commits mailing list