mirror of
https://github.com/coder/code-server.git
synced 2026-11-22 18:58:30 +08:00
* Stop generating shrinkwraps npm 12 removes support for shrinkwraps. Additionally, VS Code has switched to pnpm and this will make generating the shrinkwraps less straightforward. Exact pins in the package.json would not be a sufficient replacement since that does not cover transitive dependencies. The recommendation for end user packages installed globally with npm seems to be to be to bundle dependencies. One idea would be to build for every platform and bundle them all, but the whole reason we have the npm package is to support platforms for which we are not building. If we build them, we could just add a regular release for that platform on GitHub. So instead for each native module we would need to add rebuild commands in the postinstall. And ideally remove the current platform builds to at least try keeping the tarball size down. I am not sure it is worth the effort for what it feels like fighting with npm, so this change does not attempt that. * Remove devDependencies from extensions package.json Not strictly necessary since we only install production dependencies in the postinstall, but might as well save some bytes. * Update Code to 1.146.0 * Support pnpm for post-install * Get Node version from package.json lib/vscode/remote/.npmrc no longer exists * Switch to pnpm VS Code recently switched to pnpm so various scripts needed to be updated, and we might as well follow suite with code-server's own dependencies. In general this change just swaps out "npm" invocations for "pnpm" plus any necessary flag changes to match but to call out some less obvious changes: 1. The extensions directory no longer has a post-install script, so there is no need to copy one anymore. 2. When merging the remote package.json, only copy the dependencies since that is all we need, to avoid copying in new properties like packageManager. 3. Remove unused publish:npm. It points to a nonexistent file anyway. 4. Remove publish:docker and just call the script directly, to avoid an npm/pnpm dependency in a job that really has no need for it. * Update nfpm maintainer
320 lines
12 KiB
YAML
320 lines
12 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
# Cancel in-progress runs for pull requests when developers push
|
|
# additional changes, and serialize builds in branches.
|
|
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
ci: ${{ steps.filter.outputs.ci }}
|
|
code: ${{ steps.filter.outputs.code }}
|
|
npm: ${{ steps.filter.outputs.npm }}
|
|
vscode: ${{ steps.filter.outputs.vscode }}
|
|
docs: ${{ steps.filter.outputs.docs }}
|
|
helm: ${{ steps.filter.outputs.helm }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
ci:
|
|
- ".github/**"
|
|
- "ci/**"
|
|
docs:
|
|
- "docs/**"
|
|
- "README.md"
|
|
- "CHANGELOG.md"
|
|
helm:
|
|
- "ci/helm-chart/**"
|
|
code:
|
|
- "src/**"
|
|
- "test/**"
|
|
npm:
|
|
- "pnpm-lock.yaml"
|
|
- "test/pnpm-lock.yaml"
|
|
vscode:
|
|
- "lib/**"
|
|
- "patches/**"
|
|
- id: debug
|
|
run: |
|
|
echo "${{ toJSON(steps.filter )}}"
|
|
|
|
prettier:
|
|
name: Run prettier check
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- run: pnpm exec prettier --check .
|
|
|
|
doctoc:
|
|
name: Doctoc markdown files
|
|
runs-on: ubuntu-22.04
|
|
needs: changes
|
|
if: needs.changes.outputs.docs == 'true'
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- run: pnpm run doctoc
|
|
|
|
lint-helm:
|
|
name: Lint Helm chart
|
|
runs-on: ubuntu-22.04
|
|
needs: changes
|
|
if: needs.changes.outputs.helm == 'true'
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
version: "v3.19.2"
|
|
- uses: bmuschko/setup-kubeconform@e5d264ec1eafe2314e750c429a9da7639dd5a003 # v1.1.0
|
|
with:
|
|
kubeconform-version: "0.8.0"
|
|
- run: helm template ci/helm-chart | kubeconform -strict -summary -
|
|
shell: bash # Setting shell:bash makes GitHub add `-o pipefail`.
|
|
|
|
lint-ts:
|
|
name: Lint TypeScript files
|
|
runs-on: ubuntu-22.04
|
|
needs: changes
|
|
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.ci == 'true' || needs.changes.outputs.npm == 'true'
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- run: pnpm run lint:ts
|
|
|
|
lint-actions:
|
|
name: Lint GitHub Actions
|
|
runs-on: ubuntu-latest
|
|
needs: changes
|
|
if: needs.changes.outputs.ci == 'true'
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- name: Check workflow files
|
|
run: |
|
|
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.7.9
|
|
./actionlint -color -shellcheck= -ignore "softprops/action-gh-release"
|
|
shell: bash
|
|
|
|
test-unit:
|
|
name: Run unit tests
|
|
runs-on: ubuntu-22.04
|
|
needs: changes
|
|
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.npm == 'true'
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- run: pnpm run test:unit
|
|
|
|
build:
|
|
name: linux-x64
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
DISABLE_V8_COMPILE_CACHE: 1
|
|
VERSION: 0.0.0
|
|
VSCODE_ARCH: x64
|
|
VSCODE_TARGET: linux-x64
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
|
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
|
|
|
steps:
|
|
- run: sudo apt update && sudo apt install -y libkrb5-dev
|
|
- uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # latest
|
|
with:
|
|
packages: quilt
|
|
version: 1.0
|
|
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
with:
|
|
submodules: true
|
|
- run: quilt push -a
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
|
|
# Get Code's git hash. When this changes it means the content is
|
|
# different and we need to rebuild.
|
|
- name: Get latest lib/vscode rev
|
|
id: vscode-rev
|
|
run: echo "rev=$(git rev-parse HEAD:./lib/vscode)" >> $GITHUB_OUTPUT
|
|
|
|
# We need to rebuild when we have a new version of Code, when any of the
|
|
# patches changed, or when the code-server version changes (since it gets
|
|
# embedded into the code). Use VSCODE_CACHE_VERSION to force a rebuild.
|
|
- name: Fetch prebuilt linux-x64 Code package from cache
|
|
id: cache-vscode
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
path: lib/vscode-reh-web-linux-x64
|
|
key: vscode-linux-x64-package-${{ vars.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
|
|
- name: Build vscode
|
|
if: steps.cache-vscode.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd lib/vscode/build
|
|
pnpm install --frozen-lockfile
|
|
cd ..
|
|
source ./build/azure-pipelines/linux/setup-env.sh
|
|
# Run preinstall script before root dependencies are installed
|
|
# so that v8 headers are patched correctly for native modules.
|
|
pnpm run preinstall
|
|
pnpm install --frozen-lockfile
|
|
cd ../..
|
|
pnpm run build:vscode
|
|
|
|
# Build the code-server wrapper.
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- run: pnpm run build
|
|
|
|
# Push up an artifact containing the linux-x64 release.
|
|
- run: KEEP_MODULES=1 pnpm run release
|
|
- run: tar -czf package.tar.gz release
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: linux-x64-package
|
|
path: ./package.tar.gz
|
|
|
|
test-e2e:
|
|
name: Run e2e tests
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
LOG_LEVEL: debug
|
|
needs: [changes, build]
|
|
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.npm == 'true' || needs.changes.outputs.vscode == 'true' || needs.changes.outputs.ci == 'true'
|
|
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- name: Install Playwright OS dependencies
|
|
run: |
|
|
./test/node_modules/.bin/playwright install-deps
|
|
./test/node_modules/.bin/playwright install
|
|
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
with:
|
|
name: linux-x64-package
|
|
- run: tar -xzf package.tar.gz
|
|
|
|
- run: CODE_SERVER_TEST_ENTRY=./release pnpm run test:e2e
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
if: always()
|
|
with:
|
|
name: failed-test-videos
|
|
path: ./test/test-results
|
|
|
|
test-e2e-proxy:
|
|
name: Run e2e tests behind proxy
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
LOG_LEVEL: debug
|
|
needs: [changes, build]
|
|
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.npm == 'true' || needs.changes.outputs.vscode == 'true' || needs.changes.outputs.ci == 'true'
|
|
|
|
steps:
|
|
- name: Cache Caddy
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
id: caddy-cache
|
|
with:
|
|
path: |
|
|
~/.cache/caddy
|
|
key: cache-caddy-2.5.2
|
|
- name: Install Caddy
|
|
if: steps.caddy-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
gh release download v2.5.2 --repo caddyserver/caddy --pattern "caddy_2.5.2_linux_amd64.tar.gz"
|
|
mkdir -p ~/.cache/caddy
|
|
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy
|
|
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
test/pnpm-lock.yaml
|
|
- run: SKIP_SUBMODULE_DEPS=1 pnpm install --frozen-lockfile
|
|
- name: Install Playwright OS dependencies
|
|
run: |
|
|
./test/node_modules/.bin/playwright install-deps
|
|
./test/node_modules/.bin/playwright install
|
|
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
|
|
with:
|
|
name: linux-x64-package
|
|
- run: tar -xzf package.tar.gz
|
|
|
|
- run: ~/.cache/caddy/caddy start --config ./ci/Caddyfile
|
|
- run: CODE_SERVER_TEST_ENTRY=./release pnpm run test:e2e:proxy
|
|
- run: ~/.cache/caddy/caddy stop --config ./ci/Caddyfile
|
|
if: always()
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
if: always()
|
|
with:
|
|
name: failed-test-videos-proxy
|
|
path: ./test/test-results
|