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

Add package lockfile support #2388

Merged
merged 24 commits into from
Oct 2, 2023
Merged

Add package lockfile support #2388

merged 24 commits into from
Oct 2, 2023

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Sep 25, 2023

This PR adds lock file support to the compiler pipeline. The lock file is generated whenever a compiler pipeline command (juvix {compile, typecheck, repl}) is run.

The lock file contains all the information necessary to reproduce the whole dependency source tree. In particular for git dependencies, branch/tag references are resolved to git hash references.

Lock file format

The lock file is a YAML juvix.lock.yaml file written by the compiler alongside the package's juvix.yaml file.

LOCKFILE_SPEC: { dependencies: { DEPENDENCY_SPEC, dependencies: LOCKFILE_SPEC }
DEPENDENCY_SPEC: PATH_SPEC | GIT_SPEC
PATH_SPEC: { path: String }
GIT_SPEC: { git: {url: String, ref: String, name: String } }

Example

Consider a project containing the following juvix.yaml:

dependencies:
- .juvix-build/stdlib/
- git:
   url: https://github.com/anoma/juvix-containers
   ref: v0.7.1
   name: containers
name: example
version: 1.0.0

After running juvix compile the following lockfile juvix.lock.yaml is generated.

# This file was autogenerated by Juvix version 0.5.1.
# Do not edit this file manually.

dependencies:
- path: .juvix-build/stdlib/
  dependencies: []
- git:
    name: containers
    ref: 3debbc7f5776924eb9652731b3c1982a2ee0ff24
    url: https://github.com/anoma/juvix-containers
  dependencies:
  - git:
      name: stdlib
      ref: 4facf14d9b2d06b81ce1be1882aa9050f768cb45
      url: https://github.com/anoma/juvix-stdlib
    dependencies: []
  - git:
      name: test
      ref: a7ac74cac0db92e0b5e349f279d797c3788cdfdd
      url: https://github.com/anoma/juvix-test
    dependencies:
    - git:
        name: stdlib
        ref: 4facf14d9b2d06b81ce1be1882aa9050f768cb45
        url: https://github.com/anoma/juvix-stdlib
      dependencies: []

For subsequent runs of the juvix compile pipeline, the lock file dependency information is used.

Behaviour when package file and lock file are out of sync

If a dependency is specified in juvix.yaml that is not present in the lock file, an error is raised.

Continuing the example above, say we add an additional dependency:

dependencies:
- .juvix-build/stdlib/
- git:
     url: https://github.com/anoma/juvix-containers
     ref: v0.7.1
     name: containers
- git:
     url: https://github.com/anoma/juvix-test
     ref: v0.6.1
     name: test
name: example
version: 1.0.0

juvix compile will throw an error:

/Users/paul/tmp/lockfile/dep/juvix.yaml:1:1: error:
The dependency test is declared in the package's juvix.yaml but is not declared in the lockfile: /Users/paul/tmp/lockfile/dep/juvix.lock.json
Try removing /Users/paul/tmp/lockfile/dep/juvix.lock.yaml and then run Juvix again.

Closes:

@paulcadman paulcadman added this to the 0.5.2 milestone Sep 25, 2023
@paulcadman paulcadman self-assigned this Sep 25, 2023
@paulcadman paulcadman force-pushed the lockfile-support branch 3 times, most recently from 5f932fc to 8849226 Compare September 29, 2023 17:32
@paulcadman paulcadman marked this pull request as ready for review October 2, 2023 07:58
@jonaprieto jonaprieto self-requested a review October 2, 2023 08:13
@paulcadman paulcadman force-pushed the lockfile-support branch 3 times, most recently from 14ac1ba to 2741dfb Compare October 2, 2023 12:16
Copy link
Collaborator

@jonaprieto jonaprieto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks!

@jonaprieto jonaprieto merged commit dad3963 into main Oct 2, 2023
4 checks passed
@jonaprieto jonaprieto deleted the lockfile-support branch October 2, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants