Skip to content

Commit

Permalink
Add spec for yarn2 modules with zero install
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Feb 7, 2022
1 parent bc33290 commit 90b0bae
Show file tree
Hide file tree
Showing 57 changed files with 1,290 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/ci/yarn2_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative '../spec_helper'

describe "yarn2 examples" do
# Example uses the pnp linker and pushes all dependencies in .yarn/cache.
# No packages should be downloaded and buildcache is not used in this mode.
it "pnp zero-install with should deploy successfully and not use the cache" do
app = Hatchet::Runner.new("spec/fixtures/repos/yarn2-pnp-zero-install")
app.deploy do |app|
Expand All @@ -14,6 +16,8 @@
end
end

# Example uses the pnp linker but does not push dependencies in .yarn/cache.
# All packages will either be restored from buildcache or downloaded.
it "pnp nonzero-install should deploy successfully and reuse the cache" do
app = Hatchet::Runner.new("spec/fixtures/repos/yarn2-pnp-nonzero-install")
app.deploy do |app|
Expand All @@ -28,6 +32,25 @@
end
end

# Example uses the node-modules linker (e.g. node standard module resolution)
# and pushes all dependencies in .yarn/cache. No packages should be downloaded
# and buildcache is not used in this mode.
it "node_modules zero install should deploy successfully and reuse the cache" do
app = Hatchet::Runner.new("spec/fixtures/repos/yarn2-modules-zero-install")
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello from yarn2-modules-zero-install")

run!('git commit --allow-empty -m "deploy again to test cache reuse"')
app.push!

expect(app.output).to include("yarn cache is checked into source control and cannot be cached")
expect(successful_body(app).strip).to eq("Hello from yarn2-modules-zero-install")
end
end

# Example uses the node-modules linker (e.g. node standard module resolution)
# and does not push dependencies in .yarn/cache. All packages will either be
# restored from the buildcache or downloaded.
it "node_modules nonzero install should deploy successfully and reuse the cache" do
app = Hatchet::Runner.new("spec/fixtures/repos/yarn2-modules-nonzero-install")
app.deploy do |app|
Expand Down
8 changes: 8 additions & 0 deletions spec/fixtures/repos/yarn2-modules-zero-install/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions spec/fixtures/repos/yarn2-modules-zero-install/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-3.1.1.cjs
nodeLinker: node-modules
11 changes: 11 additions & 0 deletions spec/fixtures/repos/yarn2-modules-zero-install/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const express = require("express");
const app = express();
const port = process.env["PORT"] || 3000;

app.get("/", (_req,res) => {
res.send("Hello from yarn2-modules-zero-install");
});

app.listen(port, () => {
console.log(`yarn2-modules-zero-install listening on ${port}`);
});
13 changes: 13 additions & 0 deletions spec/fixtures/repos/yarn2-modules-zero-install/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "yarn2-modules-zero-install",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "yarn node index.js"
},
"dependencies": {
"express": "^4.17.2"
},
"packageManager": "yarn@3.1.1"
}
Loading

0 comments on commit 90b0bae

Please sign in to comment.