Skip to content

fixed the sample github action in the documentation - #1962

Merged
gerhard merged 3 commits into
dagger:mainfrom
ekinbarut:main
Apr 13, 2022
Merged

gerhard merged 3 commits into
dagger:mainfrom
ekinbarut:main

Conversation

@ekinbarut

Copy link
Copy Markdown
Contributor

The sample GitHub action in the documentation did not work due to go packages not being installed before the deploy script.

This is a working sample and suits the documentation better, imo.

You can see the trial and errors here: https://github.com/ekinbarut/dagger_test/actions

@grouville

grouville commented Mar 31, 2022 •

Copy link
Copy Markdown
Member

Hello, thanks for your contribution 😇

Did you push to your repo the packages and the cue.mod created with the init and the update ?
As you seem to have understood with your PR, it's the reason why it didn't work on your case. You did the init and update in the CI, but pushing them to the repo could also be a possibility.

I don't have a strong opinion on the best practice. However, you're right: the way this action is built implies that the best practice is indeed to push the packages. Wdyt @helderco ?

Could you also please update your DCO ?

@ekinbarut
ekinbarut force-pushed the main branch 2 times, most recently from 87e9932 to c643876 Compare March 31, 2022 14:03
@slumbering

Copy link
Copy Markdown
Contributor

Hi @ekinbarut ! many thanks for your contribution :). By the way, we have a contributing guide if you want to have a look 👀 . Usually when we create PR from our fork, we create branch first. Again thanks for your time.

@ekinbarut

Copy link
Copy Markdown
Contributor Author

Thanks for your comments. My mistake in skipping the contributing guideline, should I close this and recreate another PR in accordance with the guideline?

@ekinbarut

Copy link
Copy Markdown
Contributor Author

@grouville I don't have a strong opinion on where to handle that either, first thing that came to my mind was to solve it using CI. General feedback as a user would be that it'd be great if dagger project init & dagger project update is mentioned somewhere in the "getting started" part for a smooth first experience.

@TomChv

TomChv commented Mar 31, 2022

Copy link
Copy Markdown
Member

Thanks for your comments. My mistake in skipping the contributing guideline, should I close this and recreate another PR in accordance with the guideline?

No it's ok, you have signed off your commit, it's enough :P

@TomChv

TomChv commented Mar 31, 2022

Copy link
Copy Markdown
Member

@grouville I don't have a strong opinion on where to handle that either, first thing that came to my mind was to solve it using CI. General feedback as a user would be that it'd be great if dagger project init & dagger project update is mentioned somewhere in the "getting started" part for a smooth first experience.

In my opinion, you should push the cue.mod because if you create your own package, they may be overridden by dagger project update.

But I agree that we should insist on init & update usage. We should write a couple of line about the CLI, what's your opinion @gerhard?

@TomChv TomChv added area/documentation Improvements or additions to documentation size/small labels Mar 31, 2022
@slumbering

Copy link
Copy Markdown
Contributor

Thanks for your comments. My mistake in skipping the contributing guideline, should I close this and recreate another PR in accordance with the guideline?

hey @ekinbarut, not a problem :). I was saying that for next time. Thanks

@gerhard

gerhard commented Mar 31, 2022 •

Copy link
Copy Markdown
Contributor

Hi @ekinbarut, thank you for mentioning this!

In the original context - pkg/universe.dagger.io/examples/todoapp - this is not necessary. The todoapp app is already in the context of a project, and all the packages that it needs are already there.

Double-checking this now in a fresh Linux container with bash, curl, docker & git pre-installed:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock --rm \
  nixery.dev/shell/coreutils/curl/docker/git/gnugrep/gnutar/gzip

# all following commands are running inside this container 👇🏻

curl -L https://dl.dagger.io/dagger/install.sh | sh
# ...
type dagger
# dagger is /bin/dagger
dagger version
# dagger 0.2.4 (b32c8732) linux/amd64

mkdir -p github.com/dagger
cd github.com/dagger
git clone https://github.com/dagger/dagger
cd dagger/pkg/universe.dagger.io/examples/todoapp
pwd
# /github.com/dagger/dagger/pkg/universe.dagger.io/examples/todoapp

dagger do build
# [✔] actions.build.run.script                                      0.2s
# [✔] actions.deps                                                 23.0s
# [✔] actions.test.script                                           0.2s
# [✔] client.filesystem."./".read                                   0.3s
# [✔] actions.test                                                  0.8s
# [✔] actions.build.run                                             4.8s
# [✔] actions.build.contents                                        0.1s
# [✔] client.filesystem."./_build".write                            0.0s

# ☝🏻 Everything works OK, no dagger project init or update required

OK, so once the todoapp example is taken out of the original context, your GitHub Actions runs show what happens - thank you for sharing those! I have noticed the same approach in the GitLab example - #1949 - so I know that we definitely need to improve this.

While these changes are a step in the right direction, they do require a few changes. Let me add those as inline comments on docs/tests/getting-started/github-actions.yml

@gerhard gerhard Mar 31, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should not do this in the context of CI, otherwise we are implying that this Dagger project does not run outside of CI, which raises package versioning issues.

You should have initialised this project locally via this command, and committed all files that this generates. There is a single one right now:

❯ pwd
/home/gerhard/github.com/ekinbarut/dagger_test

❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	cue.mod/

❯ git add .

❯ git diff --cached
diff --git a/cue.mod/module.cue b/cue.mod/module.cue
new file mode 100644
index 0000000..b57d010
--- /dev/null
+++ b/cue.mod/module.cue
@@ -0,0 +1 @@
+module: ""
\ No newline at end of file

@TomChv TomChv mentioned this pull request Mar 31, 2022
@helderco

helderco commented Mar 31, 2022 •

Copy link
Copy Markdown
Contributor

I don't have a strong opinion on the best practice. However, you're right: the way this action is built implies that the best practice is indeed to push the packages. Wdyt @helderco ?

After working in web development for a number of years, and using several different package managers, I usually frown upon committing dependencies to git, assuming there's a lock file.

So project init: yes, commit but keep the pkg/.gitignore. Only do the project update, but this should be cached and you should pin your dependencies.

@gerhard

gerhard commented Apr 1, 2022 •

Copy link
Copy Markdown
Contributor

@helderco my understanding is:

✅ project update
❌ project init

That means that this requires the following changes @ekinbarut before we can merge:

  • Pin dagger version to 0.2 in dagger/dagger-for-github@v2
  • Remove project init from the GitHub workflow
  • Mention needing to run project init locally & committing cue.mod file, see this comment

Is there anything else that I have missed @helderco @TomChv?

@TomChv

TomChv commented Apr 1, 2022

Copy link
Copy Markdown
Member

Is there anything else that I have missed @helderco @TomChv?

I think it's ok, but I'm not sure that external package will be kept on dagger update?
For instance what happens if you write a package in cue.mod/usr, will it be overridden?

@helderco

helderco commented Apr 1, 2022 •

Copy link
Copy Markdown
Contributor

Is there anything else that I have missed @helderco @TomChv?

To pin external dependencies, you add them with a git tag: dagger project update github.com/helderco/[email protected]. You should see this reflected in cue.mod/dagger.{mod,sum}. So the global dagger project update in CI should just install that exact version.

what happens if you write a package in cue.mod/usr, will it be overridden?

No, packages are installed in cue.mod/pkg. If you're working on something not yet published then you can put it in usr and commit to git, don't put it in pkg.

@ekinbarut
ekinbarut requested a review from a team as a code owner April 1, 2022 18:32
@ekinbarut

Copy link
Copy Markdown
Contributor Author

@helderco my understanding is:

✅ project update ❌ project init

That means that this requires the following changes @ekinbarut before we can merge:

  • Pin dagger version to 0.2 in dagger/dagger-for-github@v2
  • Remove project init from the GitHub workflow
  • Mention needing to run project init locally & committing cue.mod file, see this comment

Is there anything else that I have missed @helderco @TomChv?

and

To pin external dependencies, you add them with a git tag: dagger project update github.com/helderco/[email protected]. You should see this reflected in cue.mod/dagger.{mod,sum}. So the global dagger project update in CI should just install that exact version.

  • Pin dagger version to 0.2 in dagger/dagger-for-github@v2
  • Remove project init from the GitHub workflow
  • Mention needing to run project init locally & committing cue.mod file, see this comment

Those were the required updates as far as I've understood. Did I miss any?

@TomChv

TomChv commented Apr 1, 2022

Copy link
Copy Markdown
Member

No, packages are installed in cue.mod/pkg. If you're working on something not yet published then you can put it in usr and commit to git, don't put it in pkg.

Is it explained somewhere? It's really important to know that

@TomChv
TomChv requested review from gerhard and helderco April 1, 2022 20:39

@gerhard gerhard left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for sticking with me on this one @ekinbarut. I just got back and wanted to first get #2172 on the launchpad before getting yours merged. That new PR ensures a nice continuity to your contribution, which I am grateful for. Thank you! 🙌🏻 🚀

Would you like to review those changes for me @ekinbarut? 🙂

@gerhard
gerhard merged commit 3da76c8 into dagger:main Apr 13, 2022
ivorscott pushed a commit to ivorscott/dagger that referenced this pull request Apr 18, 2022
Thanks to a great community contribution, we are improving the GitHub
Actions integration further. We should probably do the same for the
GitLab integration doc as a follow-up to this.

Follow-up to dagger#1962
Uses improvements from dagger#2195

Signed-off-by: Gerhard Lazu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants