From e77dd25d7417af6c648d75eecafdabca2c154633 Mon Sep 17 00:00:00 2001 From: Raphael Aurich Date: Tue, 19 Nov 2024 10:28:17 +0100 Subject: [PATCH 1/2] feat: Add archived status check to GraphQL query --- ciplatforms/internal/github/api.go | 8 ++++++++ ciplatforms/internal/io/output.go | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ciplatforms/internal/github/api.go b/ciplatforms/internal/github/api.go index 5b1637a..3572ae0 100644 --- a/ciplatforms/internal/github/api.go +++ b/ciplatforms/internal/github/api.go @@ -25,6 +25,7 @@ type Repository struct { GitHubActions bool `json:"gh_actions"` Taskcluster bool `json:"taskcluster"` Accessible bool `json:"accessible"` + Archived bool `json:"archived"` } // Define the GraphQL query template for batch queries for multiple repos. @@ -34,6 +35,7 @@ query { repo{{ $i }}: repository(owner: "{{ $repo.Owner }}", name: "{{ $repo.Name }}") { name owner { login } + isArchived circleci: object(expression: "HEAD:.circleci/config.yml") { ... on Blob { id } } @@ -162,6 +164,12 @@ func updateRepos(batch []*Repository, data map[string]interface{}) error { return fmt.Errorf("invalid data format for alias %s (%s/%s): expected a map but got %T", alias, repo.Owner, repo.Name, repoData) } + if archived, ok := repoDataMap["isArchived"].(bool); ok { + repo.Archived = archived + } else { + log.Printf("[WARNING] 'isArchived' field missing or invalid for repository %s/%s", repo.Owner, repo.Name) + } + // Check if CircleCI configuration file is present repo.CircleCI = repoDataMap["circleci"] != nil diff --git a/ciplatforms/internal/io/output.go b/ciplatforms/internal/io/output.go index cb3cd94..3bcb277 100644 --- a/ciplatforms/internal/io/output.go +++ b/ciplatforms/internal/io/output.go @@ -38,7 +38,7 @@ func (c CSVResultWriter) WriteResults(filename string, services []github.Service defer writer.Flush() // Write header row - header := []string{"service", "repo", "circleci", "github_actions", "taskcluster", "accessible"} + header := []string{"service", "repo", "circleci", "github_actions", "taskcluster", "accessible", "archived"} if err := writer.Write(header); err != nil { return fmt.Errorf("error writing header to CSV file: %w", err) } @@ -52,6 +52,7 @@ func (c CSVResultWriter) WriteResults(filename string, services []github.Service fmt.Sprintf("%t", service.Repository.GitHubActions), fmt.Sprintf("%t", service.Repository.Taskcluster), fmt.Sprintf("%t", service.Repository.Accessible), + fmt.Sprintf("%t", service.Repository.Archived), } if err := writer.Write(row); err != nil { return fmt.Errorf("error writing row to CSV file: %w", err) From 1ab871f8b263abfdeacc7123d6098eb9f86a177f Mon Sep 17 00:00:00 2001 From: Raphael Aurich Date: Tue, 19 Nov 2024 11:08:37 +0100 Subject: [PATCH 2/2] docs: Update README for new archived field --- ciplatforms/README.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ciplatforms/README.md b/ciplatforms/README.md index 427fb19..81df08b 100644 --- a/ciplatforms/README.md +++ b/ciplatforms/README.md @@ -99,6 +99,7 @@ service,repository monitor,mozilla/blurts-server autoconnect,mozilla-services/autopush-rs autoendpoint,mozilla-services/autopush-rs +contile,mozilla-services/contile ``` Example JSON output format (`services_ciplatforms.json`): @@ -111,7 +112,8 @@ Example JSON output format (`services_ciplatforms.json`): "circle_ci": false, "gh_actions": true, "taskcluster": false, - "accessible": true + "accessible": true, + "archived": false }, { "service": "autoconnect", @@ -119,7 +121,8 @@ Example JSON output format (`services_ciplatforms.json`): "circle_ci": true, "gh_actions": true, "taskcluster": false, - "accessible": true + "accessible": true, + "archived": false }, { "service": "autoendpoint", @@ -127,16 +130,26 @@ Example JSON output format (`services_ciplatforms.json`): "circle_ci": true, "gh_actions": true, "taskcluster": false, - "accessible": true + "accessible": true, + "archived": false + }, + { + "service": "contile", + "repository": "mozilla-services/contile", + "circle_ci": true, + "gh_actions": false, + "taskcluster": false, + "accessible": true, + "archived": true } ] ``` This output provides details about the CI platform configuration status of each repository, including its accessibility (a repository may be inaccessible if it -does not exist or if the provided authentication token lacks access), and flags -indicating the presence of CircleCI, GitHub Actions, and Taskcluster -configuration files. +does not exist or if the provided authentication token lacks access), whether it +has been archived, and flags indicating the presence of CircleCI, GitHub +Actions, and Taskcluster configuration files. ## Docker