Skip to content

Commit 1be1dc6

Browse files
authored
Merge branch 'main' into main
2 parents 677c897 + 3f3a489 commit 1be1dc6

File tree

16 files changed

+242
-36
lines changed

16 files changed

+242
-36
lines changed

.github/workflows/ci.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ on:
88
branches:
99
- main
1010

11+
# Cancel in-progress runs for pull requests when developers push
12+
# additional changes, and serialize builds in branches.
13+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17+
1118
# Note: if: success() is used in several jobs -
1219
# this ensures that it only executes if all previous jobs succeeded.
1320

@@ -21,7 +28,7 @@ jobs:
2128
timeout-minutes: 15
2229
steps:
2330
- name: Checkout repo
24-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
2532

2633
- name: Install Node.js v14
2734
uses: actions/setup-node@v3
@@ -63,7 +70,7 @@ jobs:
6370
timeout-minutes: 15
6471
steps:
6572
- name: Checkout repo
66-
uses: actions/checkout@v2
73+
uses: actions/checkout@v3
6774

6875
- name: Install Node.js v14
6976
uses: actions/setup-node@v3
@@ -95,7 +102,7 @@ jobs:
95102
env:
96103
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
97104
steps:
98-
- uses: actions/checkout@v2
105+
- uses: actions/checkout@v3
99106
with:
100107
fetch-depth: 0
101108

@@ -189,7 +196,7 @@ jobs:
189196
if: github.event.pull_request.head.repo.full_name == github.repository
190197
runs-on: ubuntu-latest
191198
steps:
192-
- uses: actions/checkout@v2
199+
- uses: actions/checkout@v3
193200

194201
- uses: actions/download-artifact@v2
195202
id: download
@@ -218,7 +225,7 @@ jobs:
218225
container: "centos:7"
219226

220227
steps:
221-
- uses: actions/checkout@v2
228+
- uses: actions/checkout@v3
222229

223230
- name: Install Node.js v14
224231
uses: actions/setup-node@v3
@@ -307,7 +314,7 @@ jobs:
307314
NODE_VERSION: v14.17.4
308315

309316
steps:
310-
- uses: actions/checkout@v2
317+
- uses: actions/checkout@v3
311318

312319
- name: Install Node.js v14
313320
uses: actions/setup-node@v3
@@ -356,7 +363,7 @@ jobs:
356363
runs-on: macos-latest
357364
timeout-minutes: 15
358365
steps:
359-
- uses: actions/checkout@v2
366+
- uses: actions/checkout@v3
360367

361368
- name: Install Node.js v14
362369
uses: actions/setup-node@v3
@@ -401,7 +408,7 @@ jobs:
401408
# since VS Code will load faster due to the bundling.
402409
CODE_SERVER_TEST_ENTRY: "./release-packages/code-server-linux-amd64"
403410
steps:
404-
- uses: actions/checkout@v2
411+
- uses: actions/checkout@v3
405412

406413
- name: Install Node.js v14
407414
uses: actions/setup-node@v3
@@ -455,7 +462,7 @@ jobs:
455462
runs-on: ubuntu-20.04
456463
steps:
457464
- name: Checkout code
458-
uses: actions/checkout@v2
465+
uses: actions/checkout@v3
459466
- name: Run Trivy vulnerability scanner in repo mode
460467
#Commit SHA for v0.0.17
461468
uses: aquasecurity/trivy-action@296212627a1e693efa09c00adc3e03b2ba8edf18

.github/workflows/codeql-analysis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ on:
1010
# Runs every Monday morning PST
1111
- cron: "17 15 * * 1"
1212

13+
# Cancel in-progress runs for pull requests when developers push
14+
# additional changes, and serialize builds in branches.
15+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19+
1320
jobs:
1421
analyze:
1522
name: Analyze
1623
runs-on: ubuntu-20.04
1724

1825
steps:
1926
- name: Checkout repository
20-
uses: actions/checkout@v2
27+
uses: actions/checkout@v3
2128

2229
# Initializes the CodeQL tools for scanning.
2330
- name: Initialize CodeQL

.github/workflows/docker.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ on:
99
types:
1010
- released
1111

12+
# Cancel in-progress runs for pull requests when developers push
13+
# additional changes, and serialize builds in branches.
14+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
18+
1219
jobs:
1320
docker-images:
1421
runs-on: ubuntu-20.04
1522
steps:
1623
- name: Checkout
17-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
1825

1926
- name: Set up QEMU
2027
uses: docker/setup-qemu-action@v1

.github/workflows/docs-preview.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ permissions:
1717
security-events: none
1818
statuses: none
1919

20+
# Cancel in-progress runs for pull requests when developers push
21+
# additional changes, and serialize builds in branches.
22+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
26+
2027
jobs:
2128
preview:
2229
name: Docs preview
@@ -30,7 +37,7 @@ jobs:
3037
uses: styfle/cancel-workflow-action@0.9.1
3138

3239
- name: Checkout m
33-
uses: actions/checkout@v2
40+
uses: actions/checkout@v3
3441
with:
3542
repository: coder/m
3643
ref: refs/heads/master

.github/workflows/installer.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ on:
1212
paths:
1313
- "install.sh"
1414

15+
# Cancel in-progress runs for pull requests when developers push
16+
# additional changes, and serialize builds in branches.
17+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
21+
1522
jobs:
1623
ubuntu:
1724
name: Test installer on Ubuntu
1825
runs-on: ubuntu-latest
1926
steps:
2027
- name: Checkout repo
21-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2229

2330
- name: Install code-server
2431
run: ./install.sh
@@ -32,7 +39,7 @@ jobs:
3239
container: "alpine:3.14"
3340
steps:
3441
- name: Checkout repo
35-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
3643

3744
- name: Install curl
3845
run: apk add curl
@@ -50,7 +57,7 @@ jobs:
5057

5158
steps:
5259
- name: Checkout repo
53-
uses: actions/checkout@v2
60+
uses: actions/checkout@v3
5461

5562
- name: Install code-server
5663
run: ./install.sh

.github/workflows/npm-brew.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ on:
88
release:
99
types: [released]
1010

11+
# Cancel in-progress runs for pull requests when developers push
12+
# additional changes, and serialize builds in branches.
13+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17+
1118
jobs:
1219
# NOTE: this job requires curl, jq and yarn
1320
# All of them are included in ubuntu-latest.
1421
npm:
1522
runs-on: ubuntu-latest
1623
steps:
17-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
1825

1926
- uses: actions/download-artifact@v2
2027
id: download
@@ -42,7 +49,7 @@ jobs:
4249
id: set-up-homebrew
4350
uses: Homebrew/actions/setup-homebrew@master
4451

45-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
4653
- name: Configure git
4754
run: |
4855
git config user.name github-actions

.github/workflows/scripts.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ on:
1414
- "**.sh"
1515
- "**.bats"
1616

17+
permissions:
18+
actions: none
19+
checks: none
20+
contents: read
21+
deployments: none
22+
issues: none
23+
packages: none
24+
pull-requests: none
25+
repository-projects: none
26+
security-events: none
27+
statuses: none
28+
29+
# Cancel in-progress runs for pull requests when developers push
30+
# additional changes, and serialize builds in branches.
31+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
32+
concurrency:
33+
group: ${{ github.workflow }}-${{ github.ref }}
34+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
35+
1736
jobs:
1837
test:
1938
name: Run script unit tests
@@ -22,7 +41,7 @@ jobs:
2241
container: "alpine:3.14"
2342
steps:
2443
- name: Checkout repo
25-
uses: actions/checkout@v2
44+
uses: actions/checkout@v3
2645

2746
- name: Install test utilities
2847
run: apk add bats checkbashisms

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"compression": "^1.7.4",
9090
"cookie-parser": "^1.4.5",
9191
"env-paths": "^2.2.0",
92-
"express": "^5.0.0-alpha.8",
92+
"express": "5.0.0-alpha.8",
9393
"http-proxy": "^1.18.0",
9494
"httpolyglot": "^0.1.2",
9595
"js-yaml": "^4.0.0",

src/node/constants.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,35 @@ export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJso
1717
}
1818

1919
const pkg = getPackageJson("../../package.json")
20+
const codePkg = getPackageJson("../../vendor/modules/code-oss-dev/package.json")
2021

2122
export const pkgName = pkg.name || "code-server"
2223
export const version = pkg.version || "development"
2324
export const commit = pkg.commit || "development"
2425
export const rootPath = path.resolve(__dirname, "../..")
2526
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
27+
export const codeVersion = codePkg.version || "development"
2628
export const tmpdir = path.join(os.tmpdir(), "code-server")
2729
export const isDevMode = commit === "development"
2830
export const httpProxyUri =
2931
process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy
32+
33+
/**
34+
* getVersionString returns a human-readable version string suitable
35+
* for outputting to the console.
36+
*/
37+
export function getVersionString(): string {
38+
return [version, commit, "with Code", codeVersion].join(" ")
39+
}
40+
41+
/**
42+
* getVersionJsonString returns a machine-readable version string
43+
* suitable for outputting to the console.
44+
*/
45+
export function getVersionJsonString(): string {
46+
return JSON.stringify({
47+
codeServer: version,
48+
commit,
49+
vscode: codeVersion,
50+
})
51+
}

src/node/entry.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { logger } from "@coder/logger"
22
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
3-
import { commit, version } from "./constants"
3+
import { getVersionString, getVersionJsonString } from "./constants"
44
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
55
import { isChild, wrapper } from "./wrapper"
66

@@ -24,7 +24,7 @@ async function entry(): Promise<void> {
2424
const args = await setDefaults(cliArgs, configArgs)
2525

2626
if (args.help) {
27-
console.log("code-server", version, commit)
27+
console.log("code-server", getVersionString())
2828
console.log("")
2929
console.log(`Usage: code-server [options] [path]`)
3030
console.log(` - Opening a directory: code-server ./path/to/your/project`)
@@ -39,15 +39,9 @@ async function entry(): Promise<void> {
3939

4040
if (args.version) {
4141
if (args.json) {
42-
console.log(
43-
JSON.stringify({
44-
codeServer: version,
45-
commit,
46-
vscode: require("../../vendor/modules/code-oss-dev/package.json").version,
47-
}),
48-
)
42+
console.log(getVersionJsonString())
4943
} else {
50-
console.log(version, commit)
44+
console.log(getVersionString())
5145
}
5246
return
5347
}

src/node/http.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ export const relativeRoot = (originalUrl: string): string => {
138138
return normalize("./" + (depth > 1 ? "../".repeat(depth - 1) : ""))
139139
}
140140

141+
/**
142+
* A helper function to construct a redirect path based on
143+
* an Express Request, query and a path to redirect to.
144+
*
145+
* Redirect path is relative to `/${to}`.
146+
*/
147+
export const constructRedirectPath = (req: express.Request, query: qs.ParsedQs, to: string): string => {
148+
const relativePath = normalize(`${relativeRoot(req.originalUrl)}/${to}`, true)
149+
// %2f or %2F are both equalivent to an encoded slash /
150+
const queryString = qs.stringify(query).replace(/%2[fF]/g, "/")
151+
const redirectPath = `${relativePath}${queryString ? `?${queryString}` : ""}`
152+
153+
return redirectPath
154+
}
155+
141156
/**
142157
* Redirect relatively to `/${to}`. Query variables on the current URI will be
143158
* preserved. `to` should be a simple path without any query parameters
@@ -156,9 +171,7 @@ export const redirect = (
156171
}
157172
})
158173

159-
const relativePath = normalize(`${relativeRoot(req.originalUrl)}/${to}`, true)
160-
const queryString = qs.stringify(query)
161-
const redirectPath = `${relativePath}${queryString ? `?${queryString}` : ""}`
174+
const redirectPath = constructRedirectPath(req, query, to)
162175
logger.debug(`redirecting from ${req.originalUrl} to ${redirectPath}`)
163176
res.redirect(redirectPath)
164177
}
@@ -196,7 +209,7 @@ export const getCookieDomain = (host: string, proxyDomains: string[]): string |
196209
// default NGINX does this).
197210
!host.includes(".")
198211
) {
199-
logger.debug("no valid cookie doman", field("host", host))
212+
logger.debug("no valid cookie domain", field("host", host))
200213
return undefined
201214
}
202215

@@ -206,7 +219,7 @@ export const getCookieDomain = (host: string, proxyDomains: string[]): string |
206219
}
207220
})
208221

209-
logger.debug("got cookie doman", field("host", host))
222+
logger.debug("got cookie domain", field("host", host))
210223
return host || undefined
211224
}
212225

0 commit comments

Comments
 (0)