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

Reuse build setup using a dedicated github action #2563

Merged
merged 10 commits into from Jan 5, 2022

Conversation

jneira
Copy link
Member

@jneira jneira commented Jan 4, 2022

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 5, 2022

Is this allowed 8)?

I didn't knew yaml composite exists.

Would review in near time.

# (most probably sticky bit is set on $HOME)
# `&&` insures `rm -f` return is positive.
# Many platforms aslo have `alias cp='cp -i'`.
rm -f -v cabal.project && cp -v cabal-ghc${GHCVER//./}.project cabal.project
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking escaping in-build:
https://github.com/haskell/haskell-language-server/runs/4707587679?check_suite_focus=true#step:3:60:

removed 'cabal.project'
'cabal-ghc901.project' -> 'cabal.project'

Great, works as intended.

@Anton-Latukha
Copy link
Collaborator

For me, in the GitHub Action design is useful to note several things.

Great.

😎 🍾 👏 😃 👏 👏

@Anton-Latukha Anton-Latukha added the merge me Label to trigger pull request merge label Jan 5, 2022
@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 5, 2022

Looked at the number of builds. What I saw looks normal ...

merging ...

@Anton-Latukha
Copy link
Collaborator

Build was/is expecting:
Screenshot-2022-01-05-12:28:14
Restarted:
Screenshot-2022-01-05-12:28:54

But maybe the backend requirement names not aligned?

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 5, 2022

It may be due to 3.6 cabal setting removal from the matrix & so from the name:
Screenshot-2022-01-05-12:31:59

Screenshot-2022-01-05-12:33:05

All other workflows were not requiring this because they either have post_job & so merge checks depend on post_job and other workflows do not have matrix. (looking at this, this seems like a nice thing to abstract, flags probably needs to gain the post_job & CircleCI need also (because right now any GHC version change requires to readjust CircleCI merge checks) either to return 1 status or have a post_job that returns merge status product).

@Anton-Latukha
Copy link
Collaborator

This is actually what I arrived to with DHall, DHall solution essentially required to form a number of modules to reimport. But there is a whole hussle to convert it perfectly into GitHub yaml design caveats ( - '[ "ele.**", file.md, ... ]' & stuff).

This way of solving under current & foreseeable future conditions is much neater.

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

Deduplication looks amazing, just a few comments as I happened to be reading this file for the first time.

.github/actions/setup-build/action.yml Show resolved Hide resolved
.github/actions/setup-build/action.yml Outdated Show resolved Hide resolved
.github/actions/setup-build/action.yml Outdated Show resolved Hide resolved
.github/actions/setup-build/action.yml Outdated Show resolved Hide resolved
echo "" && \
cat 'cabal.project.freeze' && \
echo "" || \
echo 'WARNING: Could not produce the `freeze`.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, is there maybe a way to set -e globally so we can just fail if anything fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

afaik the shell has -e by default but we want the opposite thing: it should not fail so cache will fallback to only index state

Copy link
Collaborator

Choose a reason for hiding this comment

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

But why? We can fail to produce the freeze file? Probably could do with a note explaining that if it's expected...

Copy link
Member Author

@jneira jneira Jan 5, 2022

Choose a reason for hiding this comment

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

good question, we had some issues producing it for bleeding-edge branches like ghc-9.2 but i think it should work now. However i am not sure if we have to be stricter and block ci. Maybe we could try the strict way and make it optional if we see there are more problems hard to fix quickly

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM.

Also, further dumb question: why do we need the freeze file? Given that we pin the index state, won't cabal produce a deterministic build plan anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

i ve made it strict and trying the ghc-9.2 branch here: jneira#59

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@jneira jneira Jan 5, 2022

Choose a reason for hiding this comment

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

SGTM.

Also, further dumb question: why do we need the freeze file? Given that we pin the index state, won't cabal produce a deterministic build plan anyway?

pr's can change dependencies removing, adding or updating bounds in any of the many .cabal files. This way we can have a dedicated cache taking in account those changes. However we could hash all .cabal files. But any change in any cabalfile would miss the cache.

Otoh you can change things in the cabal.project (like constraints, flags, ghc option) which might affect dependencies. cabal freeze should record the relevant changes affecting dependencies. That way cosmetic or other changes not affecting dep resolution in cabal.project does not make miss the cache.

The unique thing we are not tracking is cabal global config, but it does not change frequently (although it did recently for windows duw to github vm inages change)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Freeze file gets into account all projects & infers 1 package version set to rule them all.

Here freeze served the caching key detection purposes - so I was thinking in that adenda & framing, so to have cache fault-tolerant. If any of optional steps fail - the cache does not gets saved (but further I would show that that is a minor thing to having other perks).

There can be mutually exclusive dependencies, especially between plugins. Currently, most of them are enabled by default, so their package constraints should be solvable. But with the growing number of plugins - keeping all plugins package constraints up to date & mutually resolvable would be a challenge.

freeze in itself is a test, that all regular build targets in all projects can infer 1 set of versions of dependencies, so that is a dependency requirement test in itself & it probably should be made & placed so accordingly. Maybe now thinking on having CI to check with freeze for merge would seem viable.

And the additional thought - it seems a good strategy to check contributor PRs for consistency in update/dependency management. It would enforce also to have some backward compatibility of versions between projects, wich is both a good thing and may be a security concern, but security concern is when mainteiners can come into play. So for example, having the consistency means restricting from old versions in one place, would mean it can be at once removed in all other projects.

So indeed, having a freeze requirement seems as a feature.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@michaelpj

Also, further dumb question: why do we need the freeze file? Given that we pin the index state, won't cabal produce a deterministic build plan anyway?

It is not a dumb question. It is a Cabal innerworkings, my understanding from doing my part is:

index-state is a the Hackage deps API catalog state/identifier (even more, Hackage has discrete moments when it has snapshot state available, so cabal takes index-state set - & retrieves info on the nearest Hackage snapshot in the past to it, rolls back into the past to the existing Hackage snapshot state). Then we notice that Hackage ships a lot of package versions at every moment, so index-state determines only the Hackage state & we can not say that it picks versions, it is just a Hackage time machine to the past. The catalog is a tree structure package/{set-of-all-versions} (alike in ~/.cabal/packages/, & inside index*.tar* metadata that gets downloaded form Hackage itself). So under one index-state two build targets are free to choose two mutually exclusive versions.
freeze requires all (afaik build targets, I need to look) package descriptions to be solvable as a whole.

.github/actions/setup-build/action.yml Outdated Show resolved Hide resolved
.github/actions/setup-build/action.yml Outdated Show resolved Hide resolved
jneira and others added 3 commits January 5, 2022 12:58
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
@jneira
Copy link
Member Author

jneira commented Jan 5, 2022

All other workflows were not requiring this because they either have post_job & so merge checks depend on post_job and other workflows do not have matrix. (looking at this, this seems like a nice thing to abstract, flags probably needs to gain the post_job & CircleCI need also (because right now any GHC version change requires to readjust CircleCI merge checks) either to return 1 status or have a post_job that returns merge status product).

For now, i've changed the branch protection rules

@mergify mergify bot merged commit e622744 into haskell:master Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants