Skip to content

Commit 6d0637f

Browse files
authored
Merge branch 'master' into add-projects
2 parents fb6e7a8 + 46f1bf2 commit 6d0637f

25 files changed

+1166
-87
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
5555
5656
- name: Cache go modules
57-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
57+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
5858
with:
5959
path: |
6060
${{ steps.cache-paths.outputs.go-cache }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coverage.out
99
vendor/
1010
.DS_Store
1111
.vscode
12+
.claude/
1213
# vim temp files
1314
*.swp
1415

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ linters:
88
- copyloopvar
99
- dogsled
1010
- dupl
11+
- errorlint
1112
- forbidigo
1213
- gocritic
1314
- godot
@@ -25,6 +26,10 @@ linters:
2526
- unparam
2627
- whitespace
2728
settings:
29+
errorlint:
30+
errorf: false
31+
asserts: true
32+
comparison: true
2833
forbidigo:
2934
forbid:
3035
- pattern: ^reflect\.DeepEqual$

example/basicauth/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package main
1717
import (
1818
"bufio"
1919
"context"
20+
"errors"
2021
"fmt"
2122
"os"
2223
"strings"
@@ -43,7 +44,7 @@ func main() {
4344
user, _, err := client.Users.Get(ctx, "")
4445

4546
// Is this a two-factor auth error? If so, prompt for OTP and try again.
46-
if _, ok := err.(*github.TwoFactorAuthError); ok {
47+
if errors.As(err, new(*github.TwoFactorAuthError)) {
4748
fmt.Print("\nGitHub OTP: ")
4849
otp, _ := r.ReadString('\n')
4950
tp.OTP = strings.TrimSpace(otp)

github/actions_workflow_runs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package github
88
import (
99
"context"
1010
"encoding/json"
11+
"errors"
1112
"fmt"
1213
"net/http"
1314
"net/url"
@@ -482,7 +483,7 @@ func TestActionsService_CancelWorkflowRunByID(t *testing.T) {
482483

483484
ctx := context.Background()
484485
resp, err := client.Actions.CancelWorkflowRunByID(ctx, "o", "r", 3434)
485-
if _, ok := err.(*AcceptedError); !ok {
486+
if !errors.As(err, new(*AcceptedError)) {
486487
t.Errorf("Actions.CancelWorkflowRunByID returned error: %v (want AcceptedError)", err)
487488
}
488489
if resp.StatusCode != http.StatusAccepted {

github/classroom.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ import (
1616
// GitHub API docs: https://docs.github.com/rest/classroom/classroom
1717
type ClassroomService service
1818

19+
// ClassroomUser represents a GitHub user simplified for Classroom.
20+
type ClassroomUser struct {
21+
ID *int64 `json:"id,omitempty"`
22+
Login *string `json:"login,omitempty"`
23+
AvatarURL *string `json:"avatar_url,omitempty"`
24+
HTMLURL *string `json:"html_url,omitempty"`
25+
}
26+
27+
func (u ClassroomUser) String() string {
28+
return Stringify(u)
29+
}
30+
1931
// Classroom represents a GitHub Classroom.
2032
type Classroom struct {
2133
ID *int64 `json:"id,omitempty"`
@@ -56,6 +68,41 @@ func (a ClassroomAssignment) String() string {
5668
return Stringify(a)
5769
}
5870

71+
// AcceptedAssignment represents a GitHub Classroom accepted assignment.
72+
type AcceptedAssignment struct {
73+
ID *int64 `json:"id,omitempty"`
74+
Submitted *bool `json:"submitted,omitempty"`
75+
Passing *bool `json:"passing,omitempty"`
76+
CommitCount *int `json:"commit_count,omitempty"`
77+
Grade *string `json:"grade,omitempty"`
78+
Students []*ClassroomUser `json:"students,omitempty"`
79+
Repository *Repository `json:"repository,omitempty"`
80+
Assignment *ClassroomAssignment `json:"assignment,omitempty"`
81+
}
82+
83+
func (a AcceptedAssignment) String() string {
84+
return Stringify(a)
85+
}
86+
87+
// AssignmentGrade represents a GitHub Classroom assignment grade.
88+
type AssignmentGrade struct {
89+
AssignmentName *string `json:"assignment_name,omitempty"`
90+
AssignmentURL *string `json:"assignment_url,omitempty"`
91+
StarterCodeURL *string `json:"starter_code_url,omitempty"`
92+
GithubUsername *string `json:"github_username,omitempty"`
93+
RosterIdentifier *string `json:"roster_identifier,omitempty"`
94+
StudentRepositoryName *string `json:"student_repository_name,omitempty"`
95+
StudentRepositoryURL *string `json:"student_repository_url,omitempty"`
96+
SubmissionTimestamp *Timestamp `json:"submission_timestamp,omitempty"`
97+
PointsAwarded *int `json:"points_awarded,omitempty"`
98+
PointsAvailable *int `json:"points_available,omitempty"`
99+
GroupName *string `json:"group_name,omitempty"`
100+
}
101+
102+
func (g AssignmentGrade) String() string {
103+
return Stringify(g)
104+
}
105+
59106
// GetAssignment gets a GitHub Classroom assignment. Assignment will only be
60107
// returned if the current user is an administrator of the GitHub Classroom
61108
// for the assignment.
@@ -155,3 +202,55 @@ func (s *ClassroomService) ListClassroomAssignments(ctx context.Context, classro
155202

156203
return assignments, resp, nil
157204
}
205+
206+
// ListAcceptedAssignments lists accepted assignments for a GitHub Classroom assignment.
207+
// Accepted assignments will only be returned if the current user is an administrator
208+
// of the GitHub Classroom for the assignment.
209+
//
210+
// GitHub API docs: https://docs.github.com/rest/classroom/classroom#list-accepted-assignments-for-an-assignment
211+
//
212+
//meta:operation GET /assignments/{assignment_id}/accepted_assignments
213+
func (s *ClassroomService) ListAcceptedAssignments(ctx context.Context, assignmentID int64, opts *ListOptions) ([]*AcceptedAssignment, *Response, error) {
214+
u := fmt.Sprintf("assignments/%v/accepted_assignments", assignmentID)
215+
u, err := addOptions(u, opts)
216+
if err != nil {
217+
return nil, nil, err
218+
}
219+
220+
req, err := s.client.NewRequest("GET", u, nil)
221+
if err != nil {
222+
return nil, nil, err
223+
}
224+
225+
var acceptedAssignments []*AcceptedAssignment
226+
resp, err := s.client.Do(ctx, req, &acceptedAssignments)
227+
if err != nil {
228+
return nil, resp, err
229+
}
230+
231+
return acceptedAssignments, resp, nil
232+
}
233+
234+
// GetAssignmentGrades gets assignment grades for a GitHub Classroom assignment.
235+
// Grades will only be returned if the current user is an administrator
236+
// of the GitHub Classroom for the assignment.
237+
//
238+
// GitHub API docs: https://docs.github.com/rest/classroom/classroom#get-assignment-grades
239+
//
240+
//meta:operation GET /assignments/{assignment_id}/grades
241+
func (s *ClassroomService) GetAssignmentGrades(ctx context.Context, assignmentID int64) ([]*AssignmentGrade, *Response, error) {
242+
u := fmt.Sprintf("assignments/%v/grades", assignmentID)
243+
244+
req, err := s.client.NewRequest("GET", u, nil)
245+
if err != nil {
246+
return nil, nil, err
247+
}
248+
249+
var grades []*AssignmentGrade
250+
resp, err := s.client.Do(ctx, req, &grades)
251+
if err != nil {
252+
return nil, resp, err
253+
}
254+
255+
return grades, resp, nil
256+
}

0 commit comments

Comments
 (0)