Files
unleash/scripts/docker-postgres.sh
T
Christopher Kolstad 78eb6ad911 task: migrate to pnpm (#11898)
Things worth noticing (+14075, -20262 most of this is due to yarn.lock
being deleted, and a new package manager tool being checked in)

## Code changes (actual changes to ts files)
### Not interesting
- being explicit about test imports in frontend rather than using
tsconfig globals to resolve `describe`, `it`, `test`, `expect` et al.
### Interesting
- Type signatures resolutions have changed a slightly bit, so some of
our Knex queries needed to be extracted for tsc to manage to type
analyse and pass type checking. All tests are green, so I'm assuming I
managed to reproduce the behaviour, in particular
src/lib/features/project/project-read-model.ts has some extra variables
to pass typechecking.


### Other considerations
- Do we still build the way we did? (pnpm pack produces the same
files/artifact as yarn pack)
- Will this merge cleanly with enterprise (which runs prepack)?

#### Known unknowns
- I've changed our vite.config.mts in frontend to use vite's own built
in tsconfigpaths, but Thomas pointed out that he tried that already and
ran into some issue when enterprise used the dependency, so we'll need
to double check that it works, and be ready to rollback to using the
deprecated plugin (and accept that vite gives us a warning that this is
now native functionality).

### Build failures
- Expected is openapi validation on main, we've changed to using pnpm
action rather than yarn action so it won't recognize yarn as a
packageManager on main
- dependency scanner, due to how pnpm resolves dependencies, we now have
a more direct dependencies, which our scanner apparently is scoring too
low for it to be OK with them. These were already a dependency, just
transitively rather than direct, so I'm comfortable with this.
2026-05-06 12:17:17 +02:00

76 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -e
export POSTGRES_PASSWORD="uleash"
function getDockerDBPort() {
case "$OSTYPE" in
darwin*) echo `docker ps| grep unleash-post| awk '{print $(NF-1)}'| awk -F "->" '{print $1}'| awk -F \: '{print $4}'`;;
# solaris*) echo "SOLARIS" ;;
# linux*) echo "LINUX" ;;
# bsd*) echo "BSD" ;;
# msys*) echo "WINDOWS" ;;
# cygwin*) echo "ALSO WINDOWS" ;;
*) echo `docker ps| grep unleash-post| awk '{print $(NF-1)}'| awk -F "->" '{print $1}'| awk -F \: '{print $2}'`;;
esac
}
if docker ps | grep unleash-postgres > /dev/null; then
echo "unleash-postgress is already running"
else
echo "starting postgres in docker "
HASH=`docker run -P --name unleash-postgres -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -d postgres:10`
fi
export PGPORT=$(getDockerDBPort)
if [ -z "$PGPORT" ]; then
echo "could not find PGPORT! is postgres running?"
exit 1
fi
echo "PGPORT: $PGPORT"
echo ""
echo "Waiting for postgres to start..."
function isPostgresAvailable() {
echo "polling $1:$2"
case "$OSTYPE" in
darwin*) nc -z $1 $2;;
# solaris*) echo "SOLARIS" ;;
# linux*) echo "LINUX" ;;
# bsd*) echo "BSD" ;;
# msys*) echo "WINDOWS" ;;
# cygwin*) echo "ALSO WINDOWS" ;;
*) netcat -z $1 $2;;
esac
}
if [ -z "$DOCKER_HOST" ]
then
export database_host="127.0.0.1"
else
export database_host=$(echo $DOCKER_HOST |awk -F \/ '{print $NF}'| awk -F \: '{print $1}')
fi
export TEST_DATABASE_URL=postgres://postgres:$POSTGRES_PASSWORD@$database_host:$PGPORT/postgres
for i in `seq 1 120`;
do
# echo -n "."
sleep 1
isPostgresAvailable $database_host $PGPORT && echo "postgres is up and running in docker in $i seconds!" && break
done
echo "running migrations..."
DATABASE_URL=$TEST_DATABASE_URL npm run db-migrate -- up
echo "running tests..."
pnpm test
echo "cleanup..."
docker stop $HASH
docker rm $HASH
echo "done"