You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "lordgamez (via GitHub)" <gi...@apache.org> on 2023/06/30 07:51:41 UTC

[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1591: MINIFICPP-2130 Custom cache eviction strategy for GitHub Actions

lordgamez commented on code in PR #1591:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1591#discussion_r1247553731


##########
.github/workflows/ci.yml:
##########
@@ -142,6 +154,12 @@ jobs:
               -DENABLE_AZURE=OFF -DENABLE_SPLUNK=OFF -DENABLE_GCP=OFF -DENABLE_PROCFS=OFF -DENABLE_BUSTACHE=ON -DENABLE_PCAP=ON -DENABLE_JNI=ON -DENABLE_SFTP=ON  \
               -DENABLE_LUA_SCRIPTING=OFF -DENABLE_PYTHON_SCRIPTING=OFF -DENABLE_MQTT=OFF -DENABLE_ELASTICSEARCH=OFF -DENABLE_KUBERNETES=OFF -DENABLE_OPC=OFF ..
           make -j$(nproc) VERBOSE=1
+      - name: cache save
+        uses: actions/cache/save@v3
+        if: always()
+        with:
+          path: ~/.ccache
+          key: ubuntu-20.04-ccache-${{github.ref}}-${{github.sha}}

Review Comment:
   Before this change the cache save-restore was handled automatically in the action, by restoring the cache at the beginning of the job and saving the cache after the job was successful. The problem with this approach was that if any of the steps in the job failed, e.g. the tests were flaky or the linter failed, the build cache was not saved, so if we only wanted rerun the tests, or fixed the build in the next commit we had to run a clean build again. With this new approach after the build step is done it is saved immediately and can be reused even if any other steps fail (or even if the build fails somewhere).



##########
github_scripts/github_actions_cache_cleanup_tests.py:
##########
@@ -0,0 +1,80 @@
+#!/bin/python3
+
+import unittest
+from unittest.mock import MagicMock
+from github_actions_cache_cleanup import GithubActionsCacheCleaner
+
+
+class TestGithubActionsCacheCleaner(unittest.TestCase):
+    def create_mock_github_request_sender(self):
+        mock = MagicMock()
+        mock.list_open_pull_requests = MagicMock()
+        open_pull_requests = [
+            {
+                "number": "227",
+                "title": "MINIFICPP-13712 TEST1",
+            },
+            {
+                "number": "228",
+                "title": "MINIFICPP-9999 TEST2",
+            },
+            {
+                "number": "229",
+                "title": "MINIFICPP-123 TEST3",
+            }
+        ]
+        mock.list_open_pull_requests.return_value = open_pull_requests
+        caches = {
+            "actions_caches": [
+                {
+                    "id": "999",
+                    "key": "macos-xcode-ccache-refs/pull/226/merge-6c8d283f5bc894af8dfc295e5976a5f154753123",
+                },
+                {
+                    "id": "11111",
+                    "key": "ubuntu-20.04-ccache-refs/pull/227/merge-9d6d283f5bc894af8dfc295e5976a5f1b46649c4",
+                },
+                {
+                    "id": "11112",
+                    "key": "ubuntu-20.04-ccache-refs/pull/227/merge-1d6d283f5bc894af8dfc295e5976a5f154753487",
+                },
+                {
+                    "id": "12345",
+                    "key": "macos-xcode-ccache-refs/pull/227/merge-2d6d283f5bc894af8dfc295e5976a5f154753536",
+                },
+                {
+                    "id": "22221",
+                    "key": "macos-xcode-ccache-refs/heads/MINIFICPP-9999-9d5e183f5bc894af8dfc295e5976a5f1b4664456",
+                },
+                {
+                    "id": "22222",
+                    "key": "macos-xcode-ccache-refs/heads/MINIFICPP-9999-8f4d283f5bc894af8dfc295e5976a5f1b4664123",
+                },
+                {
+                    "id": "44444",
+                    "key": "ubuntu-20.04-all-clang-ccache-refs/heads/main-1d4d283f5bc894af8dfc295e5976a5f1b4664456",
+                },
+                {
+                    "id": "55555",
+                    "key": "ubuntu-20.04-all-clang-ccache-refs/heads/main-2f4d283f5bc894af8dfc295e5976a5f1b4664567",
+                }

Review Comment:
   We check [which id is bigger,](https://github.com/apache/nifi-minifi-cpp/pull/1591/files#diff-2928f02afcafb093965cad50e466a01dc35c94e133f336a057c612bc530fb5d0R83) as I checked the cache ids are sequential in github actions



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org