-
Notifications
You must be signed in to change notification settings - Fork 5.9k
chore: move Code to a submodule #4990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
98053a0
Move Code to a submodule
code-asher 7ebf071
Base Code cache on hash and re-enable node_modules cache
code-asher 6ba19d2
fixup! Move Code to a submodule
code-asher 4233ca7
Prevent infinite install loop
code-asher 286cb34
Run fmt and lint
code-asher da70f66
fixup! Move Code to a submodule
code-asher c7b157c
fixup! Move Code to a submodule
code-asher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ jobs: | |
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -38,21 +41,17 @@ jobs: | |
- name: Install helm | ||
uses: azure/[email protected] | ||
|
||
# NOTE@jsjoeio | ||
# disabling this until we can audit the build process | ||
# and the usefulness of this step | ||
# See: https://github.com/coder/code-server/issues/4287 | ||
# - name: Fetch dependencies from cache | ||
# id: cache-yarn | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: "**/node_modules" | ||
# key: yarn-build-${{ hashFiles('**/yarn.lock') }} | ||
# restore-keys: | | ||
# yarn-build- | ||
- name: Fetch dependencies from cache | ||
id: cache-yarn | ||
uses: actions/cache@v2 | ||
with: | ||
path: "**/node_modules" | ||
key: yarn-build-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
yarn-build- | ||
|
||
- name: Install dependencies | ||
# if: steps.cache-yarn.outputs.cache-hit != 'true' | ||
if: steps.cache-yarn.outputs.cache-hit != 'true' | ||
run: yarn --frozen-lockfile | ||
|
||
- name: Run yarn fmt | ||
|
@@ -71,6 +70,9 @@ jobs: | |
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -102,56 +104,49 @@ jobs: | |
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "14" | ||
|
||
# TODO@Teffen investigate why this omits code-oss-dev/node_modules | ||
# - name: Fetch dependencies from cache | ||
# id: cache-yarn | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: | | ||
# "**/node_modules" | ||
# "**/vendor/modules" | ||
# "**/vendor/modules/code-oss-dev/node_modules" | ||
# key: yarn-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/vendor/yarn.lock') }} | ||
# restore-keys: | | ||
# yarn-build- | ||
- name: Fetch dependencies from cache | ||
id: cache-yarn | ||
uses: actions/cache@v2 | ||
with: | ||
path: "**/node_modules" | ||
key: yarn-build-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
yarn-build- | ||
|
||
- name: Install dependencies | ||
# if: steps.cache-yarn.outputs.cache-hit != 'true' | ||
if: steps.cache-yarn.outputs.cache-hit != 'true' | ||
run: yarn --frozen-lockfile | ||
|
||
- name: Build code-server | ||
run: yarn build | ||
|
||
# Parse the hash of the latest commit inside vendor/modules/code-oss-dev | ||
# use this to avoid rebuilding it if nothing changed | ||
# How it works: the `git log` command fetches the hash of the last commit | ||
# that changed a file inside `vendor/modules/code-oss-dev`. If a commit changes any file in there, | ||
# the hash returned will change, and we rebuild vscode. If the hash did not change, | ||
# (for example, a change to `src/` or `docs/`), we reuse the same build as last time. | ||
# This saves a lot of time in CI, as compiling VSCode can take anywhere from 5-10 minutes. | ||
- name: Get latest vendor/modules/code-oss-dev rev | ||
# Get Code's git hash. When this changes it means the content is | ||
# different and we need to rebuild. Use VSCODE_CACHE_VERSION to force a | ||
# rebuild. | ||
- name: Get latest lib/vscode rev | ||
id: vscode-rev | ||
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' vendor/package.json | sed -r 's|.*#(.*)$|\1|')" | ||
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)" | ||
|
||
- name: Attempt to fetch vscode build from cache | ||
- name: Fetch Code build from cache | ||
id: cache-vscode-2 | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
vendor/modules/code-oss-dev/.build | ||
vendor/modules/code-oss-dev/package.json | ||
vendor/modules/code-oss-dev/out-build | ||
vendor/modules/code-oss-dev/out-vscode-reh-web | ||
vendor/modules/code-oss-dev/out-vscode-reh-web-min | ||
lib/vscode/.build | ||
lib/vscode/out-build | ||
lib/vscode/out-vscode-reh-web | ||
lib/vscode/out-vscode-reh-web-min | ||
key: vscode-reh-build-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }} | ||
|
||
- name: Build vscode | ||
|
@@ -197,7 +192,11 @@ jobs: | |
if: github.event.pull_request.head.repo.full_name == github.repository | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- uses: actions/download-artifact@v3 | ||
id: download | ||
|
@@ -226,7 +225,11 @@ jobs: | |
container: "centos:7" | ||
|
||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -315,7 +318,11 @@ jobs: | |
NODE_VERSION: v14.17.4 | ||
|
||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -364,7 +371,11 @@ jobs: | |
runs-on: macos-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -409,7 +420,11 @@ jobs: | |
# since VS Code will load faster due to the bundling. | ||
CODE_SERVER_TEST_ENTRY: "./release-packages/code-server-linux-amd64" | ||
steps: | ||
- name: Checkout repo | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Install Node.js v14 | ||
uses: actions/setup-node@v3 | ||
|
@@ -446,12 +461,6 @@ jobs: | |
./test/node_modules/.bin/playwright install-deps | ||
./test/node_modules/.bin/playwright install | ||
|
||
# TODO@jsjoeio - remove once we switch to submodules. | ||
- name: Create package.json for testing | ||
run: | | ||
mkdir -p ./vendor/modules/code-oss-dev | ||
echo '{ "version": "test" }' > ./vendor/modules/code-oss-dev/package.json | ||
|
||
- name: Run end-to-end tests | ||
run: yarn test:e2e | ||
|
||
|
@@ -470,6 +479,10 @@ jobs: | |
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Run Trivy vulnerability scanner in repo mode | ||
uses: aquasecurity/trivy-action@296212627a1e693efa09c00adc3e03b2ba8edf18 | ||
with: | ||
|
@@ -480,6 +493,7 @@ jobs: | |
template: "@/contrib/sarif.tpl" | ||
output: "trivy-repo-results.sarif" | ||
severity: "HIGH,CRITICAL" | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v1 | ||
with: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/vscode"] | ||
path = lib/vscode | ||
url = https://github.com/coder/vscode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
main() { | ||
cd "$(dirname "$0")/../.." | ||
source ./ci/lib.sh | ||
|
||
pushd test | ||
echo "Installing dependencies for $PWD" | ||
yarn install | ||
popd | ||
|
||
# Install dependencies in $1. | ||
install-deps() { | ||
local args=(install) | ||
if [[ ${CI-} ]]; then | ||
args+=(--frozen-lockfile) | ||
fi | ||
|
||
pushd test | ||
echo "Installing dependencies for $PWD" | ||
yarn "${args[@]}" | ||
popd | ||
|
||
pushd test/e2e/extensions/test-extension | ||
echo "Installing dependencies for $PWD" | ||
yarn "${args[@]}" | ||
pushd "$1" | ||
echo "Installing dependencies for $PWD" | ||
yarn "${args[@]}" | ||
popd | ||
} | ||
|
||
pushd vendor | ||
echo "Installing dependencies for $PWD" | ||
|
||
# We install in 'modules' instead of 'node_modules' because VS Code's | ||
# extensions use a webpack config which cannot differentiate between its own | ||
# node_modules and itself being in a directory with the same name. | ||
args+=(--modules-folder modules) | ||
|
||
# We ignore scripts because NPM/Yarn's default behavior is to assume that | ||
# devDependencies are not needed, and that even git repo based packages are | ||
# assumed to be compiled. Because the default behavior for VS Code's | ||
# `postinstall` assumes we're also compiled, this needs to be ignored. | ||
args+=(--ignore-scripts) | ||
|
||
yarn "${args[@]}" | ||
|
||
# Finally, run the vendor `postinstall` | ||
yarn run postinstall | ||
main() { | ||
cd "$(dirname "$0")/../.." | ||
source ./ci/lib.sh | ||
|
||
popd | ||
install-deps test | ||
install-deps test/e2e/extensions/test-extension | ||
install-deps lib/vscode | ||
jsjoeio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
main "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me again, we don't need this anymore because it's no longer cached or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think the problem was that we cache
node_modules
and then restore that cache. But Code is undervendor/modules
so it did not get restored. Then we tried to readpackage.json
from it.Now that this uses a submodule and we have
submodules: true
in the checkout stage Code will be cloned as part of the checkout phase andpackage.json
will exist.