Skip to content

Commit 7ebf071

Browse files
committed
Base Code cache on hash and re-enable node_modules cache
The current setup appears to only rebuild VS Code if the dependencies change but we need to rebuild it if anything changes. I also re-enabled the commented out node_modules caches. They look like they should work to me with the submodule method. I think the problem occurred because Code itself was being installed in the yarn step.
1 parent 98053a0 commit 7ebf071

File tree

1 file changed

+23
-35
lines changed

1 file changed

+23
-35
lines changed

.github/workflows/ci.yaml

+23-35
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,17 @@ jobs:
4141
- name: Install helm
4242
uses: azure/[email protected]
4343

44-
# NOTE@jsjoeio
45-
# disabling this until we can audit the build process
46-
# and the usefulness of this step
47-
# See: https://github.com/coder/code-server/issues/4287
48-
# - name: Fetch dependencies from cache
49-
# id: cache-yarn
50-
# uses: actions/cache@v2
51-
# with:
52-
# path: "**/node_modules"
53-
# key: yarn-build-${{ hashFiles('**/yarn.lock') }}
54-
# restore-keys: |
55-
# yarn-build-
44+
- name: Fetch dependencies from cache
45+
id: cache-yarn
46+
uses: actions/cache@v2
47+
with:
48+
path: "**/node_modules"
49+
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
50+
restore-keys: |
51+
yarn-build-
5652
5753
- name: Install dependencies
58-
# if: steps.cache-yarn.outputs.cache-hit != 'true'
54+
if: steps.cache-yarn.outputs.cache-hit != 'true'
5955
run: yarn --frozen-lockfile
6056

6157
- name: Run yarn fmt
@@ -119,38 +115,30 @@ jobs:
119115
with:
120116
node-version: "14"
121117

122-
# TODO@Teffen investigate why this omits code-oss-dev/node_modules
123-
# - name: Fetch dependencies from cache
124-
# id: cache-yarn
125-
# uses: actions/cache@v2
126-
# with:
127-
# path: |
128-
# "**/node_modules"
129-
# "**/vendor/modules"
130-
# "**/lib/vscode/node_modules"
131-
# key: yarn-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/vendor/yarn.lock') }}
132-
# restore-keys: |
133-
# yarn-build-
118+
- name: Fetch dependencies from cache
119+
id: cache-yarn
120+
uses: actions/cache@v2
121+
with:
122+
path: "**/node_modules"
123+
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
124+
restore-keys: |
125+
yarn-build-
134126
135127
- name: Install dependencies
136-
# if: steps.cache-yarn.outputs.cache-hit != 'true'
128+
if: steps.cache-yarn.outputs.cache-hit != 'true'
137129
run: yarn --frozen-lockfile
138130

139131
- name: Build code-server
140132
run: yarn build
141133

142-
# Parse the hash of the latest commit inside lib/vscode
143-
# use this to avoid rebuilding it if nothing changed
144-
# How it works: the `git log` command fetches the hash of the last commit
145-
# that changed a file inside `lib/vscode`. If a commit changes any file in there,
146-
# the hash returned will change, and we rebuild vscode. If the hash did not change,
147-
# (for example, a change to `src/` or `docs/`), we reuse the same build as last time.
148-
# This saves a lot of time in CI, as compiling VSCode can take anywhere from 5-10 minutes.
134+
# Get Code's git hash. When this changes it means the content is
135+
# different and we need to rebuild. Use VSCODE_CACHE_VERSION to force a
136+
# rebuild.
149137
- name: Get latest lib/vscode rev
150138
id: vscode-rev
151-
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' lib/vscode/package.json | sed -r 's|.*#(.*)$|\1|')"
139+
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)"
152140

153-
- name: Attempt to fetch vscode build from cache
141+
- name: Fetch Code build from cache
154142
id: cache-vscode-2
155143
uses: actions/cache@v2
156144
with:

0 commit comments

Comments
 (0)