diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 4cb0ab29..c44ab11d 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -41,12 +41,19 @@ jobs: run: npm clean-install - name: Lint code run: npm run lint - unittest: - name: Run unit tests + test: + name: Run tests runs-on: ubuntu-latest + env: + MSSQL_USER: 'sa' + MSSQL_PASSWORD: 'yourStrong(!)Password' + MSSQL_SERVER: 'localhost' + MSSQL_PORT: '1433' + MSSQL_DATABASE: 'master' strategy: matrix: node-version: [14.x, 16.x, 18.x, 20.x] + sql-version: [2017, 2019, 2022] steps: - name: Checkout code uses: actions/checkout@v3 @@ -61,3 +68,24 @@ jobs: run: npm clean-install - name: Run unit tests run: npm run test-unit + - name: Start docker container + run: docker run --name mssql -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_PASSWORD" -p 1433:1433 -d mcr.microsoft.com/mssql/server:${{ matrix.sql-version }}-latest + - name: Store test config + run: echo "{\"user\":\"$MSSQL_USER\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"$MSSQL_SERVER\",\"port\":$MSSQL_PORT,\"database\":\"$MSSQL_DATABASE\"}" > ./test/.mssql.json + - name: Wait for database to be ready + run: | + set +e + ATTEMPT=0 + while [ $ATTEMPT -le 10 ]; do + ATTEMPT=$(( ATTEMPT + 1 )) + docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U "$MSSQL_USER" -P "$MSSQL_PASSWORD" -q 'SELECT 1;' + if [ $? -eq 0 ]; then + break + fi + sleep 1 + done + - name: Run tedious tests + run: npm run test-tedious + - name: Stop container + if: ${{ always() }} + run: docker rm -f -v mssql