Add secret validation #5
This file contains hidden or 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: Test SQL Server | ||
|
Check failure on line 1 in .github/workflows/TestSqlServer.yaml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - feature/* | ||
| - release/* | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - feature/* | ||
| - release/* | ||
| permissions: {} | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| sqlserver_version: [2025, 2022, 2019] | ||
| services: | ||
| mssql: | ||
| image: mcr.microsoft.com/mssql/server:${{ matrix.sqlserver_version }}-latest | ||
| env: | ||
| ACCEPT_EULA: "Y" | ||
| SA_PASSWORD: "${{ secrets.MSSQL_SA_PASSWORD2 }}" | ||
| ports: | ||
| - 1433:1433 | ||
| options: >- | ||
| --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q 'SELECT 1' -C" | ||
| --health-start-period=20s | ||
| --health-interval=2s | ||
| --health-retries=30 | ||
| --health-timeout=5s | ||
| steps: | ||
| # Note that the secret is required for the SQL Server service to start above, and that happens before any steps. | ||
| # We still have this step with always() (so it doesn't get skipped if the service failed to start) to help debug | ||
| # issues. | ||
| - name: Check that secrets.MSSQL_SA_PASSWORD2 exists | ||
| if: ${{ always() && secrets.MSSQL_SA_PASSWORD2 == '' }} | ||
| run: | | ||
| echo "::error::Missing secret: MSSQL_SA_PASSWORD2" | ||
| exit 1 | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Restore | ||
| run: ./restore.sh | ||
| - name: Export SQL Server connection string as an environment variable for the tests | ||
| run: echo "Test__SqlServer__DefaultConnection=Server=localhost;Database=master;User=SA;Password=${{ secrets.MSSQL_SA_PASSWORD2 }};Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true" >> "$GITHUB_ENV" | ||
| - name: Test on SQL Server | ||
| run: dotnet test test/EFCore.SqlServer.FunctionalTests | ||
| - name: Publish Test Results | ||
| uses: actions/upload-artifact@v6 | ||
| if: always() | ||
| with: | ||
| name: test-results-sqlserver-${{ matrix.sqlserver_version }} | ||
| path: artifacts/log/Debug/* | ||