Skip to content

Lint sdk code before publishing. - #4065

Closed
sipsma wants to merge 1 commit into
dagger:mainfrom
sipsma:lint-before-publish
Closed

sipsma wants to merge 1 commit into
dagger:mainfrom
sipsma:lint-before-publish

Conversation

@sipsma

@sipsma sipsma commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

The main goal here is to ensure that the generated client-side APIs are matching the engine being published with. This requires that we use ./hack/make-prod when calling publish in CI, which is currently the case already.

Signed-off-by: Erik Sipsma [email protected]

PTAL @gerhard

cc @slumbering @grouville goal here is to prevent future occurrences of the issue that happened today where the node sdk was published w/ unix socket APIs even though the released engine did not have them.

The main goal here is to ensure that the generated client-side APIs are
matching the engine being published with. This requires that we use
`./hack/make-prod` when calling publish in CI, which is currently the
case already.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma

sipsma commented Dec 1, 2022

Copy link
Copy Markdown
Contributor Author

I just realized that this creates a catch 22 around the Go SDK specifically, fortunately that will also be solved by the solution mentioned in this issue: #4041

To explain, the CI automation uses the Go SDK to setup the go linting, w/ dagger-in-dagger used to expose the engine api back to it. But that means we are linting against the engine created by the non-replaced Go SDK version in our go.mod, which is the previous vesion. Basically, we can't release the Go SDK until we have upgraded it and can't upgrade it until we have released it.

The fix to the linked issue will address this because it'll result in the Go SDK actually doing full provisioning inside the exec rather than using dagger-in-dagger, so it'll use the actual engine dependency from the SDK's main. It'll also just be way simpler to think about in general thankfully...

I'm marking this as a draft for now; will undraft once I merge the fix for that linked issue (working on it now)

@aluzzardi

aluzzardi commented Dec 1, 2022 •

Copy link
Copy Markdown
Contributor

@sipsma How can it be not the case since every commit in main should be linted already?

edit because of make-prod, I already forgot

@sipsma
sipsma marked this pull request as draft December 1, 2022 18:52
@sipsma

sipsma commented Dec 1, 2022

Copy link
Copy Markdown
Contributor Author

@sipsma How can it be not the case since every commit in main should be linted already?

@aluzzardi it's linted against the dev engine, which is not the latest released one.

@aluzzardi

Copy link
Copy Markdown
Contributor

@aluzzardi it's linted against the dev engine, which is not the latest released one.

With the proposed solution in #4041 this linting couldn't be possible anymore, right(-ish)? Since it will overall simplify everything and get rid of make/make-prod

@sipsma

sipsma commented Dec 1, 2022

Copy link
Copy Markdown
Contributor Author

With the proposed solution in #4041 this linting couldn't be possible anymore, right(-ish)? Since it will overall simplify everything and get rid of make/make-prod

No I've realized as I started working on that issue that even though it simplifies things we still want both ./make and ./make-prod.

The reason is that even though we simplify by only running the mage code with one pinned go sdk version, we still need to run the code inside the execs sometimes against the dev engine and sometimes against the prod one.

Linting is actually a perfect example:

  1. Most of the time we want to check that the dev engine API matches the generated SDK API
  2. But right before we publish an SDK, we actually want to check that the prod engine API (the one the SDK defaults to using) matches the generated SDK API

I think testing is probably the same thing.

I'm approaching this by just never using the ExperimentalPrivilegedNesting flag in our CI. Instead, we always mount in the docker sock and then choose between running against the dev vs prod engine by toggling whether, in the exec, we set the DAGGER_HOST env var or not.

@gerhard

gerhard commented Dec 2, 2022 •

Copy link
Copy Markdown
Contributor

If we test & lint all commits using a dev Engine, then we should most definitely test & lint using the Engine version referenced in the SDK part of publishing. Linting is a good first step, but we should also test.

@gerhard

gerhard commented Dec 2, 2022

Copy link
Copy Markdown
Contributor

I'm really missing a diagram now that explains how all of this works. There are too many layers, dependencies and state transitions to keep everything in my head. Want to pair-up on this @sipsma?


Btw, this really helped in the context of https://github.com/dagger/dagger.io/pull/1275

@gerhard

gerhard commented Dec 2, 2022 •

Copy link
Copy Markdown
Contributor

This is a starting point which helped me visualise what we are missing:

flowchart LR
    branch(main)
    tde([Test with DevEngine])
    lde([Lint with DevEngine])
    DevEngine --> tde --> |"✅"| branch
    DevEngine -.- DevGoSDK --> tde & lde --> |"✅"| branch
    DevEngine -.- DevPythonSDK --> tde & lde --> |"✅"| branch
    DevEngine -.- DevNodejsSDK --> tde & lde --> |"✅"| branch

    tpe([Test with PublishedEngine])
    lpe([Lint with PublishedEngine])
    branch --> publish([Publish]) --> PublishedEngine & PublishedCLI

    PublishedEngine --> TaggedGoSDK --> tpe & lpe --> |"✅"| PublishedGoSDK
    PublishedEngine --> TaggedPythonSDK --> tpe & lpe --> |"✅"| PublishedPythonSDK
    PublishedEngine --> TaggedNodejsSDK --> tpe & lpe --> |"✅"| PublishedNodejsSDK

    PublishedCLI --> S3(dl.dagger.io/dagger) & brew-tap(github.com/dagger/homebrew-tap)
Loading

Rather than have separate workflows that publish SDKs individually, we should have a single publish workflow that publishes everything at once. Does that look right?

@gerhard

gerhard commented Dec 2, 2022 •

Copy link
Copy Markdown
Contributor

We spent some time with @sipsma to capture what happens when we run Go SDK tests:

flowchart TD
    make(./hack/make sdk:go:test)
    dev(./hack/dev go run main.go sdk:go:test)

    dev -.- sdk -.- test

    StableGoSDK(Go SDK: dagger.io/dagger v0.4.1) ==> dev

    sdk(Go SDK) --> |mount| docker-container://test-dagger-engine 

    make --> dev ==> |provision ghcr.io/dagger/dagger:v0.3.6| docker-container://dagger-engine-sha256
    build --> tar(/tmp/dagger-engine-export)
    tar --> |load & run| docker-container://test-dagger-engine

    subgraph Docker
        subgraph docker-container://dagger-engine-sha256
            build
        end
        subgraph docker-container://test-dagger-engine
            subgraph buildkit-exec
                binary(DAGGER_HOST=bin:///.dagger_engine_session)
                socket(DAGGER_RUNNER_HOST=unix:///dagger-runner.sock)
                test(go test)
            end 
        end
    end
Loading

While the above renders in GitHub mermaid, some details are missing. Here's a link to the original graph.

@sipsma

sipsma commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Closing as this turned out to not yet be possible due to an independent bug, explained more in the PR here: #4087

We will want this in general but it will take a bit to get there, specifically we'll need to have SDKs use the CLI as downloaded from S3 instead of the engine-session bin pulled from images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants