Checking some relations and capabilities between GitHub & Git, client-server model, network, GitHub actions and Continous Integration.
Making this repo most committed one on GitHub
- Committing and pushing from GitHub to GitHub.
- In the beginning I used my local and another platform to run git workflow scripts. But later on, I used GitHub actions to run them. So that there is no network latency because committed repo and committing actions (GitHub actions) resides in the same platform/virtual machine. That means pushing from GitHub to GitHub.
- Getting
COMMIT_COUNTandPUSH_THRESHOLDfrom .env - Running
scriptsvia workflows to achive 1. step
git.sh
#!/bin/bashsource .env
git pull
foriin$(evalecho {1..$COMMIT_COUNT} )do
git commit --allow-empty -m 'go + git + github = 💥'if [[ $i%$PUSH_THRESHOLD-eq 0 ]]
then git push echo'🛬 pushed successfully'fidonegit.go
package main
import (
"fmt""os""strconv""os/exec""github.com/joho/godotenv"
)
funcmain() {
godotenv.Load() commitCount, _:=strconv.Atoi(os.Getenv("COMMIT_COUNT"))
pushThreshold, _:=strconv.Atoi(os.Getenv("PUSH_THRESHOLD"))
git:="git"commit:="commit"push:="push"allow_empty:="--allow-empty"m:="-m"message:="'go + git + github = 💥'"fori:=0; i<commitCount; i++ {
cmdCommit:=exec.Command(git, commit, allow_empty, m, message)
stdoutCommit, errCommit:=cmdCommit.Output()
iferrCommit!=nil {
fmt.Println("🔥 commit error: ", errCommit.Error())
return
}
fmt.Println("🚀 ",string(stdoutCommit))
if (i%pushThreshold==0) {
cmdPush:=exec.Command(git, push)
_, errPush:=cmdPush.Output()
iferrPush!=nil {
fmt.Println("🔥 push error: ", errPush.Error())
}
fmt.Println("🛬 pushed successfully")
}
}
}git.js
const{ exec }=require("child_process");require('dotenv').config();constcommitCount=process.env.COMMIT_COUNT;constpushThreshold=process.env.PUSH_THRESHOLD;constgitPull=()=>{returnexec("git pull",(err,stdout,stderr)=>{if(err){console.log("🔥 pull error: ",err);return;}console.log(`🚀 : ${stdout}`);});};constgitCommit=()=>{returnexec('git commit --allow-empty -m "go + git + github = 💥"',(err,stdout,stderr)=>{if(err){// console.log("🔥 commit error: ", err);return;}console.log(`🚀 : ${stdout}`);});};constgitPush=()=>{returnexec("git push",(err,stdout,stderr)=>{if(err){console.log("🔥 push error: ",err);return;}console.log(`🛬 pushed successfully: ${stdout}`);});};construn=()=>{gitPull();for(leti=0;i<commitCount;i++){gitCommit();if(i%pushThreshold===0){gitPush();}}};run();Disclamer: These observations and thoughts may not be correct. These are my personal experiments and observations.
- In GitHub there are a few repos that have over 1m+ commits. ( I didn't examine througoutly).
git pushing from another platform or from our local will take slightly more time. Because there will be network latency. But using GitHub actions means our code/repo and Git are in same platform/machine ( a virtual machine provisioned by GitHub which our repo and action runners resides). So that there will be no network latency. That makesgit pushblazingly faster.- Golang felt faster than Bash and Node, it's like a super-jet.
- Github actions have some restrictions and limits . Some GitHub error messages are like :
- No space left on device.
- You are running out of disk space.
- Each runner has only 6 hours (360 minute) exact time to do it's job.
- Temperature of my computer (2011 model Asus brand 4 core i7 processor) suddenly rised and the fan screamed. In System Monitor, the each of 4 core were over 80%.
- In GitHub actions with Go every three second (~3000ms) ~1000 commits can be pushed. Disclamer: For that measurement I observed commit time in GitHub. So it's not scientific :)
- Gitpod blocked my account after running some scripts on their server. As they explained doing so degraded their platform and it looked like a DoS attack. Thanks to them again for unblocking my account. It's a nice and powerful platform.
- GitHub is such a powerful platform. Tens of thousands of file (.txt) I have created and written with commits alongside of push and nothing broken.
- I have learned also that git has a flag that is
--allow-emptyand lets you write commit without any change. - ..... to be continued.