#! /usr/bin/env bash

set -e

# Get the repo dir
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
cd $REPO_DIR

echo "🧪 Testing with rspec and linting with rubocop"

if [ ! -f "/.github-full-larger-runner" ]; then
    WORKSPACE=$REPO_DIR
    touch -r ${WORKSPACE}/Dockerfile ${WORKSPACE}/apt-auth-conf ${WORKSPACE}/pkg-mirror-host
    trap 'rm -f "${WORKSPACE}/apt-auth-conf ${WORKSPACE}/pkg-mirror-host"' EXIT
fi


docker build --secret id=apt-auth-conf,src=${WORKSPACE}/apt-auth-conf --secret id=pkg-mirror-host,src=${WORKSPACE}/pkg-mirror-host -t github/octosecrets .


docker run github/octosecrets bash -c "script/test"
