diff --git a/.github/workflows/setup.yaml b/.github/workflows/setup.yaml new file mode 100644 index 000000000..a85fc8880 --- /dev/null +++ b/.github/workflows/setup.yaml @@ -0,0 +1,28 @@ +--- +name: setup-ubuntu +on: + workflow_call: + secrets: {} + +job: + setup-repo: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: sudo apt install -y make direnv unzip lz4 wget curl npm jq pv coreutils + - name: Install git-cliff + uses: baptiste0928/cargo-install@v3 + with: + crate: git-cliff + - name: Detect required Go version + run: | + toolchain=$(./script/tools.sh gotoolchain | sed 's/go*//') + echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + - uses: actions/setup-go@v5 + with: + go-version: "${{ env.GOVERSION }}" + check-latest: true + - name: set environment + uses: HatsuneMiku3939/direnv-action@v1 + with: + masks: '' diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b01518a27..f52bb0325 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -22,10 +22,6 @@ jobs: run: | brew install bash direnv pv lz4 git-cliff sudo chsh -s /usr/local/bin/bash - - name: Install git-cliff - uses: baptiste0928/cargo-install@v3 - with: - crate: git-cliff - name: Hook direnv to bash run: echo 'eval "$(direnv hook bash)"' >> $HOME/.bashrc - uses: actions/checkout@v4 @@ -47,25 +43,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: git fetch --prune --unshallow - - name: Install dependencies - run: sudo apt install -y make direnv unzip lz4 wget curl npm jq pv coreutils - - name: Install git-cliff - uses: baptiste0928/cargo-install@v3 with: - crate: git-cliff - - name: Detect required Go version - run: | - toolchain=$(./script/tools.sh gotoolchain | sed 's/go*//') - echo "GOVERSION=${toolchain}" >> $GITHUB_ENV - - uses: actions/setup-go@v5 - with: - go-version: "${{ env.GOVERSION }}" - check-latest: true - - name: set environment - uses: HatsuneMiku3939/direnv-action@v1 - with: - masks: '' + token: ${{ secrets.GITHUB_TOKEN }} + - run: git fetch --prune --unshallow + - uses: ./.github/workflows/setup.yaml - run: make bins - run: make docker-image diff --git a/script/tools.sh b/script/tools.sh index 6a3071902..478aaba9c 100755 --- a/script/tools.sh +++ b/script/tools.sh @@ -5,6 +5,30 @@ SEMVER=$SCRIPT_DIR/semver.sh gomod="$SCRIPT_DIR/../go.mod" +macos_deps=( + "bash" + "direnv" + "pv" + "lz4" + "git-cliff" +) + +debian_deps=( + "make" + "build-essentials" + "direnv" + "unzip" + "wget" + "curl" + "npm" + "jq" + "coreutils" +) + +is_command() { + command -v "$1" >/dev/null +} + function get_gotoolchain() { local gotoolchain local goversion @@ -117,6 +141,80 @@ function replace_import_path() { replace_paths "./go/go.mod" "$curr_module_name" "$new_module_name" } +function install_gha_deps() { + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Detected Darwin based system" + + if ! is_command brew; then + echo "homebrew is not installed. visit https://brew.sh" + exit 1 + fi + + local tools + + if ! is_command make || [[ $(make --version | head -1 | cut -d" " -f3 | cut -d"." -f1) -lt 4 ]]; then + tools="$tools make" + fi + + # shellcheck disable=SC2068 + for dep in ${macos_deps[@]}; do + echo -n "detecting $dep ..." + status="(installed)" + if ! brew list "$dep" >/dev/null 2>&1; then + tools="$tools $dep" + status="(not installed)" + fi + + echo " $status" + done + + if [[ "$tools" != "" ]]; then + # don't put quotes around $tools! + # shellcheck disable=SC2086 + brew install $tools + else + echo "All requirements already met. Nothing to install" + fi + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + if is_command dpkg; then + echo "Detected Debian based system" + local tools + + # shellcheck disable=SC2068 + for dep in ${debian_deps[@]}; do + echo -n "detecting $dep ..." + status="(installed)" + if ! dpkg -l "$dep"; then + tools="$tools $dep" + status="(not installed)" + fi + echo " $status" + done + + cmd="apt-get" + + if is_command sudo; then + cmd="sudo $cmd" + fi + + if [[ "$tools" != "" ]]; then + $cmd update + # don't put quotes around $tools! + # shellcheck disable=SC2086 + ( + set -x + $cmd install -y $tools + ) + else + echo "All requirements already met. Nothing to install" + fi + fi + else + echo "Unsupported OS $OSTYPE" + exit 1 + fi +} + case "$1" in gotoolchain) get_gotoolchain diff --git a/tests/upgrade/upgrade_test.go b/tests/upgrade/upgrade_test.go index 8c26a3dc8..e6bf365cb 100644 --- a/tests/upgrade/upgrade_test.go +++ b/tests/upgrade/upgrade_test.go @@ -982,7 +982,7 @@ loop: _ = l.params.pub.Publish(nodePreUpgradeReady{ name: l.params.name, }) - } else if stage == nodeTestStagePostUpgrade && blocksCount == 10 { + } else if stage == nodeTestStagePostUpgrade && blocksCount >= 10 { l.t.Logf("[%s][%s]: counted 10 blocks. signaling has performed upgrade", l.params.name, nodeTestStageMapStr[stage]) l.upgradeSuccessful <- struct{}{}