Skip to content

Instantly share code, notes, and snippets.

@Bogdanp
Created July 10, 2019 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bogdanp/4278bcd67402d2c40a84099fb5357be9 to your computer and use it in GitHub Desktop.
Save Bogdanp/4278bcd67402d2c40a84099fb5357be9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
log() {
printf "[%s] %s\n" "$(date)" "$@"
}
log "Installing postgres..."
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update -y && apt-get install -y --no-install-recommends postgresql-11
echo "local all postgres peer" > /etc/postgresql/11/main/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/11/main/pg_hba.conf
service postgresql start
log "Setting up postgres user and db..."
echo "create user matchacha with password 'matchacha' login" | psql -Upostgres -h127.0.0.1
echo "create database matchacha_tests" | psql -Upostgres -h127.0.0.1
echo "grant all privileges on database matchacha_tests to matchacha" | psql -Upostgres -h127.0.0.1
log "Downloading libargon2..."
pushd /tmp
wget https://github.com/P-H-C/phc-winner-argon2/archive/20171227.tar.gz
tar xzf 20171227.tar.gz
log "Installing libargon2..."
pushd phc-winner-argon2-20171227
make && make install
popd && popd
log "Checking out workspace..."
pushd "$GITHUB_WORKSPACE"
log "Creating static folder..."
mkdir -p static
log "Installing app and its dependencies..."
raco pkg install --batch --auto matchacha/ matchacha-tests/
log "Running raco setup on the app..."
raco setup --tidy --check-pkg-deps --unused-pkg-deps matchacha tests/matchacha
log "Migrating database..."
raco north migrate -uf postgres://matchacha:matchacha@127.0.0.1:5432/matchacha_tests
log "Testing app..."
# shellcheck disable=SC2046
env $(xargs < .env.default) raco test -j 8 matchacha-tests/ || \
("$GITHUB_WORKSPACE"/.github/actions/notify.sh "Version '$GITHUB_SHA' tests failed."; exit 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment