Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit679e269

Browse files
committed
Merge branch 'main' ofhttps://github.com/coder/coder into bq/display-ws-status-on-tasks
2 parents1c12838 +98262d8 commit679e269

File tree

37 files changed

+3593
-2346
lines changed

37 files changed

+3593
-2346
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name:AI Triage Automation
22

33
on:
4+
issues:
5+
types:
6+
-labeled
47
workflow_dispatch:
58
inputs:
69
issue_url:
@@ -32,6 +35,7 @@ jobs:
3235
traiage:
3336
name:Triage GitHub Issue with Claude Code
3437
runs-on:ubuntu-latest
38+
if:github.event.label.name == 'traiage' || github.event_name == 'workflow_dispatch'
3539
timeout-minutes:30
3640
env:
3741
CODER_URL:${{ secrets.TRAIAGE_CODER_URL }}
@@ -43,17 +47,58 @@ jobs:
4347
actions:write
4448

4549
steps:
46-
-name:Checkout repository
47-
uses:actions/checkout@v4
48-
with:
49-
persist-credentials:false
50-
fetch-depth:0
50+
-name:Get GitHub user ID
51+
id:github-user-id
52+
if:always()
53+
env:
54+
GITHUB_ACTOR:${{ github.actor }}
55+
GITHUB_EVENT_NAME:${{ github.event_name }}
56+
GITHUB_EVENT_USER_ID:${{ github.event.sender.id }}
57+
GITHUB_EVENT_USER_LOGIN:${{ github.event.sender.login }}
58+
GH_TOKEN:${{ github.token }}
59+
run:|
60+
# For workflow_dispatch, use the actor who triggered it
61+
# For issues events, use the issue author
62+
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
63+
if ! GITHUB_USER_ID=$(gh api "users/${GITHUB_ACTOR}" --jq '.id'); then
64+
echo "::error::Failed to get GitHub user ID for actor ${GITHUB_ACTOR}"
65+
exit 1
66+
fi
67+
echo "Using workflow_dispatch actor: ${GITHUB_ACTOR} (ID: ${GITHUB_USER_ID})"
68+
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
69+
echo "github_username=${GITHUB_ACTOR}" >> "${GITHUB_OUTPUT}"
70+
exit 0
71+
elif [[ "${GITHUB_EVENT_NAME}" == "issues" ]]; then
72+
GITHUB_USER_ID=${GITHUB_EVENT_USER_ID}
73+
echo "Using issue author: ${GITHUB_EVENT_USER_LOGIN} (ID: ${GITHUB_USER_ID})"
74+
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
75+
echo "github_username=${GITHUB_EVENT_USER_LOGIN}" >> "${GITHUB_OUTPUT}"
76+
exit 0
77+
else
78+
echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}"
79+
exit 1
80+
fi
81+
82+
-name:Verify organization membership
83+
env:
84+
GITHUB_ORG:${{ github.repository_owner }}
85+
GH_TOKEN:${{ github.token }}
86+
GITHUB_USERNAME:${{ steps.github-user-id.outputs.github_username }}
87+
GITHUB_USER_ID:${{ steps.github-user-id.outputs.github_user_id }}
88+
run:|
89+
# Check if the actor is a member of the organization
90+
if ! gh api "orgs/${GITHUB_ORG}/members/${GITHUB_USERNAME}" --silent 2>/dev/null; then
91+
echo "::error title=Access Denied::User ${GITHUB_USERNAME} is not a member of the ${GITHUB_ORG} organization"
92+
echo "::error::You must be a member of the ${GITHUB_ORG} GitHub organization to run this workflow."
93+
exit 1
94+
fi
95+
echo "::notice::User ${GITHUB_USERNAME} verified as member of ${GITHUB_ORG} organization"
5196
5297
-name:Extract context key from issue
5398
id:extract-context
5499
env:
55100
ISSUE_URL:${{ inputs.issue_url }}
56-
GITHUB_TOKEN:${{ github.token }}
101+
GH_TOKEN:${{ github.token }}
57102
run:|
58103
issue_number="$(gh issue view "${ISSUE_URL}" --json number --jq '.number')"
59104
context_key="gh-${issue_number}"
@@ -82,25 +127,30 @@ jobs:
82127
id:get-coder-username
83128
env:
84129
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
85-
GITHUB_USER_ID:${{
86-
(github.event_name == 'workflow_dispatch' && github.actor_id)
87-
}}
130+
GH_TOKEN:${{ github.token }}
131+
GITHUB_USER_ID:${{ steps.github-user-id.outputs.github_user_id }}
88132
run:|
89-
[[ -z "${GITHUB_USER_ID}" || "${GITHUB_USER_ID}" == "null" ]] && echo "No GitHub actor ID found" && exit 1
90133
user_json=$(
91134
coder users list --github-user-id="${GITHUB_USER_ID}" --output=json
92135
)
93136
coder_username=$(jq -r 'first | .username' <<< "$user_json")
94137
[[ -z "${coder_username}" || "${coder_username}" == "null" ]] && echo "No Coder user with GitHub user ID ${GITHUB_USER_ID} found" && exit 1
95138
echo "coder_username=${coder_username}" >> "${GITHUB_OUTPUT}"
96139
140+
-name:Checkout repository
141+
uses:actions/checkout@v4
142+
with:
143+
persist-credentials:false
144+
fetch-depth:0
145+
97146
# TODO(Cian): this is a good use-case for 'recipes'
98147
-name:Create Coder task
99148
id:create-task
100149
env:
101150
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
102151
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
103-
GITHUB_TOKEN:${{ github.token }}
152+
GH_TOKEN:${{ github.token }}
153+
GITHUB_REPOSITORY:${{ github.repository }}
104154
ISSUE_URL:${{ inputs.issue_url }}
105155
PREFIX:${{ inputs.prefix }}
106156
RUN_ID:${{ github.run_id }}
@@ -125,7 +175,11 @@ jobs:
125175
export TASK_NAME="${PREFIX}-${CONTEXT_KEY}-${RUN_ID}"
126176
echo "Creating task: $TASK_NAME"
127177
./scripts/traiage.sh create
128-
coder exp task status "${CODER_USERNAME}/$TASK_NAME" --watch
178+
if [[ "${ISSUE_URL}" == "https://github.com/${GITHUB_REPOSITORY}"* ]]; then
179+
gh issue comment "${ISSUE_URL}" --body "Task created: ${TASK_NAME}" --create-if-none --edit-last
180+
else
181+
echo "Skipping comment on other repo."
182+
fi
129183
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_OUTPUT}"
130184
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_ENV}"
131185
@@ -134,7 +188,11 @@ jobs:
134188
if:inputs.cleanup
135189
env:
136190
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
191+
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
192+
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}
137193
run:|
194+
echo "Waiting for task to complete..."
195+
coder exp task status "${CODER_USERNAME}/$TASK_NAME" --watch
138196
echo "Creating archive for workspace: $TASK_NAME"
139197
./scripts/traiage.sh archive
140198
echo "archive_url=${BUCKET_PREFIX%%/}/$TASK_NAME.tar.gz" >> "${GITHUB_OUTPUT}"
@@ -145,8 +203,9 @@ jobs:
145203
env:
146204
ARCHIVE_URL:${{ steps.create-archive.outputs.archive_url }}
147205
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
206+
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
148207
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
149-
GITHUB_TOKEN:${{ github.token }}
208+
GH_TOKEN:${{ github.token }}
150209
GITHUB_REPOSITORY:${{ github.repository }}
151210
ISSUE_URL:${{ inputs.issue_url }}
152211
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}

‎cli/exp_boundary.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package cli
2+
3+
import (
4+
boundarycli"github.com/coder/boundary/cli"
5+
"github.com/coder/serpent"
6+
)
7+
8+
func (*RootCmd)boundary()*serpent.Command {
9+
cmd:=boundarycli.BaseCommand()// Package coder/boundary/cli exports a "base command" designed to be integrated as a subcommand.
10+
cmd.Use+=" [args...]"// The base command looks like `boundary -- command`. Serpent adds the flags piece, but we need to add the args.
11+
returncmd
12+
}

‎cli/exp_boundary_test.go‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package cli_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
8+
boundarycli"github.com/coder/boundary/cli"
9+
"github.com/coder/coder/v2/cli/clitest"
10+
"github.com/coder/coder/v2/pty/ptytest"
11+
"github.com/coder/coder/v2/testutil"
12+
)
13+
14+
// Actually testing the functionality of coder/boundary takes place in the
15+
// coder/boundary repo, since it's a dependency of coder.
16+
// Here we want to test basically that integrating it as a subcommand doesn't break anything.
17+
funcTestBoundarySubcommand(t*testing.T) {
18+
t.Parallel()
19+
ctx:=testutil.Context(t,testutil.WaitShort)
20+
21+
inv,_:=clitest.New(t,"exp","boundary","--help")
22+
pty:=ptytest.New(t).Attach(inv)
23+
24+
gofunc() {
25+
err:=inv.WithContext(ctx).Run()
26+
assert.NoError(t,err)
27+
}()
28+
29+
// Expect the --help output to include the short description.
30+
// We're simply confirming that `coder boundary --help` ran without a runtime error as
31+
// a good chunk of serpents self validation logic happens at runtime.
32+
pty.ExpectMatch(boundarycli.BaseCommand().Short)
33+
}

‎cli/root.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func (r *RootCmd) AGPLExperimental() []*serpent.Command {
145145
r.promptExample(),
146146
r.rptyCommand(),
147147
r.tasksCommand(),
148+
r.boundary(),
148149
}
149150
}
150151

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ func (q *querier) DeleteOrganizationMember(ctx context.Context, arg database.Del
16911691
OrganizationID:arg.OrganizationID,
16921692
UserID:arg.UserID,
16931693
IncludeSystem:false,
1694+
GithubUserID:0,
16941695
}))
16951696
iferr!=nil {
16961697
return database.OrganizationMember{},err
@@ -4694,6 +4695,7 @@ func (q *querier) UpdateMemberRoles(ctx context.Context, arg database.UpdateMemb
46944695
OrganizationID:arg.OrgID,
46954696
UserID:arg.UserID,
46964697
IncludeSystem:false,
4698+
GithubUserID:0,
46974699
}))
46984700
iferr!=nil {
46994701
return database.OrganizationMember{},err

‎coderd/database/queries.sql.go‎

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/organizationmembers.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ WHERE
2828
WHEN @include_system::bool THEN TRUE
2929
ELSE
3030
is_system= false
31-
END;
31+
END
32+
-- Filter by github user ID. Note that this requires a join on the users table.
33+
AND CASE
34+
WHEN @github_user_id ::bigint!=0 THEN
35+
users.github_com_user_id= @github_user_id
36+
ELSE true
37+
END;
3238

3339
-- name: InsertOrganizationMember :one
3440
INSERT INTO

‎coderd/dynamicparameters/render.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ func WorkspaceOwner(ctx context.Context, db database.Store, org uuid.UUID, owner
300300
OrganizationID:org,
301301
UserID:ownerID,
302302
IncludeSystem:true,
303+
GithubUserID:0,
303304
}))
304305
iferr!=nil {
305306
returnnil,xerrors.Errorf("fetch user: %w",err)

‎coderd/httpmw/organizationparam.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func ExtractOrganizationMember(ctx context.Context, auth func(r *http.Request, a
181181
OrganizationID:orgID,
182182
UserID:user.ID,
183183
IncludeSystem:true,
184+
GithubUserID:0,
184185
})
185186
ifhttpapi.Is404Error(err) {
186187
httpapi.ResourceNotFound(rw)

‎coderd/idpsync/role.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (s AGPLIDPSync) SyncRoles(ctx context.Context, db database.Store, user data
9393
OrganizationID:uuid.Nil,
9494
UserID:user.ID,
9595
IncludeSystem:false,
96+
GithubUserID:0,
9697
})
9798
iferr!=nil {
9899
returnxerrors.Errorf("get organizations by user id: %w",err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp