Skip to content
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

When publishing, check only the published project's dependencies, not all workspace dependencies #1314

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Other improvements:
- When the `publish.location` field is missing, `spago publish` will attempt to
figure out the location from Git remotes and write it back to `spago.yaml`.
- Internally Spago uses stricter-typed file paths.
- `spago publish` no longer tries to validate all workspace dependencies, but
only the (transitive) dependencies of the project being published.

## [0.21.0] - 2023-05-04

Expand Down
8 changes: 4 additions & 4 deletions src/Spago/Command/Publish.purs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ publish _args = do
logDebug $ "Publishing package " <> strName

-- As first thing we run a build to make sure the package compiles at all
built <- runBuild { selected, dependencies: env.dependencies }
built <- runBuild { selected, dependencies }
( Build.run
{ depsOnly: false
, pursArgs: []
Expand All @@ -103,8 +103,8 @@ publish _args = do
Effect.liftEffect Process.exit

-- We then need to check that the dependency graph is accurate. If not, queue the errors
let allCoreDependencies = Fetch.toAllDependencies $ dependencies <#> _ { test = Map.empty }
let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: allCoreDependencies, depsOnly: false }
let coreDependencies = dependencies # Map.lookup name <#> _.core # fromMaybe Map.empty
let globs = Build.getBuildGlobs { rootPath, selected: NEA.singleton selected, withTests: false, dependencies: coreDependencies, depsOnly: false }
eitherGraph <- Graph.runGraph rootPath globs []
case eitherGraph of
Right graph -> do
Expand Down Expand Up @@ -206,7 +206,7 @@ publish _args = do
RegistryVersion v -> Right (Tuple pkgName v)
_ -> Left pkgName
)
$ (Map.toUnfoldable allCoreDependencies :: Array _)
$ (Map.toUnfoldable coreDependencies :: Array _)
if Array.length fail > 0 then
addError
$ toDoc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Reading Spago workspace configuration...

✓ Selecting package to build: root

Downloading dependencies...
Building...
Src Lib All
Warnings 0 0 0
Errors 0 0 0

✓ Build succeeded.

Passed preliminary checks.
‼ Spago is in offline mode - not pushing the git tag v0.0.1
Building again with the build plan from the solver...
Building...
Src Lib All
Warnings 0 0 0
Errors 0 0 0

✓ Build succeeded.


✓ Ready for publishing. Calling the registry..


✘ Spago is offline - not able to call the Registry.
14 changes: 14 additions & 0 deletions test-fixtures/publish/1307-publish-dependencies/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package:
name: root
dependencies:
- prelude: ">=6.0.1 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
publish:
version: 0.0.1
license: MIT
location:
githubOwner: purescript
githubRepo: aaa
workspace:
packageSet:
registry: 62.2.5
7 changes: 7 additions & 0 deletions test-fixtures/publish/1307-publish-dependencies/src/Main.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Root where

import Prelude
import Effect (Effect)

main :: Effect Unit
main = pure unit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package:
name: subdir
dependencies:
- root
- prelude
publish:
version: 0.0.1
license: MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Subdir where

anExport :: String
anExport = "Hello, World!"
7 changes: 7 additions & 0 deletions test/Spago/Publish.purs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ spec = Spec.around withTempDir do
spago [ "fetch" ] >>= shouldBeSuccess
spago [ "publish", "--offline" ] >>= shouldBeFailureErr (fixture "publish/ready.txt")

Spec.it "#1307 allows other non-published projects to reference local project in the workspace" \{ spago, fixture, testCwd } -> do
FS.copyTree { src: fixture "publish/1307-publish-dependencies", dst: testCwd }
spago [ "build" ] >>= shouldBeSuccess
doTheGitThing
spago [ "fetch" ] >>= shouldBeSuccess
spago [ "publish", "-p", "root", "--offline" ] >>= shouldBeFailureErr (fixture "publish/1307-publish-dependencies/expected-stderr.txt")

Spec.describe "transfer" do

Spec.it "fails if the publish config is not specified" \{ spago, fixture } -> do
Expand Down
Loading