From 7e775fde69055b96cea4e5fdff7377b89e121086 Mon Sep 17 00:00:00 2001 From: Rafael David Tinoco Date: Fri, 20 Sep 2024 16:26:13 -0300 Subject: [PATCH 1/7] chore: remove old workflows --- .github/workflows/linter.yml | 19 --------- .github/workflows/tests.yml | 76 ------------------------------------ 2 files changed, 95 deletions(-) delete mode 100644 .github/workflows/linter.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 24f3d909db..0000000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,19 +0,0 @@ -on: [push, pull_request] -name: linter - -permissions: - contents: read - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: 1.x - cache-dependency-path: "**/go.sum" - - run: script/lint.sh - env: - CHECK_GITHUB_OPENAPI: 1 - GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 36ec9b3178..0000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,76 +0,0 @@ -concurrency: - group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - pull_request: - branches: - - master - -name: tests -env: - GO111MODULE: on - -permissions: - contents: read - -jobs: - test: - defaults: - run: - shell: bash - strategy: - matrix: - go-version: [1.x, 1.22.x] - platform: [ubuntu-latest] - include: - # include windows, but only with the latest Go version, since there - # is very little in the library that is platform specific - - go-version: 1.x - platform: windows-latest - - # only update test coverage stats with the most recent go version on linux - - go-version: 1.x - platform: ubuntu-latest - update-coverage: true - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v4 - - # Get values for cache paths to be used in later steps - - id: cache-paths - run: | - echo "go-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT - echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT - - - name: Cache go modules - uses: actions/cache@v4 - with: - path: | - ${{ steps.cache-paths.outputs.go-cache }} - ${{ steps.cache-paths.outputs.go-mod-cache }} - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go- - - - name: Run go test - run: | - if [ -n "${{ matrix.update-coverage }}" ]; then - script/test.sh -race -covermode atomic -coverprofile coverage.txt ./... - exit - fi - script/test.sh -race -covermode atomic ./... - - - name: Ensure integration tests build - # don't actually run tests since they hit live GitHub API - run: go test -v -tags=integration -run=^$ ./test/integration - - - name: Upload coverage to Codecov - if: ${{ matrix.update-coverage }} - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 #v4.5.0 From 5d48d9ef9550ed08e67b031b3e5efd6424f3b9a9 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:37:20 -0400 Subject: [PATCH 2/7] Bump go-github from v64 to v65 in /scrape (#3267) --- scrape/apps.go | 2 +- scrape/apps_test.go | 2 +- scrape/go.mod | 2 +- scrape/go.sum | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scrape/apps.go b/scrape/apps.go index 12ca7c0f13..cf294f72f5 100644 --- a/scrape/apps.go +++ b/scrape/apps.go @@ -18,7 +18,7 @@ import ( "strings" "github.com/PuerkitoBio/goquery" - "github.com/google/go-github/v64/github" + "github.com/google/go-github/v65/github" ) // AppRestrictionsEnabled returns whether the specified organization has diff --git a/scrape/apps_test.go b/scrape/apps_test.go index 331c021c82..741bfbb612 100644 --- a/scrape/apps_test.go +++ b/scrape/apps_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/google/go-github/v64/github" + "github.com/google/go-github/v65/github" ) func Test_AppRestrictionsEnabled(t *testing.T) { diff --git a/scrape/go.mod b/scrape/go.mod index 04eff1de44..91a05ac4d6 100644 --- a/scrape/go.mod +++ b/scrape/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.0 require ( github.com/PuerkitoBio/goquery v1.9.2 github.com/google/go-cmp v0.6.0 - github.com/google/go-github/v64 v64.0.0 + github.com/google/go-github/v65 v65.0.0 github.com/xlzd/gotp v0.1.0 golang.org/x/net v0.29.0 ) diff --git a/scrape/go.sum b/scrape/go.sum index f3014057ca..fa424ba7a1 100644 --- a/scrape/go.sum +++ b/scrape/go.sum @@ -5,8 +5,8 @@ github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6 github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v64 v64.0.0 h1:4G61sozmY3eiPAjjoOHponXDBONm+utovTKbyUb2Qdg= -github.com/google/go-github/v64 v64.0.0/go.mod h1:xB3vqMQNdHzilXBiO2I+M7iEFtHf+DP/omBOv6tQzVo= +github.com/google/go-github/v65 v65.0.0 h1:pQ7BmO3DZivvFk92geC0jB0q2m3gyn8vnYPgV7GSLhQ= +github.com/google/go-github/v65 v65.0.0/go.mod h1:DvrqWo5hvsdhJvHd4WyVF9ttANN3BniqjP8uTFMNb60= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/xlzd/gotp v0.1.0 h1:37blvlKCh38s+fkem+fFh7sMnceltoIEBYTVXyoa5Po= From cb513864240b61aaebdb88fc7fa74c1a865aed12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:26:56 -0400 Subject: [PATCH 3/7] Bump github.com/alecthomas/kong from 0.9.0 to 1.2.1 in /tools (#3268) --- tools/go.mod | 2 +- tools/go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 08215dadfd..1b61373c3e 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.22.0 require ( - github.com/alecthomas/kong v0.9.0 + github.com/alecthomas/kong v1.2.1 github.com/getkin/kin-openapi v0.127.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v65 v65.0.0 diff --git a/tools/go.sum b/tools/go.sum index 9cff8611b5..928a46b069 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -1,7 +1,7 @@ -github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= -github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= -github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= +github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= +github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/kong v1.2.1 h1:E8jH4Tsgv6wCRX2nGrdPyHDUCSG83WH2qE4XLACD33Q= +github.com/alecthomas/kong v1.2.1/go.mod h1:rKTSFhbdp3Ryefn8x5MOEprnRFQ7nlmMC01GKhehhBM= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From adb0cb1dd6781e10a75f61bef12a6631e2bf4542 Mon Sep 17 00:00:00 2001 From: Daniel Cole <10801604+danhcole@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:18:28 -0400 Subject: [PATCH 4/7] Add 'mark thread as done' functionality (#3265) Fixes #3264. --- github/activity_notifications.go | 17 +++++++++++++++++ github/activity_notifications_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/github/activity_notifications.go b/github/activity_notifications.go index 47f22261dd..e712323ed4 100644 --- a/github/activity_notifications.go +++ b/github/activity_notifications.go @@ -178,6 +178,23 @@ func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Respo return s.client.Do(ctx, req, nil) } +// MarkThreadDone marks the specified thread as done. +// Marking a thread as "done" is equivalent to marking a notification in your notification inbox on GitHub as done. +// +// GitHub API docs: https://docs.github.com/rest/activity/notifications#mark-a-thread-as-done +// +//meta:operation DELETE /notifications/threads/{thread_id} +func (s *ActivityService) MarkThreadDone(ctx context.Context, id int64) (*Response, error) { + u := fmt.Sprintf("notifications/threads/%v", id) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + // GetThreadSubscription checks to see if the authenticated user is subscribed // to a thread. // diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 815238ebb5..0c224924cc 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -208,6 +208,32 @@ func TestActivityService_MarkThreadRead(t *testing.T) { }) } +func TestActivityService_MarkThreadDone(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + w.WriteHeader(http.StatusResetContent) + }) + + ctx := context.Background() + _, err := client.Activity.MarkThreadDone(ctx, 1) + if err != nil { + t.Errorf("Activity.MarkThreadDone returned error: %v", err) + } + + const methodName = "MarkThreadDone" + testBadOptions(t, methodName, func() (err error) { + _, err = client.Activity.MarkThreadDone(ctx, 0) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + return client.Activity.MarkThreadDone(ctx, 1) + }) +} + func TestActivityService_GetThreadSubscription(t *testing.T) { client, mux, _, teardown := setup() defer teardown() From eb2b7dd30af8e5f5d9194e0695582f83976b357e Mon Sep 17 00:00:00 2001 From: Mudit Date: Thu, 19 Sep 2024 16:49:59 +0200 Subject: [PATCH 5/7] feat!: Add login query param support to ListCredentialAuthorizations (#3270) BREAKING CHANGE: `ListCredentialAuthorizations` now takes `opts *CredentialAuthorizationsListOptions` instead of `ListOptions`. --- github/orgs_credential_authorizations.go | 12 +++++++++++- github/orgs_credential_authorizations_test.go | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/github/orgs_credential_authorizations.go b/github/orgs_credential_authorizations.go index eed0f0c66e..dca42433c3 100644 --- a/github/orgs_credential_authorizations.go +++ b/github/orgs_credential_authorizations.go @@ -55,13 +55,23 @@ type CredentialAuthorization struct { AuthorizedCredentialExpiresAt *Timestamp `json:"authorized_credential_expires_at,omitempty"` } +// CredentialAuthorizationsListOptions adds the Login option as supported by the +// list SAML SSO authorizations for organizations endpoint alongside paging options +// such as Page and PerPage. +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization +type CredentialAuthorizationsListOptions struct { + ListOptions + // For credentials authorizations for an organization, limit the list of authorizations to a specific login (aka github username) + Login string `url:"login,omitempty"` +} + // ListCredentialAuthorizations lists credentials authorized through SAML SSO // for a given organization. Only available with GitHub Enterprise Cloud. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization // //meta:operation GET /orgs/{org}/credential-authorizations -func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error) { +func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) ([]*CredentialAuthorization, *Response, error) { u := fmt.Sprintf("orgs/%v/credential-authorizations", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/orgs_credential_authorizations_test.go b/github/orgs_credential_authorizations_test.go index e3986eb5ca..006ee86c45 100644 --- a/github/orgs_credential_authorizations_test.go +++ b/github/orgs_credential_authorizations_test.go @@ -21,7 +21,7 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { mux.HandleFunc("/orgs/o/credential-authorizations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodGet) - testFormValues(t, r, values{"per_page": "2", "page": "2"}) + testFormValues(t, r, values{"per_page": "2", "page": "2", "login": "l"}) fmt.Fprint(w, `[ { "login": "l", @@ -34,7 +34,11 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) { ]`) }) - opts := &ListOptions{Page: 2, PerPage: 2} + opts := &CredentialAuthorizationsListOptions{ + ListOptions: ListOptions{Page: 2, PerPage: 2}, + Login: "l", + } + ctx := context.Background() creds, _, err := client.Organizations.ListCredentialAuthorizations(ctx, "o", opts) if err != nil { From d6ceb3f6112e8acbea7f0ab033e2321bd041d420 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:43:03 -0400 Subject: [PATCH 6/7] Update comment for Ruleset (#3275) --- github/repos_rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index a90555cc44..50e75cdba1 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -458,7 +458,7 @@ func NewFilePathRestrictionRule(params *RuleFileParameters) (rule *RepositoryRul type Ruleset struct { ID *int64 `json:"id,omitempty"` Name string `json:"name"` - // Possible values for Target are branch, tag + // Possible values for Target are branch, tag, push Target *string `json:"target,omitempty"` // Possible values for SourceType are: Repository, Organization SourceType *string `json:"source_type,omitempty"` From 834c8b5377fc78c7b44c66babd95284d03eb6675 Mon Sep 17 00:00:00 2001 From: Rafael David Tinoco Date: Fri, 20 Sep 2024 16:48:21 -0300 Subject: [PATCH 7/7] fix: fix workflows --- .github/workflows/build.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b4d4809267..d008569513 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -223,9 +223,6 @@ jobs: ping -c 5 -w 5 www.uol.com.br > /dev/null 2>&1 || true # - name: Network 02 - uses: ./.github/actions/test - # - - name: Network 03 run: | curl -s --connect-timeout 5 -m 5 -o /dev/null https://www.pinterest.com || true curl -s --connect-timeout 5 -m 5 -o /dev/null https://www.etsy.com || true @@ -233,17 +230,14 @@ jobs: curl -s --connect-timeout 5 -m 5 -o /dev/null https://www.snapchat.com || true curl -s --connect-timeout 5 -m 5 -o /dev/null https://www.whatsapp.com || true # - - name: Network 04 - uses: rafaeldtinoco/list-github-env@v0.4 - # - - name: Network 05 + - name: Network 03 run: | ping -c 5 -w 5 www.google.com > /dev/null 2>&1 || true ping -c 5 -w 5 www.google.com > /dev/null 2>&1 || true ping -c 5 -w 5 8.8.4.4 > /dev/null 2>&1 || true ping -c 5 -w 5 8.8.8.8 > /dev/null 2>&1 || true # - - name: Network 06 + - name: Network 04 run: | ping -c 5 -w 5 1.1.1.1 > /dev/null 2>&1 || true curl -s --connect-timeout 5 -m 5 -o /dev/null https://www.etsy.com || true