Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,50 @@ on:

jobs:
deploy:
if: (github.event == "pull_request" && github.event.pull_request.head.repo == github.repository.full_name) || (github.event == "pull_request_target" && github.event.pull_request.head.repo != github.repository.full_name)
if: (github.event == 'pull_request' && github.event.pull_request.head.repo == github.repository.full_name) || (github.event == 'pull_request_target' && github.event.pull_request.head.repo != github.repository.full_name)
environment: Automation test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
env:
TEST_DB: 'SqlActionTest-${{ matrix.os }}'

steps:
- name: Checkout from PR branch
- name: Checkout from PR branch
uses: actions/checkout@v2
with:
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Installing node_modules
run: |
npm install

run: npm install

- name: Build GitHub Action
run: npm run build

- uses: azure/login@v1
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: ./

# Deploy a DACPAC with only a table to server
- name: Test DACPAC Action
uses: ./
with:
server-name: sql-action.database.windows.net
connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }}
sql-file: ./testsql.sql

connection-string: '${{ secrets.AZURE_SQL_CONNECTION_STRING_NO_DATABASE }}Initial Catalog=${{ env.TEST_DB }};'
dacpac-package: ./__testdata__/sql-action.dacpac

# Execute testsql.sql via SQLCMD on server
- name: Test SQL Action
uses: ./
with:
connection-string: '${{ secrets.AZURE_SQL_CONNECTION_STRING_NO_DATABASE }}Initial Catalog=${{ env.TEST_DB }};'
sql-file: ./__testdata__/testsql.sql

- name: Cleanup Test Database
uses: ./
with:
connection-string: '${{ secrets.AZURE_SQL_CONNECTION_STRING_NO_DATABASE }}Initial Catalog=master;'
sql-file: ./__testdata__/cleanup.sql
arguments: '-v DbName="${{ env.TEST_DB }}"'
2 changes: 2 additions & 0 deletions __testdata__/cleanup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This script is used by pr-check.yml to cleanup test database after each run, DbName will be set at runtime
DROP DATABASE [$(DbName)];
Binary file added __testdata__/sql-action.dacpac
Binary file not shown.
4 changes: 4 additions & 0 deletions __testdata__/testsql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This script is used by pr-check.yml to test the SQLCMD action

-- This should successfully insert data into the table created in the DACPAC step
INSERT INTO [Table1] VALUES(1, 'test');
3 changes: 0 additions & 3 deletions testsql.sql

This file was deleted.