Просмотр исходного кода

Add a Github Action to verify shared source files are in sync (#19024)

https://github.com/dotnet/runtime/issues/1584
Chris Ross 6 лет назад
Родитель
Сommit
e4e387cd4e
2 измененных файлов с 86 добавлено и 2 удалено
  1. 2 2
      .github/CODEOWNERS
  2. 84 0
      .github/workflows/runtime-sync.yml

+ 2 - 2
.github/CODEOWNERS

@@ -19,6 +19,6 @@
 # /src/ProjectTemplates/          @ryanbrandenburg
 /src/Security/                  @tratcher @anurse
 /src/Servers/                   @tratcher @jkotalik @anurse @halter73
-/src/Shared/Http2/              @aspnet/http2
-/src/Shared/test/Shared.Tests/Http2/ @aspnet/http2
+/src/Shared/runtime/            @dotnet/http
+/src/Shared/test/Shared.Tests/runtime/ @dotnet/http
 /src/SignalR/                   @BrennanConroy @halter73 @anurse

+ 84 - 0
.github/workflows/runtime-sync.yml

@@ -0,0 +1,84 @@
+name: AspNetCore-Runtime Code Sync
+on:
+  # Test this script using on: push
+  # push
+  schedule:
+    # * is a special character in YAML so you have to quote this string
+    # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#scheduled-events-schedule
+    # Once per day at midnight PST (8 UTC)
+    - cron: '0 8 * * *'
+
+jobs:
+  compare_repos:
+    name: Compare the shared code in the AspNetCore and Runtime repos and notify if they're out of sync.
+    runs-on: windows-latest
+    steps:
+    - name: Checkout aspnetcore
+      uses: actions/[email protected]
+      with:
+        # Test this script using changes in a fork 
+        # repository: 'Tratcher/aspnetcore'
+        repository: 'dotnet/aspnetcore'
+        path: aspnetcore
+    - name: Checkout runtime
+      uses: actions/[email protected]
+      with:
+        # Test this script using changes in a fork 
+        # repository: 'Tratcher/runtime'
+        repository: 'dotnet/runtime'
+        path: runtime
+    - name: Copy
+      shell: cmd
+      working-directory: .\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\
+      env:
+        ASPNETCORE_REPO: d:\a\aspnetcore\aspnetcore\aspnetcore\
+      run: |
+        dir
+        CopyToAspNetCore.cmd
+    - name: Diff
+      shell: cmd
+      working-directory: .\aspnetcore\
+      run: |
+        mkdir ..\artifacts
+        git status > ..\artifacts\status.txt
+        git diff > ..\artifacts\diff.txt
+    - uses: actions/upload-artifact@v1
+      with:
+        name: results
+        path: artifacts
+    - name: Check and Notify
+      shell: pwsh
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      run: |
+        # Check the code is in sync
+        $changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
+        if (-not $changed) { exit }
+        # Test this script using an issue in the local forked repo
+        # $issue = 'https://api.github.com/repos/Tratcher/aspnetcore/issues/1'
+        $issue = 'https://api.github.com/repos/dotnet/aspnetcore/issues/18943'
+        # Check if tracking issue is open/closed
+        $Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
+        $result = Invoke-RestMethod -Uri $issue
+        if ($result.state -eq "closed") { 
+         $json = "{ `"state`": `"open`" }"
+         $result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
+        }
+        # Add a comment
+        $status = [IO.File]::ReadAllText("artifacts\status.txt")
+        $diff = [IO.File]::ReadAllText("artifacts\diff.txt")
+        $body = @"
+        The shared code is out of sync.
+        <details>
+          <summary>The Diff</summary>
+          
+        ``````
+        $status
+        $diff
+        ``````
+        
+        </details>
+        "@
+        $json = ConvertTo-Json -InputObject @{ 'body' = $body }
+        $issue = $issue + '/comments'
+        $result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json