mirror of
				https://github.com/avelino/awesome-go.git
				synced 2025-10-30 23:17:40 -04:00 
			
		
		
		
	run stale repo check as test instead (#4265)
This commit is contained in:
		
							parent
							
								
									462dbbb9e7
								
							
						
					
					
						commit
						1fd356d91f
					
				
					 3 changed files with 7 additions and 9 deletions
				
			
		
							
								
								
									
										2
									
								
								.github/workflows/run-check.yaml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/run-check.yaml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -13,6 +13,6 @@ jobs:
 | 
			
		|||
    - name: Get dependencies
 | 
			
		||||
      run: go get -v -t -d ./...
 | 
			
		||||
    - name: run script
 | 
			
		||||
      run: go run test_stale_repositories.go scripts.go
 | 
			
		||||
      run: go test stale_repositories_test.go scripts.go
 | 
			
		||||
      env:
 | 
			
		||||
        OAUTH_TOKEN: ${{secrets.OAUTH_TOKEN}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
tmpl/index.html
 | 
			
		||||
awesome-go
 | 
			
		||||
vendor
 | 
			
		||||
 | 
			
		||||
# Folders
 | 
			
		||||
.idea
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ package main
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +10,7 @@ import (
 | 
			
		|||
	"os"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
	"text/template"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,8 +38,6 @@ const movedPermanently = " status code 301 received"
 | 
			
		|||
const status302 = " status code 302 received"
 | 
			
		||||
const archived = " repository has been archived"
 | 
			
		||||
 | 
			
		||||
var delay time.Duration = 1
 | 
			
		||||
 | 
			
		||||
//LIMIT specifies the max number of repositories that are added in a single run of the script
 | 
			
		||||
var LIMIT = 10
 | 
			
		||||
var ctr = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -140,10 +140,7 @@ func getAllFlaggedRepositories(client *http.Client, flaggedRepositories *map[str
 | 
			
		|||
}
 | 
			
		||||
func containsOpenIssue(link string, openIssues map[string]bool) bool {
 | 
			
		||||
	_, ok := openIssues[link]
 | 
			
		||||
	if ok {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
	return ok
 | 
			
		||||
}
 | 
			
		||||
func testRepoState(toRun bool, href string, client *http.Client, staleRepos *[]string) bool {
 | 
			
		||||
	if toRun {
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +229,7 @@ func testStaleRepository() {
 | 
			
		|||
		tokenSource := &tokenSource{
 | 
			
		||||
			AccessToken: oauth,
 | 
			
		||||
		}
 | 
			
		||||
		client = oauth2.NewClient(oauth2.NoContext, tokenSource)
 | 
			
		||||
		client = oauth2.NewClient(context.Background(), tokenSource)
 | 
			
		||||
	}
 | 
			
		||||
	err := getAllFlaggedRepositories(client, &addressedRepositories)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -270,6 +267,6 @@ func testStaleRepository() {
 | 
			
		|||
	createIssue(staleRepos, client)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
func TestStaleRepository(t *testing.T) {
 | 
			
		||||
	testStaleRepository()
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue