Skip to content

Commit

Permalink
Switch fully to npm
Browse files Browse the repository at this point in the history
This is to match VS Code.  We were already partially using npm for the
releases so this is some nice alignment.
  • Loading branch information
code-asher committed Oct 5, 2024
1 parent 1b237fa commit 24905b4
Show file tree
Hide file tree
Showing 37 changed files with 11,880 additions and 7,172 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ body:
id: logs
attributes:
label: Logs
description: Run code-server with the --verbose flag and then paste any relevant logs from the server, from the browser console and/or the browser network tab. For issues with installation, include installation logs (i.e. output of `yarn global add code-server`).
description: Run code-server with the --verbose flag and then paste any relevant logs from the server, from the browser console and/or the browser network tab. For issues with installation, include installation logs (i.e. output of `npm install -g code-server`).
render: shell

- type: textarea
Expand Down
17 changes: 0 additions & 17 deletions .github/PULL_REQUEST_TEMPLATE/release_template.md

This file was deleted.

165 changes: 59 additions & 106 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
# this ensures that it only executes if all previous jobs succeeded.

# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# will skip running `yarn install` if it successfully fetched from cache
# will skip running `npm install` if it successfully fetched from cache

jobs:
prettier:
Expand Down Expand Up @@ -55,14 +55,16 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: "yarn"
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Install doctoc
run: yarn global add doctoc@2.2.1
- if: steps.changed-files.outputs.any_changed == 'true'
run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Run doctoc
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn doctoc
- if: steps.changed-files.outputs.any_changed == 'true'
run: npm run doctoc

lint-helm:
name: Lint Helm chart
Expand All @@ -87,12 +89,10 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install helm kubeval plugin
if: steps.changed-files.outputs.any_changed == 'true'
- if: steps.changed-files.outputs.any_changed == 'true'
run: helm plugin install https://github.com/instrumenta/helm-kubeval

- name: Lint Helm chart
if: steps.changed-files.outputs.any_changed == 'true'
- if: steps.changed-files.outputs.any_changed == 'true'
run: helm kubeval ci/helm-chart

lint-ts:
Expand Down Expand Up @@ -120,24 +120,17 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Fetch dependencies from cache
if: steps.changed-files.outputs.any_changed == 'true'
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true' && steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
- if: steps.changed-files.outputs.any_changed == 'true'
run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Lint TypeScript files
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn lint:ts
run: npm run lint:ts

lint-actions:
name: Lint GitHub Actions
Expand Down Expand Up @@ -175,24 +168,16 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Fetch dependencies from cache
if: steps.changed-files.outputs.any_changed == 'true'
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-
- name: if: steps.changed-files.outputs.any_changed == 'true'
run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true' && steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile

- name: Run unit tests
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn test:unit
- if: steps.changed-files.outputs.any_changed == 'true'
run: npm run test:unit

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
Expand Down Expand Up @@ -229,24 +214,16 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: yarn-build-code-server-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-code-server-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile
- run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Build code-server
env:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn build
run: npm run build

# Get Code's git hash. When this changes it means the content is
# different and we need to rebuild.
Expand All @@ -269,17 +246,19 @@ jobs:
env:
VERSION: "0.0.0"
if: steps.cache-vscode.outputs.cache-hit != 'true'
run: yarn build:vscode
run: |
pushd lib/vscode
npm ci
popd
npm run build:vscode
# The release package does not contain any native modules
# and is neutral to architecture/os/libc version.
- name: Create release package
run: yarn release
- run: npm run release
if: success()

# https://github.com/actions/upload-artifact/issues/38
- name: Compress release package
run: tar -czf package.tar.gz release
- run: tar -czf package.tar.gz release

- name: Upload npm package artifact
uses: actions/upload-artifact@v4
Expand All @@ -303,38 +282,28 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-
- run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Download npm package
uses: actions/download-artifact@v4
with:
name: npm-package

- name: Decompress npm package
run: tar -xzf package.tar.gz
- run: tar -xzf package.tar.gz

- name: Install release package dependencies
run: cd release && npm install --unsafe-perm --omit=dev

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
- run: cd release && npm install --unsafe-perm --omit=dev

- name: Install Playwright OS dependencies
run: |
./test/node_modules/.bin/playwright install-deps
./test/node_modules/.bin/playwright install
- name: Run end-to-end tests
run: CODE_SERVER_TEST_ENTRY=./release yarn test:e2e
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e

- name: Upload test artifacts
if: always()
Expand Down Expand Up @@ -362,30 +331,21 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache-dependency-path: |
package-lock.json
test/package-lock.json
- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-
- run: SKIP_SUBMODULE_DEPS=1 npm ci

- name: Download npm package
uses: actions/download-artifact@v4
with:
name: npm-package

- name: Decompress npm package
run: tar -xzf package.tar.gz
- run: tar -xzf package.tar.gz

- name: Install release package dependencies
run: cd release && npm install --unsafe-perm --omit=dev

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
- run: cd release && npm install --unsafe-perm --omit=dev

- name: Install Playwright OS dependencies
run: |
Expand All @@ -409,22 +369,15 @@ jobs:
mkdir -p ~/.cache/caddy
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy
- name: Start Caddy
run: sudo ~/.cache/caddy/caddy start --config ./ci/Caddyfile
- run: sudo ~/.cache/caddy/caddy start --config ./ci/Caddyfile

- name: Run end-to-end tests
run: CODE_SERVER_TEST_ENTRY=./release yarn test:e2e:proxy --global-timeout 840000
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e:proxy --global-timeout 840000

- name: Stop Caddy
if: always()
- if: always()
run: sudo ~/.cache/caddy/caddy stop --config ./ci/Caddyfile

- name: Upload test artifacts
if: always()
- if: always()
uses: actions/upload-artifact@v4
with:
name: failed-test-videos-proxy
path: ./test/test-results

- name: Remove release packages and test artifacts
run: rm -rf ./release ./test/test-results
19 changes: 6 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
# NOTE: this job requires curl, jq and yarn
# All of them are included in ubuntu-latest.
npm:
runs-on: ubuntu-latest
steps:
Expand All @@ -33,7 +31,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: "yarn"

- name: Download npm package from release artifacts
uses: robinraju/release-downloader@v1.11
Expand All @@ -43,15 +40,13 @@ jobs:
fileName: "package.tar.gz"
out-file-path: "release-npm-package"

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
# Strip out the v (v4.9.1 -> 4.9.1).
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Publish npm package and tag with "latest"
run: yarn publish:npm
- run: npm run publish:npm
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -77,8 +72,7 @@ jobs:
git config --global user.name cdrci
git config --global user.email opensource@coder.com
# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
# Strip out the v (v4.9.1 -> 4.9.1).
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
Expand Down Expand Up @@ -124,8 +118,7 @@ jobs:
git config --global user.name cdrci
git config --global user.email opensource@coder.com
# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
# Strip out the v (v4.9.1 -> 4.9.1).
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
Expand All @@ -151,6 +144,7 @@ jobs:
git commit -m "chore: updating version to ${{ env.VERSION }}"
git push -u origin $(git branch --show)
gh pr create --repo coder/code-server-aur --title "chore: bump version to ${{ env.VERSION }}" --body "PR opened by @$GITHUB_ACTOR" --assignee $GITHUB_ACTOR
docker:
runs-on: ubuntu-20.04
steps:
Expand All @@ -176,8 +170,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# NOTE@jsjoeio - we do this so we can strip out the v
# i.e. v4.9.1 -> 4.9.1
# Strip out the v (v4.9.1 -> 4.9.1).
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
Expand Down
Loading

0 comments on commit 24905b4

Please sign in to comment.