Skip to content

Commit

Permalink
When publishing, check only the published project's dependencies, not…
Browse files Browse the repository at this point in the history
… all workspace dependencies (#1314)
  • Loading branch information
fsoikin authored Jan 23, 2025
1 parent ad5a1e3 commit 9cd1209
Showing 8 changed files with 73 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

8 changes: 4 additions & 4 deletions src/Spago/Command/Publish.purs
Original file line number Diff line number Diff line change
@@ -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: []
@@ -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
@@ -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
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
@@ -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

0 comments on commit 9cd1209

Please sign in to comment.