This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Test | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
- name: Creating SQL server password | |
run: | | |
echo "PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 16)$(LC_ALL=C tr -dc '@^#' < /dev/urandom | head -c 1)" >> $GITHUB_ENV | |
- name: Install mssql | |
run: | | |
sudo cp ./mssql.init /etc/init.d/mssql-server | |
sudo chmod +x /etc/init.d/mssql-server | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc | |
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list)" | |
sudo apt-get update | |
sudo apt-get install -y mssql-server | |
sudo ACCEPT_EULA='Y' MSSQL_PID='Developer' MSSQL_SA_PASSWORD=${{ env.PASSWORD }} /opt/mssql/bin/mssql-conf setup || true | |
- name: Start mssql | |
run: | | |
sudo service mssql-server start | |
- name: Creating Loc Directories Expected By Dotnet Build | |
run: ./azure-pipelines/createBuildDirectories.sh | |
- name: Building Test Environment | |
run: dotnet build './test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj' | |
- name: Writing test environment config file | |
run: | | |
cat << 'EOF' > test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/SQLConnectionInstances.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<Instances> | |
<Instance VersionKey="sqlOnPrem"> | |
<DataSource>localhost</DataSource> | |
<UserId>sa</UserId> | |
<Password>${{ env.PASSWORD }}</Password> | |
</Instance> | |
</Instances> | |
EOF | |
- name: Setting Up Test Environment | |
run: | | |
cd test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig | |
dotnet run SQLConnectionInstances.xml | |
- name: Building Integration Tests | |
run: dotnet build './test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj' | |
- name: Running Integration Tests | |
run: | | |
sqlOnPrem_password=${{ env.PASSWORD }} | |
dotnet test './test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj' --logger "trx;logfilename=testResults.trx" --no-build | |
# We need to figure out how to set these environment variables | |
## AzureStorageAccountKey: '$(sqltools-backup-url-tests-storageaccountkey)' | |
## AzureStorageAccountName: '$(sqltools-backup-url-tests-storageaccountname)' | |
## AzureBlobContainerUri: '$(sqltools-backup-url-tests-blobcontaineruri)' | |
- name: Integration Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: 'Integration Test Report' | |
path: ./test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/TestResults/testResults.trx | |
reporter: dotnet-trx | |
badge-title: 'unit-tests' | |