-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Bump alpine to 3.21 * chore: Remove go patch version from go.mod * refactor: Scripts * chore: Remove go patch version form go mod * docs: Update readme
- Loading branch information
1 parent
5372434
commit 47bc437
Showing
57 changed files
with
500 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,97 @@ | ||
#!/bin/bash | ||
|
||
# Enable strict error handling | ||
set -eu | ||
|
||
# Script metadata | ||
SCRIPT_NAME="$(basename "$0")" | ||
REPO_ROOT="$(pwd)" | ||
TOOLS_DIR="${REPO_ROOT}/tools" | ||
|
||
echo "${SCRIPT_NAME} is running... " | ||
|
||
# Change directory to TOOLS_DIR | ||
cd "${TOOLS_DIR}" || exit 1 | ||
|
||
# Function to check the status of the last executed command | ||
function check_status() { | ||
# first param is error message to print in case of error | ||
local error_message="$1" | ||
if [ $? -ne 0 ]; then | ||
if [ -n "$1" ]; then | ||
echo "$1" | ||
if [ -n "$error_message" ]; then | ||
echo "[ERROR]: $error_message" | ||
fi | ||
|
||
# Exit 255 to pass signal to xargs to abort process with code 1, in other cases xargs will complete with 0. | ||
# Exit with code 255 to signal xargs to abort the process, otherwise it will return 0 | ||
exit 255 | ||
fi | ||
} | ||
|
||
# Function to install a dependency | ||
function install_dep() { | ||
dep=$1 | ||
local dep=$1 | ||
|
||
bin_out=$GOBIN/$(echo $dep | awk 'BEGIN { FS="/" } {for (i=NF; i>0; i--) if ($i !~ /^v[0-9]/) {print $i;exit}}') | ||
# Extract the binary output path | ||
bin_out="$GOBIN/$(echo "$dep" | awk 'BEGIN { FS="/" } { for (i=NF; i>0; i--) if ($i !~ /^v[0-9]/) { print $i; exit } }')" | ||
|
||
echo "[INFO]: Going to build ${dep} - ${bin_out}" | ||
# Determine tools module | ||
tools_module="$(grep '^module ' go.mod | awk '{print $2}')" | ||
|
||
go build -mod=vendor -o "${bin_out}" "${dep}" | ||
# Extract the version of the dependency | ||
raw_version=$(go list -mod=readonly -m -f '{{if not .Indirect}}{{.Path}} {{.Version}}{{end}}' all | grep -v "^${tools_module}") | ||
version=$(echo "$raw_version" | awk '{print $2}') | ||
|
||
check_status "[FAIL]: build [${dep}] failed!" | ||
echo "[INFO]: Building ${dep}@${version} - Output: ${bin_out}" | ||
|
||
# Build the dependency | ||
go build -mod=vendor -o "${bin_out}" "${dep}" | ||
check_status "Build failed for dependency [${dep}@${version}]!" | ||
|
||
echo "[SUCCESS]: build [${dep}] finished." | ||
echo "[SUCCESS]: Successfully built [${dep}@${version}]." | ||
} | ||
|
||
# Export functions for use in subshells (xargs) | ||
export -f install_dep | ||
export -f check_status | ||
|
||
# Function to install dependencies listed in the go.mod file | ||
function install_deps() { | ||
local tools_module | ||
|
||
# Extract the tools module name | ||
tools_module="$(grep '^module ' go.mod | awk '{print $2}')" | ||
echo "[INFO]: Installing dependencies for module: ${tools_module}" | ||
|
||
echo "[INFO]: Running install_deps for ${tools_module}" | ||
|
||
# List and install dependencies using xargs for parallel execution | ||
go list -e -f '{{ join .Imports "\n" }}' -tags="tools" "${tools_module}" | | ||
xargs -n 1 -P 0 -I {} bash -c 'install_dep "$@"' _ {} | ||
xargs -n 1 -P 0 -I {} bash -c 'install_dep "$@"' _ {} | ||
} | ||
|
||
# Function to iterate over tools and install them | ||
function install_tools() { | ||
declare -a tools_list | ||
|
||
temp_file=./tools_list.txt # создаем временный файл | ||
declare -a tools_list | ||
local temp_file=./tools_list.txt | ||
|
||
touch "$temp_file" # создаем временный файл | ||
|
||
ls -d ${TOOLS_DIR}/*/ > "$temp_file" # сохраняем вывод команды в файл | ||
# Create a temporary file to store tool directories | ||
touch "$temp_file" | ||
ls -d "${TOOLS_DIR}"/*/ > "$temp_file" | ||
|
||
# Read all tool directories into an array | ||
while IFS= read -r t; do | ||
tools_list+=("$t") | ||
done < "$temp_file" # читаем файл в массив | ||
done < "$temp_file" | ||
|
||
rm "$temp_file" # удаляем временный файл | ||
# Clean up the temporary file | ||
rm "$temp_file" | ||
|
||
# Loop through each tool and install its dependencies | ||
for t in "${tools_list[@]}"; do | ||
echo "In loop - current ${t}" | ||
echo "[INFO]: Processing tool: ${t}" | ||
|
||
tool=$(basename "${t}") | ||
cd "${TOOLS_DIR}/${tool}" || exit 1 | ||
install_deps | ||
cd - || exit 1 | ||
cd - > /dev/null || exit 1 | ||
done | ||
} | ||
|
||
|
||
install_tools | ||
# Start the tool installation process | ||
install_tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module buf | ||
|
||
go 1.23.4 | ||
go 1.23 | ||
|
||
require github.com/bufbuild/buf v1.48.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module coverbadger | ||
|
||
go 1.23.1 | ||
go 1.23 | ||
|
||
require github.com/obalunenko/coverbadger v1.4.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module enumer | ||
|
||
go 1.23.1 | ||
go 1.23 | ||
|
||
require github.com/alvaroloes/enumer v1.1.2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module fiximports | ||
|
||
go 1.23.1 | ||
go 1.23 | ||
|
||
require golang.org/x/tools v0.28.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module go-enum | ||
|
||
go 1.23.1 | ||
go 1.23 | ||
|
||
require github.com/abice/go-enum v0.6.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module gocov-html | ||
|
||
go 1.23.1 | ||
go 1.23 | ||
|
||
require github.com/matm/gocov-html v1.4.0 | ||
|
||
|
Oops, something went wrong.