local caching के जरिए GitHub Actions की गति बढ़ाना
(github.com/corca-ai)GitHub में git action का उपयोग करके CI/CD pipeline चलाने वाले लोग बहुत होंगे। तेज़ build के लिए cache का काफ़ी उपयोग किया जाता है, लेकिन शुरुआत में बड़ी समस्या नहीं दिखती; जैसे-जैसे service बड़ी होती है या branches बढ़ती हैं, caching काम नहीं करती और हर बार फिर से build होने लगता है, जिससे गति धीमी पड़ने लगती है। इसकी वजह यह है कि GitHub Actions की default caching में 10GB की size limit होती है.
इस समस्या को हल करने के लिए हमने self-hosted runner पर local में cache कर सकने वाला एक package विकसित किया है.
- name: Cache node dependencies
id: node-cache
uses: corca-ai/local-cache@v2
with:
path: node_modules
key: node-${{ hashFiles(‘yarn.lock’) }}
clean-key: node-
github-hosted runner की जगह self-hosted runner का उपयोग करें, और जहाँ पहले existing cache इस्तेमाल हो रहा था वहाँ uses हिस्से को corca-ai/local-cache में बदल दें, तो इसे तुरंत इस्तेमाल किया जा सकता है.
cache की size limit समाप्त हो जाती है, और जहाँ existing caching network के ज़रिए cache files लाती है, वहीं local caching सीधे disk से load होती है, इसलिए caching speed में काफ़ी बड़ा सुधार होता है। हमने 5 गुना से अधिक speed improvement महसूस किया है.
1 टिप्पणियां
इसी तरह की एक चीज़ maxnowack/local-cache भी है।