Skip to content

Commit

Permalink
chore(ci): run tests on github action using docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Jul 13, 2023
1 parent cf6d5a2 commit 06c3757
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 06c3757

Please sign in to comment.