Skip to content

Commit d9d7a5e

Browse files
committed
feat(ci): add test-e2e-proxy job
This adds a new job to CI to run our tests behind Caddy and simulate code-server running against a reverse-proxy.
1 parent 64f39e2 commit d9d7a5e

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

.github/workflows/ci.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,93 @@ jobs:
510510
- name: Remove release packages and test artifacts
511511
run: rm -rf ./release-packages ./test/test-results
512512

513+
test-e2e-proxy:
514+
name: End-to-end tests behind proxy
515+
needs: package-linux-amd64
516+
runs-on: ubuntu-latest
517+
timeout-minutes: 25
518+
env:
519+
# Since we build code-server we might as well run tests from the release
520+
# since VS Code will load faster due to the bundling.
521+
CODE_SERVER_TEST_ENTRY: "./release-packages/code-server-linux-amd64"
522+
steps:
523+
- name: Checkout repo
524+
uses: actions/checkout@v3
525+
with:
526+
fetch-depth: 0
527+
528+
- name: Install Node.js v16
529+
uses: actions/setup-node@v3
530+
with:
531+
node-version: "16"
532+
533+
- name: Fetch dependencies from cache
534+
id: cache-yarn
535+
uses: actions/cache@v3
536+
with:
537+
path: "**/node_modules"
538+
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
539+
restore-keys: |
540+
yarn-build-
541+
542+
- name: Download release packages
543+
uses: actions/download-artifact@v3
544+
with:
545+
name: release-packages
546+
path: ./release-packages
547+
548+
- name: Untar code-server release
549+
run: |
550+
cd release-packages
551+
tar -xzf code-server*-linux-amd64.tar.gz
552+
mv code-server*-linux-amd64 code-server-linux-amd64
553+
554+
- name: Install dependencies
555+
if: steps.cache-yarn.outputs.cache-hit != 'true'
556+
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
557+
558+
- name: Install Playwright OS dependencies
559+
run: |
560+
./test/node_modules/.bin/playwright install-deps
561+
./test/node_modules/.bin/playwright install
562+
563+
- name: Cache Caddy
564+
uses: actions/cache@v2
565+
id: caddy-cache
566+
with:
567+
path: |
568+
~/.cache/caddy
569+
key: cache-caddy-2.5.2
570+
571+
- name: Install Caddy
572+
env:
573+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
574+
if: steps.caddy-cache.outputs.cache-hit != 'true'
575+
run: |
576+
gh release download v2.5.2 --repo caddyserver/caddy --pattern "caddy_2.5.2_linux_amd64.tar.gz"
577+
mkdir -p ~/.cache/caddy
578+
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy
579+
580+
- name: Start Caddy
581+
run: sudo ~/.cache/caddy/caddy start --config ./ci/Caddyfile
582+
583+
- name: Run end-to-end tests
584+
run: yarn test:e2e:proxy
585+
586+
- name: Stop Caddy
587+
if: always()
588+
run: sudo ~/.cache/caddy/caddy stop --config ./ci/Caddyfile
589+
590+
- name: Upload test artifacts
591+
if: always()
592+
uses: actions/upload-artifact@v3
593+
with:
594+
name: failed-test-videos-proxy
595+
path: ./test/test-results
596+
597+
- name: Remove release packages and test artifacts
598+
run: rm -rf ./release-packages ./test/test-results
599+
513600
trivy-scan-repo:
514601
permissions:
515602
contents: read # for actions/checkout to fetch code

ci/Caddyfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
admin localhost:4444
3+
}
4+
:8000 {
5+
@portLocalhost path_regexp port ^/([0-9]+)\/ide
6+
handle @portLocalhost {
7+
uri strip_prefix {re.port.1}/ide
8+
reverse_proxy localhost:{re.port.1}
9+
}
10+
11+
handle {
12+
respond "Bad hostname" 400
13+
}
14+
15+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"release:github-assets": "./ci/build/release-github-assets.sh",
1919
"release:prep": "./ci/build/release-prep.sh",
2020
"test:e2e": "VSCODE_IPC_HOOK_CLI= ./ci/dev/test-e2e.sh",
21+
"test:e2e:proxy": "USE_PROXY=1 ./ci/dev/test-e2e.sh",
2122
"test:unit": "./ci/dev/test-unit.sh --forceExit --detectOpenHandles",
2223
"test:integration": "./ci/dev/test-integration.sh",
2324
"test:scripts": "./ci/dev/test-scripts.sh",

0 commit comments

Comments
 (0)