Skip to content

Commit 633c7c3

Browse files
committed
Use npm 8 in CI (to allow overriding dep versions)
This requires some fixes, including: - Updates to support the new base image, which otherwise has some issues with npm permissions in this case. - Tweaks to the release build process to ensure that the prepare script keeps working correctly with the different lifecycle behaviour. - Pinning prebuild-install to v7, because v5 (used by some deps) doesn't support the env vars for cross-platform builds with npm v7+. Regarding the base image: previously, the image had a default root user, so the checkout was made as root, but GHA always runs run steps as user 1001. After updating npm, it started to fail to install due to permissions issues, because it was running as user 1001 while the checkout was made as root. The base image has now been updated to default to a 1001 user called 'build-user' who has passwordless sudo & docker permissions. With a few small changes here, we can support that and everything should work correctly with a single consistent user used in every step.
1 parent be8a807 commit 633c7c3

File tree

4 files changed

+159
-167
lines changed

4 files changed

+159
-167
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
name: Build & test
88
runs-on: ubuntu-18.04
99
container:
10-
image: httptoolkit/act-build-base
10+
image: httptoolkit/act-build-base:v2.0.0
1111
options: "--privileged" # Required for DIND tests
1212
env:
1313
DIND_HOST: unix:///tmp/docker.sock
@@ -18,6 +18,8 @@ jobs:
1818
with:
1919
node-version: 14.18.3
2020

21+
- run: npm install -g npm@^8
22+
2123
- name: Set up JDK 11 for Java testing
2224
uses: actions/setup-java@v1
2325
with:
@@ -31,20 +33,20 @@ jobs:
3133

3234
- name: Prepare test environment
3335
run: |
34-
apt-get update
35-
apt-get install p7zip-full xterm
36+
sudo apt-get update
37+
sudo apt-get install p7zip-full xterm
3638
3739
wget https://downloads.slack-edge.com/linux_releases/slack-desktop-4.12.2-amd64.deb
38-
apt install ./slack-desktop-4.12.2-amd64.deb
40+
sudo apt install ./slack-desktop-4.12.2-amd64.deb
3941
40-
cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/google-chrome
41-
cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/slack
42+
sudo cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/google-chrome
43+
sudo cp test/no-sandbox-docker-wrapper.sh /usr/local/bin/slack
4244
4345
# Fix $HOME perms to make Firefox happy
44-
chown $(whoami) $HOME
46+
sudo chown $(whoami) $HOME
4547
4648
# Start a DIND docker host, running in the background
47-
dockerd -H $DIND_HOST &
49+
sudo dockerd -H $DIND_HOST &
4850
sleep 5
4951
5052
# Pre-pull lots of the Docker images we'll want to use later

pack.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ const spawn = (command: string, args: string[] = [], options: SpawnOptions = {})
2020
});
2121
}
2222

23+
/**
24+
* The process here is that we create a clone of the whole codebase, but keeping the latest
25+
* build output, and make a couple of small modifications to manage the build process, and then
26+
* we handle off to Oclif to rebuild once for each target operating system.
27+
*
28+
* Oclif will run "npm pack", then "npm unpack" into a temp directory, "npm install" there, inject
29+
* the appropriate scripts & node binaries to make everything work nicely, and then bundled us up
30+
* a nice tarball ready for deployment.
31+
*/
2332
const packageApp = async () => {
2433
console.log('Preparing packaging directory');
2534
await fs.emptyDir(OUTPUT_DIR);
@@ -59,7 +68,12 @@ const packageApp = async () => {
5968
.keyBy(_.identity)
6069
.mapValues((pkg: string) => pLockJson.dependencies[pkg].version);
6170

62-
delete pJson.scripts.prepack; // We don't want to rebuild
71+
// Oclif is going to re-run install, and there's a couple of extra files that will be required to make
72+
// that work, which aren't normally included by the "npm pack"/"npm unpack" flow, so we manually pull
73+
// them across here:
74+
pJson.scripts.preinstall = `cp ../../prepare.ts . && cp ../../overrides/js/package-lock.json overrides/js`;
75+
76+
delete pJson.scripts.prepack; // We don't want to rebuild - all built code will be in the packed content
6377
await fs.writeJson(path.join(OUTPUT_DIR, 'package.json'), pJson);
6478

6579
const buildScript = path.join(OUTPUT_DIR, 'build-release.sh');

0 commit comments

Comments
 (0)