Skip to content

Commit a5053c5

Browse files
committed
Merge remote-tracking branch 'origin/main' into omit-login-redirect-param/kira-pilot
2 parents fabba06 + 1f03277 commit a5053c5

29 files changed

+615
-55
lines changed

.github/workflows/coder.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ jobs:
275275
done
276276
277277
- name: Test with PostgreSQL Database
278-
run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
279-
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
280-
-coverpkg=./...,github.com/coder/coder/codersdk
281-
-count=1 -parallel=2 -race -failfast
278+
run: "make test-postgres"
282279

283280
- name: Upload DataDog Trace
284281
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork

.goreleaser.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@ archives:
22
- id: coder-linux
33
builds: [coder-linux]
44
format: tar.gz
5-
files:
6-
- src: docs/README.md
7-
dst: README.md
85

96
- id: coder-darwin
107
builds: [coder-darwin]
118
format: zip
12-
files:
13-
- src: docs/README.md
14-
dst: README.md
159

1610
- id: coder-windows
1711
builds: [coder-windows]
1812
format: zip
19-
files:
20-
- src: docs/README.md
21-
dst: README.md
2213

2314
before:
2415
hooks:

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,33 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
9191
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
9292
cd site && yarn run format:types
9393

94-
test:
94+
.PHONY: test
95+
test: test-clean
9596
gotestsum -- -v -short ./...
97+
98+
.PHONY: test-postgres
99+
test-postgres: test-clean
100+
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \
101+
-covermode=atomic -coverprofile="gotests.coverage" -timeout=5m \
102+
-coverpkg=./...,github.com/coder/coder/codersdk \
103+
-count=1 -parallel=1 -race -failfast
104+
105+
106+
.PHONY: test-postgres-docker
107+
test-postgres-docker:
108+
docker run \
109+
--env POSTGRES_PASSWORD=postgres \
110+
--env POSTGRES_USER=postgres \
111+
--env POSTGRES_DB=postgres \
112+
--env PGDATA=/tmp \
113+
--publish 5432:5432 \
114+
--name test-postgres-docker \
115+
--restart unless-stopped \
116+
--detach \
117+
postgres:11 \
118+
-c shared_buffers=1GB \
119+
-c max_connections=1000
120+
121+
.PHONY: test-clean
122+
test-clean:
123+
go clean -testcache

cli/parameter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"golang.org/x/xerrors"
77
"gopkg.in/yaml.v3"
88

9+
"github.com/spf13/cobra"
10+
911
"github.com/coder/coder/cli/cliui"
1012
"github.com/coder/coder/codersdk"
11-
"github.com/spf13/cobra"
1213
)
1314

1415
// Reads a YAML file and populates a string -> string map.

cli/ssh_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
)
2424

2525
func TestSSH(t *testing.T) {
26+
t.Skip("This is causing test flakes. TODO @cian fix this")
2627
t.Parallel()
2728
t.Run("ImmediateExit", func(t *testing.T) {
2829
t.Parallel()

coderd/workspaces_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ func TestWorkspacesByOrganization(t *testing.T) {
182182
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
183183
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
184184
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
185-
_ = coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
185+
ws := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
186+
_ = coderdtest.AwaitWorkspaceBuildJob(t, client, ws.LatestBuild.ID)
186187
workspaces, err := client.WorkspacesByOrganization(context.Background(), user.OrganizationID)
187188
require.NoError(t, err)
188189
require.Len(t, workspaces, 1)

peer/conn_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func TestMain(m *testing.M) {
5959
}
6060

6161
func TestConn(t *testing.T) {
62+
t.Skip("known flake -- https://github.com/coder/coder/issues/1644")
6263
t.Parallel()
6364

6465
t.Run("Ping", func(t *testing.T) {

site/src/components/BuildsTable/BuildsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const BuildsTable: React.FC<BuildsTableProps> = ({ builds, className }) =
3434
const styles = useStyles()
3535

3636
return (
37-
<Table className={className}>
37+
<Table className={className} data-testid="builds-table">
3838
<TableHead>
3939
<TableRow>
4040
<TableCell width="20%">{Language.actionLabel}</TableCell>

site/src/components/Footer/Footer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const useFooterStyles = makeStyles((theme) => ({
4242
flex: "0",
4343
paddingTop: theme.spacing(2),
4444
paddingBottom: theme.spacing(2),
45+
marginTop: theme.spacing(3),
4546
},
4647
copyRight: {
4748
margin: theme.spacing(0.25),
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { makeStyles, Theme } from "@material-ui/core/styles"
2+
import Table from "@material-ui/core/Table"
3+
import TableBody from "@material-ui/core/TableBody"
4+
import TableCell from "@material-ui/core/TableCell"
5+
import TableHead from "@material-ui/core/TableHead"
6+
import TableRow from "@material-ui/core/TableRow"
7+
import useTheme from "@material-ui/styles/useTheme"
8+
import React from "react"
9+
import { WorkspaceResource } from "../../api/typesGenerated"
10+
import { getDisplayAgentStatus } from "../../util/workspace"
11+
import { TableHeaderRow } from "../TableHeaders/TableHeaders"
12+
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
13+
14+
const Language = {
15+
resources: "Resources",
16+
resourceLabel: "Resource",
17+
agentsLabel: "Agents",
18+
agentLabel: "Agent",
19+
statusLabel: "Status",
20+
}
21+
22+
interface ResourcesProps {
23+
resources?: WorkspaceResource[]
24+
getResourcesError?: Error
25+
}
26+
27+
export const Resources: React.FC<ResourcesProps> = ({ resources, getResourcesError }) => {
28+
const styles = useStyles()
29+
const theme: Theme = useTheme()
30+
31+
return (
32+
<WorkspaceSection title={Language.resources} contentsProps={{ className: styles.sectionContents }}>
33+
{getResourcesError ? (
34+
{ getResourcesError }
35+
) : (
36+
<Table className={styles.table}>
37+
<TableHead>
38+
<TableHeaderRow>
39+
<TableCell>{Language.resourceLabel}</TableCell>
40+
<TableCell className={styles.agentColumn}>{Language.agentLabel}</TableCell>
41+
<TableCell>{Language.statusLabel}</TableCell>
42+
</TableHeaderRow>
43+
</TableHead>
44+
<TableBody>
45+
{resources?.map((resource) => {
46+
{
47+
/* We need to initialize the agents to display the resource */
48+
}
49+
const agents = resource.agents ?? [null]
50+
return agents.map((agent, agentIndex) => {
51+
{
52+
/* If there is no agent, just display the resource name */
53+
}
54+
if (!agent) {
55+
return (
56+
<TableRow>
57+
<TableCell className={styles.resourceNameCell}>{resource.name}</TableCell>
58+
<TableCell colSpan={2}></TableCell>
59+
</TableRow>
60+
)
61+
}
62+
63+
return (
64+
<TableRow key={`${resource.id}-${agent.id}`}>
65+
{/* We only want to display the name in the first row because we are using rowSpan */}
66+
{/* The rowspan should be the same than the number of agents */}
67+
{agentIndex === 0 && (
68+
<TableCell className={styles.resourceNameCell} rowSpan={agents.length}>
69+
{resource.name}
70+
</TableCell>
71+
)}
72+
73+
<TableCell className={styles.agentColumn}>
74+
<span style={{ color: theme.palette.text.secondary }}>{agent.name}</span>
75+
</TableCell>
76+
<TableCell>
77+
<span style={{ color: getDisplayAgentStatus(theme, agent).color }}>
78+
{getDisplayAgentStatus(theme, agent).status}
79+
</span>
80+
</TableCell>
81+
</TableRow>
82+
)
83+
})
84+
})}
85+
</TableBody>
86+
</Table>
87+
)}
88+
</WorkspaceSection>
89+
)
90+
}
91+
92+
const useStyles = makeStyles((theme) => ({
93+
sectionContents: {
94+
margin: 0,
95+
},
96+
97+
table: {
98+
border: 0,
99+
},
100+
101+
resourceNameCell: {
102+
borderRight: `1px solid ${theme.palette.divider}`,
103+
},
104+
105+
// Adds some left spacing
106+
agentColumn: {
107+
paddingLeft: `${theme.spacing(2)}px !important`,
108+
},
109+
}))

site/src/components/Stack/Stack.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { makeStyles } from "@material-ui/core/styles"
22
import React from "react"
3+
import { combineClasses } from "../../util/combineClasses"
34

45
type Direction = "column" | "row"
56

67
interface StyleProps {
7-
spacing: number
88
direction: Direction
9+
spacing: number
910
}
1011

1112
const useStyles = makeStyles((theme) => ({
@@ -17,11 +18,13 @@ const useStyles = makeStyles((theme) => ({
1718
}))
1819

1920
export interface StackProps {
20-
spacing?: number
21+
className?: string
2122
direction?: Direction
23+
spacing?: number
2224
}
2325

24-
export const Stack: React.FC<StackProps> = ({ children, spacing = 2, direction = "column" }) => {
26+
export const Stack: React.FC<StackProps> = ({ children, className, direction = "column", spacing = 2 }) => {
2527
const styles = useStyles({ spacing, direction })
26-
return <div className={styles.stack}>{children}</div>
28+
29+
return <div className={combineClasses([styles.stack, className])}>{children}</div>
2730
}

site/src/components/Workspace/Workspace.stories.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { action } from "@storybook/addon-actions"
22
import { Story } from "@storybook/react"
33
import React from "react"
4-
import { MockOutdatedWorkspace, MockWorkspace } from "../../testHelpers/renderHelpers"
4+
import {
5+
MockOutdatedWorkspace,
6+
MockWorkspace,
7+
MockWorkspaceResource,
8+
MockWorkspaceResource2,
9+
} from "../../testHelpers/renderHelpers"
510
import { Workspace, WorkspaceProps } from "./Workspace"
611

712
export default {
@@ -19,6 +24,7 @@ Started.args = {
1924
handleStop: action("stop"),
2025
handleRetry: action("retry"),
2126
workspaceStatus: "started",
27+
resources: [MockWorkspaceResource, MockWorkspaceResource2],
2228
}
2329

2430
export const Starting = Template.bind({})

site/src/components/Workspace/Workspace.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as TypesGen from "../../api/typesGenerated"
55
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
66
import { WorkspaceStatus } from "../../util/workspace"
77
import { BuildsTable } from "../BuildsTable/BuildsTable"
8+
import { Resources } from "../Resources/Resources"
89
import { Stack } from "../Stack/Stack"
910
import { WorkspaceActions } from "../WorkspaceActions/WorkspaceActions"
1011
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
@@ -17,6 +18,8 @@ export interface WorkspaceProps {
1718
handleUpdate: () => void
1819
workspace: TypesGen.Workspace
1920
workspaceStatus: WorkspaceStatus
21+
resources?: TypesGen.WorkspaceResource[]
22+
getResourcesError?: Error
2023
builds?: TypesGen.WorkspaceBuild[]
2124
}
2225

@@ -30,6 +33,8 @@ export const Workspace: React.FC<WorkspaceProps> = ({
3033
handleUpdate,
3134
workspace,
3235
workspaceStatus,
36+
resources,
37+
getResourcesError,
3338
builds,
3439
}) => {
3540
const styles = useStyles()
@@ -61,6 +66,7 @@ export const Workspace: React.FC<WorkspaceProps> = ({
6166

6267
<Stack spacing={3}>
6368
<WorkspaceStats workspace={workspace} />
69+
<Resources resources={resources} getResourcesError={getResourcesError} />
6470
<WorkspaceSection title="Timeline" contentsProps={{ className: styles.timelineContents }}>
6571
<BuildsTable builds={builds} className={styles.timelineTable} />
6672
</WorkspaceSection>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { action } from "@storybook/addon-actions"
2+
import { Story } from "@storybook/react"
3+
import React from "react"
4+
import { WorkspaceScheduleForm, WorkspaceScheduleFormProps } from "./WorkspaceScheduleForm"
5+
6+
export default {
7+
title: "components/WorkspaceScheduleForm",
8+
component: WorkspaceScheduleForm,
9+
}
10+
11+
const Template: Story<WorkspaceScheduleFormProps> = (args) => <WorkspaceScheduleForm {...args} />
12+
13+
export const Example = Template.bind({})
14+
Example.args = {
15+
onCancel: () => action("onCancel"),
16+
onSubmit: () => {
17+
action("onSubmit")
18+
return Promise.resolve()
19+
},
20+
}

0 commit comments

Comments
 (0)