delvtech / hyperdrive

An automated market maker for fixed and variable yield with on-demand terms.
Apache License 2.0
33 stars 4 forks source link

`set-hyperdrivetypes-version.sh` not working in CI #1185

Open dpaiton opened 1 month ago

dpaiton commented 1 month ago

set-hyperdrivetypes-version.sh is supposed to set the python project version for hyperdrivetypes in python/hyperdrivetypes/pyproject.toml to be the same as the version specified in contracts/src/libraries/Constants.sol. It works locally, and used to work in CI, but is now failing:

/bin/sh: 17: scripts/set-hyperdrivetypes-version.sh: [[: not found
writing to python/hyperdrivetypes/pyproject.toml
/bin/sh: 20: scripts/set-hyperdrivetypes-version.sh: [[: not found
Unsupported OS: 
make[1]: Leaving directory '/home/runner/work/hyperdrive/hyperdrive'

the error had an empty string for $OSTYPE

Unsupported OS: 

Here's the script:

#!/bin/bash

echo "get hyperdrive version"

# Extract version using sed by reading from the file
HYPERDRIVE_FILE="contracts/src/libraries/Constants.sol"
VERSION=$(sed -n -E 's/.*VERSION = "v([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' "$HYPERDRIVE_FILE")

# Determine the OS using uname and convert to lowercase
OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]')

# Append the version to hyperdrivetypes
HYPERDRIVETYPES_FILE="python/hyperdrivetypes/pyproject.toml"
echo "found version: v$VERSION"
echo "writing to $HYPERDRIVETYPES_FILE"
# Check the operating system to use the correct sed syntax
if [[ "$OSTYPE" == "darwin"* ]]; then
  # e.g. macOS
  sed -i '' -E "s/^(version = \")[0-9]+\.[0-9]+\.[0-9]+(\.*[0-9]*\".*)/\1$VERSION\2/" "$HYPERDRIVETYPES_FILE"
elif [[ "$OSTYPE" == "linux"* ]]; then
  # e.g. Ubuntu
  sed -i -E "s/^(version = \")[0-9]+\.[0-9]+\.[0-9]+(\.*[0-9]*\".*)/\1$VERSION\2/" "$HYPERDRIVETYPES_FILE"
else
  echo "Unsupported OS: $OSTYPE"
  # exit 1
fi

which I guess means uname | tr '[:upper:]' '[:lower:]' failed... maybe the container doesn't have uname installed?