saturdaymp / Migrator

Migrate database changes.
https://saturdaymp.com
MIT License
1 stars 0 forks source link

Sweep: Create GitHub Action to compile and run the unit tests #7

Closed mrbiggred closed 1 week ago

mrbiggred commented 5 months ago

The GitHub Action should compile Migrator and run all the unit tests. The tests require a SQL Server 2022 database. You can find the connection string in the app.config. in the MigratorTests project.

sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #8

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Relevant files (click to expand). Mentioned files will always appear here. https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/MigratorTests/App.config#L1-L76 https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/Migrator/Migrator.csproj#L1-L270 https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/MigratorConsoleLib/MigratorEngine.cs#L1-L97 https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/MigratorGUI/MigrationForm.Designer.cs#L1-L299 https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/MigratorGUI/App.config#L1-L82 https://github.com/saturdaymp/Migrator/blob/e34049d7e53bd1f98789c5a8b4e9cd5e0a8948e2/Source/Migrator/App.config#L1-L72

Step 2: ⌨️ Coding

.github/workflows/build-and-test.yml

Let's create the `.github/workflows` directory structure and add the `build-and-test.yml` file: 1. Open your terminal or command prompt and navigate to the root directory of your repository. 2. Run the following command to create the `.github` directory (if it doesn't already exist): ``` mkdir .github ``` 3. Navigate into the `.github` directory: ``` cd .github ``` 4. Create the `workflows` directory inside `.github`: ``` mkdir workflows ``` 5. Navigate into the `workflows` directory: ``` cd workflows ``` 6. Create a new file named `build-and-test.yml` inside the `.github/workflows` directory: ``` touch build-and-test.yml ``` (If you're using Windows, you can use `type nul > build-and-test.yml` instead) 7. Open the `build-and-test.yml` file in your preferred text editor and add the following content:
name: Build and Test

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:

  build-and-test:
    runs-on: windows-latest

    services:
      sqlserver:
        image: mcr.microsoft.com/mssql/server:2022-latest
        env:
          ACCEPT_EULA: Y
          SA_PASSWORD: ${{ secrets.SA_PASSWORD }}
        ports:
          - 1433:1433
        options: --name=sql1 --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3

    steps:
    - uses: actions/checkout@v3

    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release --no-restore

    - name: Test
      env:
        ConnectionStrings__Master: Server=localhost;Database=Master;User Id=sa;Password=${{ secrets.SA_PASSWORD }};TrustServerCertificate=True;
      run: dotnet test --no-build --verbosity normal

Source/MigratorTests/App.config

1.
--- 
+++ 
@@ -1,3 +1,3 @@
   <connectionStrings>
-    <add name="Master" connectionString="Server=localhost;Database=Master;Uid=sa;Pwd=password1234!;TrustServerCertificate=True;" />
+    <add name="Master" connectionString="Server=localhost;Database=Master;User Id=sa;Password=password1234!;TrustServerCertificate=True;" />
   </connectionStrings>

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/create_github_action_to_compile_and_run. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.