{"id":1586,"date":"2022-12-05T06:00:08","date_gmt":"2022-12-05T14:00:08","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=1586"},"modified":"2022-12-02T08:30:58","modified_gmt":"2022-12-02T16:30:58","slug":"connecting-the-dots-of-azure-sql-cicd-part-3-testing-with-tsqlt","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/connecting-the-dots-of-azure-sql-cicd-part-3-testing-with-tsqlt\/","title":{"rendered":"Connecting the Dots of Azure SQL CICD Part 3: Testing with tSQLt"},"content":{"rendered":"<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-1643 size-large\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1-1024x327.png\" alt=\"Image header picture\" width=\"640\" height=\"204\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1-1024x327.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1-300x96.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1-768x245.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1-1536x490.png 1536w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/header_picture-1.png 1781w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>In part 3 of our Azure SQL database change management (CICD) series we cover testing your code using tSQLt and GitHub Actions.<\/p>\n<h4>Prerequisites Check<\/h4>\n<p>Refer to <a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/connecting-the-dots-of-azure-sql-cicd-part-1-getting-started\/\">part 1<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/azure-sql-database-change-management\/\">part 2<\/a> for the prerequisites.<\/p>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/devops\/develop\/git\/install-and-set-up-git\" target=\"_blank\" rel=\"noreferrer noopener\" data-type=\"URL\" data-id=\"https:\/\/learn.microsoft.com\/en-us\/devops\/develop\/git\/install-and-set-up-git\">git<\/a><\/li>\n<li>A\u00a0<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>\u00a0account<\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/Download\" target=\"_blank\" rel=\"noreferrer noopener\">Visual Studio Code<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/engine\/install\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker<\/a><\/li>\n<li><a href=\"https:\/\/dotnet.microsoft.com\/en-us\/download\/dotnet\/3.1\">.NET Core SDK<\/a><\/li>\n<\/ul>\n<h2>Fork the GitHub Project<\/h2>\n<p>We will be using <a href=\"https:\/\/tsqlt.org\/\">tSQLt<\/a> in this post, so I have created a GitHub project made up of several SQL Database Projects for Visual Studio Code. In these database projects are the tSQLt samples installed and ready to go. This post will focus more on the process of setting up a testing pipeline but if you are curious, you can read about the<a href=\"https:\/\/tsqlt.org\/user-guide\/quick-start\/\"> tSQLt samples\/quickstart here<\/a>, or just read up on how amazing tSQLt is <a href=\"https:\/\/tsqlt.org\/\">here<\/a>.<\/p>\n<p>Start by going to:<\/p>\n<p><a href=\"https:\/\/github.com\/JetterMcTedder\/AzureSQLDevOpsDemo\">https:\/\/github.com\/JetterMcTedder\/AzureSQLDevOpsDemo<\/a><\/p>\n<p>and in the upper right corner of the page, click on <strong>Fork<\/strong>. Then, click<strong> + Create a new fork<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork1-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-1619 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork1-1.png\" alt=\"Image fork1\" width=\"545\" height=\"172\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork1-1.png 545w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork1-1-300x95.png 300w\" sizes=\"(max-width: 545px) 100vw, 545px\" \/><\/a><\/p>\n<p>The project will now be in your account as a new repository. You can now clone it locally.<\/p>\n<p>Get the clone URL on the repository homepage. Just click the green <strong>&lt;&gt; Code button.<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1620\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork2.png\" alt=\"Image fork2\" width=\"420\" height=\"389\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork2.png 420w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/fork2-300x278.png 300w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/a><\/p>\n<p><div class=\"alert alert-info\">YOUR_ACCOUNT_NAME_HERE is a placeholder for well, your account name. Mine is JetterMcTedder. Don&#8217;t use my account name because you will not be able to use GitHub actions later in the post, which is honestly the whole point of this post!<\/div><\/p>\n<p>Next, using a terminal\/Powershell prompt\/etc, run the following git command:<\/p>\n<p><code>git clone https:\/\/github.com\/YOUR_ACCOUNT_NAME_HERE\/AzureSQLDevOpsDemo<\/code><\/p>\n<p>This will create the AzureSQLDevOpsDemo folder with the SQL Database Projects inside on your local machine.<\/p>\n<h2>The TestsSQLServer Project<\/h2>\n<p>Inside the <strong>AzureSQLDevOpsDemo\/TestsSQLServer<\/strong> directory is the <strong>TestsSQLServer.sqlproj<\/strong> file. This is the starting point for our pipeline testing journey.<\/p>\n<p>Open this file in Visual Studio Code by 1) being on the SQL Database Projects extension and 2) clicking on the <strong>open folder icon<\/strong> or the <strong>Open Existing button<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1598\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project2.png\" alt=\"Image code project2\" width=\"356\" height=\"318\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project2.png 356w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project2-300x268.png 300w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/a><\/p>\n<p>Find the project in the AzureSQLDevOpsDemo\/TestsSQLServer directory<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project3b.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1604\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project3b.png\" alt=\"Image code project3b\" width=\"817\" height=\"316\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project3b.png 817w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project3b-300x116.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project3b-768x297.png 768w\" sizes=\"(max-width: 817px) 100vw, 817px\" \/><\/a><\/p>\n<p>and then you should see it in SQL Database Projects<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1605\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b.png\" alt=\"Image code project4b\" width=\"312\" height=\"318\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b.png 312w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b-294x300.png 294w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b-24x24.png 24w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project4b-48x48.png 48w\" sizes=\"(max-width: 312px) 100vw, 312px\" \/><\/a><\/p>\n<p>Next, <strong>right click<\/strong> the TestsSQLServer project and select <strong>Publish<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project5.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1606\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project5.png\" alt=\"Image code project5\" width=\"440\" height=\"320\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project5.png 440w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project5-300x218.png 300w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/a><\/p>\n<p>This will publish not only the tSQLt needed items to our local SQL Server instance in Docker, but also the reference to the Code SQL Database Project which has all the sample code supplied by the tSQLt quickstart (tables and procedures).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project6.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1607\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project6.png\" alt=\"Image code project6\" width=\"445\" height=\"89\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project6.png 445w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project6-300x60.png 300w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/a><\/p>\n<p>You can refer back to <a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/azure-sql-database-change-management\/\">Part 2<\/a> on setting up Docker for a local SQL Server 2022 instance.<\/p>\n<p>Once the project is deployed to the local instance<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project7.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1609\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project7.png\" alt=\"Image code project7\" width=\"446\" height=\"39\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project7.png 446w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project7-300x26.png 300w\" sizes=\"(max-width: 446px) 100vw, 446px\" \/><\/a><\/p>\n<p>you can browse the tables it has created in the local instance<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project8.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1610\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project8.png\" alt=\"Image code project8\" width=\"258\" height=\"439\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project8.png 258w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project8-176x300.png 176w\" sizes=\"(max-width: 258px) 100vw, 258px\" \/><\/a><\/p>\n<p>Testing the Test<\/p>\n<p>Open a new Query Window for our local SQL connection by right clicking on the localhost server name in the SQL Server connections tab.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project9.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1611\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project9.png\" alt=\"Image code project9\" width=\"414\" height=\"318\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project9.png 414w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project9-300x230.png 300w\" sizes=\"(max-width: 414px) 100vw, 414px\" \/><\/a><\/p>\n<p>In the project is a script called runDemoTests_VSC-ADS.sql in the myTests folder. In that script is the following command:<\/p>\n<div>\n<div><code>EXEC tSQLt.Run 'testFinancialApp';<\/code><\/div>\n<\/div>\n<div><span style=\"font-size: 1rem\">\u00a0<\/span><\/div>\n<div><span style=\"font-size: 1rem\">\nYou can open the script or just copy the command here and run it in the <\/span><strong style=\"font-size: 1rem\">New Query window<\/strong><span style=\"font-size: 1rem\">.<\/span><\/div>\n<div>\n<div><\/div>\n<\/div>\n<div><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project10.2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1614\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project10.2.png\" alt=\"Image code project10 2\" width=\"806\" height=\"311\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project10.2.png 806w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project10.2-300x116.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/code_project10.2-768x296.png 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/a><\/div>\n<div><\/div>\n<div>This ran through the pre-created tSQLt tests and returns the results. As you create the code for your SQL database, you will also create tests in tSQLt. And seeing you never want to install tSQLt into a production instance, being able to use Docker to bring up and use SQL Databases in seconds is key to having a good testing pipeline.<\/div>\n<div><\/div>\n<h2>Automated Testing with GitHub Actions<\/h2>\n<div>OK, so we can test locally all day and ensure we are checking in quality code. But what about the famous line &#8220;Well, it worked on my computer&#8221;? Using GitHub Actions, we can create a workflow that when someone checks in their code, we create a SQL Server instance in docker, deploy the SQL Database Project, run through the tSQLt test, and report back the results. Sounds like a lot of work but thanks to <a href=\"https:\/\/docs.github.com\/en\/actions\">GitHub actions<\/a> and <a href=\"https:\/\/github.com\/Azure\/sql-action\">SQL Actions<\/a>, it&#8217;s a single file that we will provide for you right now!<\/div>\n<div><\/div>\n<div>Start by taking a look in the <strong>AzureSQLDevOpsDemo\/.github\/workflows<\/strong><strong>\u00a0folder<\/strong>. There is a file called <strong>sql_test_container.yml<\/strong>.\u00a0 Let&#8217;s break this file down now.<\/div>\n<div><\/div>\n<div>We start with the Name and<a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/events-that-trigger-workflows\"> when to trigger the workflow<\/a>. For our example, we will be using <a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/events-that-trigger-workflows#workflow_dispatch\">workflow_dispatch<\/a> which allows us to manually trigger it.<\/div>\n<div><\/div>\n<div>\n<pre>name: SQL Server container in tSQLt testing pipeline\r\non:\r\n  # push:\r\n  #   branches:\r\n  #     - main\r\n  workflow_dispatch:<\/pre>\n<\/div>\n<div>The next section is the build and deploy under jobs:<\/div>\n<div>\n<pre>jobs:\r\n  build-and-deploy:\r\n    # Containers must run in Linux based operating systems\r\n    runs-on: ubuntu-latest\r\n\r\n    # service\/sidecar container for azure-sql-2022\r\n    services:\r\n      mssql:\r\n        image: mcr.microsoft.com\/mssql\/server:2022-latest\r\n        env:\r\n          ACCEPT_EULA: 1\r\n          SA_PASSWORD: P@ssw0rd\r\n        ports:\r\n          - 1433:1433<\/pre>\n<p>Here we give the information for the docker container we want to create. In out example, we are creating the latest version of SQL Server 2022 that is available from the <a href=\"https:\/\/mcr.microsoft.com\/en-us\/product\/mssql\/server\/about\">Microsoft Artifact Registry<\/a>.<\/p>\n<\/div>\n<div><\/div>\n<div>After the container is created, we have what steps we want to perform in the workflow. To start, we check if the container is up and running and accepting SQL connections via sqlcmd:<\/div>\n<div>\n<pre>    steps:\r\n      - name: 'Checkout GitHub Action'\r\n        uses: actions\/checkout@v2\r\n\r\n      - name: 'wait for sql to be ready'\r\n        run: |\r\n          set +o pipefail +e\r\n          for i in {1..60};\r\n          do\r\n              sqlcmd -S localhost -U sa -P P@ssw0rd -d master -Q \"select getdate()\"\r\n              if [ $? -eq 0 ]\r\n              then\r\n                  echo \"sql server ready\"\r\n                  break\r\n              else\r\n                  echo \"not ready yet...\"\r\n                  sleep 1\r\n              fi\r\n          done\r\n          set -o pipefail -e<\/pre>\n<\/div>\n<div>Once we can connect, we can start deploying our SQL Database Projects:<\/div>\n<div>\n<pre>      - name: 'Create and setup database'\r\n        uses: azure\/sql-action@v2\r\n        with:\r\n          connection-string: \"Server=localhost;Initial Catalog=master;User ID=sa;Password=P@ssw0rd;Encrypt=False;TrustServerCertificate=False;\"  # the local connection string\r\n          path: '.\/setups\/setupDatabase.sql' # the sql script to create db and configure for clr\r\n\r\n      - name: 'Deploy Projects'\r\n        uses: azure\/sql-action@v2\r\n        with:\r\n          connection-string: \"Server=localhost;Initial Catalog=testingDB;User ID=sa;Password=P@ssw0rd;Encrypt=False;TrustServerCertificate=False;\"  # the local connection string\r\n          path: '.\/TestsSQLServer\/TestsSQLServer.sqlproj' # the SQLproj file\r\n          action: 'Publish'\r\n          arguments: '\/p:IncludeCompositeObjects=True'<\/pre>\n<\/div>\n<div>And the last step is to run the tSQLt tests:<\/div>\n<div>\n<pre>      - name: 'Run tSQLt tests'\r\n        uses: azure\/sql-action@v2\r\n        with:\r\n          connection-string: \"Server=localhost;Initial Catalog=testingDB;User ID=sa;Password=P@ssw0rd;\"  # the local connection string\r\n          path: '.\/TestsSQLServer\/myTests\/demoExecAzureSQL.sql' # the tsqlt test command<\/pre>\n<p>We can test this ourselves using GitHub actions in our account.<\/p>\n<h2>Running the Workflow<\/h2>\n<p>Back in the project you forked, look across the top for the <strong>Actions<\/strong> tab. Click the Actions tab.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1624\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action1.png\" alt=\"Image action1\" width=\"965\" height=\"187\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action1.png 965w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action1-300x58.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action1-768x149.png 768w\" sizes=\"(max-width: 965px) 100vw, 965px\" \/><\/a><\/p>\n<p>In the Actions page, on the left-hand side, <strong>click our workflow<\/strong> &#8220;SQL Server container in tSQLt testing pipeline&#8221;.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action2-1.png\"><img decoding=\"async\" class=\"alignnone wp-image-1629 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action2-1.png\" alt=\"Image action2\" width=\"336\" height=\"241\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action2-1.png 336w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action2-1-300x215.png 300w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/a><\/p>\n<p>Then, click the Run Workflow button to see the dropdown, then click the green Run Workflow button.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1630\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3.png\" alt=\"Image action3\" width=\"1131\" height=\"513\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3.png 1131w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3-300x136.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3-1024x464.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action3-768x348.png 768w\" sizes=\"(max-width: 1131px) 100vw, 1131px\" \/><\/a><\/p>\n<p>Once the page refreshes with the running workflow, click it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1631\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action4.png\" alt=\"Image action4\" width=\"718\" height=\"231\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action4.png 718w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action4-300x97.png 300w\" sizes=\"(max-width: 718px) 100vw, 718px\" \/><\/a><\/p>\n<p>next, click on <strong>build-and-deploy<\/strong> to watch the details of the progress of the workflow.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1632\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5.png\" alt=\"Image action5\" width=\"1060\" height=\"266\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5.png 1060w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5-300x75.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5-1024x257.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action5-768x193.png 768w\" sizes=\"(max-width: 1060px) 100vw, 1060px\" \/><\/a><\/p>\n<p>And with a successful run, we can see the tSQLt test completed without error.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1633\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6.png\" alt=\"Image action6\" width=\"1380\" height=\"1018\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6.png 1380w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6-300x221.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6-1024x755.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/12\/action6-768x567.png 768w\" sizes=\"(max-width: 1380px) 100vw, 1380px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>You can see how <a href=\"https:\/\/docs.github.com\/en\/actions\">GitHub actions<\/a> can help you test code on your projects by simulating a deployment and running regression tests via <a href=\"https:\/\/tsqlt.org\/\">tSQLt<\/a> providing more stable and error free release.<\/p>\n<p>I also cannot stress to you enough that everything we did in these three blog posts are 100% free. There is no charge for using SQL Server in developer mode on Docker or via GitHub actions (<a href=\"https:\/\/github.com\/pricing\">2000 free CICD minutes that include GitHub actions, and our test took 1m 23s<\/a>). Visual Studio Code is free and used by millions of people around the world as well.<\/p>\n<p>So, what do you think? Is this something you can see incorporating into your CICD pipelines for database change management? Let us know in the comments section or feel free to reach out to us directly!<\/p>\n<p><b>Special thanks to <\/b><a style=\"font-weight: bold\" href=\"https:\/\/www.linkedin.com\/in\/drew-skwiers-koballa\">Drew Skwiers-Koballa<\/a><b> and <\/b><a style=\"font-weight: bold\" href=\"https:\/\/www.linkedin.com\/in\/lizbaron\/\">Liz Baron<\/a><b> for their help and guidance on writing this post.<\/b><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In part 3 of our Azure SQL database change management (CICD) series we cover testing your code using tSQLt and GitHub Actions. Prerequisites Check Refer to part 1 and part 2 for the prerequisites. git A\u00a0GitHub\u00a0account Visual Studio Code Docker .NET Core SDK Fork the GitHub Project We will be using tSQLt in this post, [&hellip;]<\/p>\n","protected":false},"author":95874,"featured_media":1643,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[532,1,484,92,546,545,533],"tags":[443,510,469,448,548,30,449,93,94,549,34,547,485,530],"class_list":["post-1586","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-data-studio","category-azure-sql","category-containers","category-devops","category-github","category-unit-testing","category-visual-studio-code","tag-automation","tag-azure-sql-database","tag-azuresqldb","tag-ci-cd","tag-containers","tag-developers","tag-development","tag-devops","tag-github","tag-github-actions","tag-t-sql","tag-tsqlt","tag-unit-testing","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>In part 3 of our Azure SQL database change management (CICD) series we cover testing your code using tSQLt and GitHub Actions. Prerequisites Check Refer to part 1 and part 2 for the prerequisites. git A\u00a0GitHub\u00a0account Visual Studio Code Docker .NET Core SDK Fork the GitHub Project We will be using tSQLt in this post, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/95874"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=1586"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1586\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/1643"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}