Skip to content

Commit

Permalink
ci: reuse workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Oct 8, 2024
1 parent d580137 commit 3692e66
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 23 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: setup-ubuntu
on:
workflow_call:
secrets:
GITHUB_TOKEN:
required: true

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: ''
25 changes: 3 additions & 22 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
98 changes: 98 additions & 0 deletions script/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}

Expand Down

0 comments on commit 3692e66

Please sign in to comment.