Skip to content

Use GHC CI infrastructure to produce release artifacts. #6616

Closed

Description

@phadej

The current CI is good for daily development, but GHC CI has wider platform coverage, which would be great for providing binary releases.

Yet, the setup have to be made.

Activity

  1. bgamari commented on Mar 25, 2020

    @bgamari
    Contributor

    Anyone interested should get in touch with me. I'm happy to advise.

  2. samuela commented on Apr 18, 2020

    @samuela

    Hey @bgamari I'm interested in taking a stab at this! What needs to be done?

  3. bgamari commented on Apr 18, 2020

    @bgamari
    Contributor

    @samuela, great! Essentially, the task is to write a .gitlab-ci.yml similar to GHC's which uses the same build environments to build and package cabal-install. The GHC build environments already include cabal-install (since it's necessary to build GHC's Hadrian build system) so the task of building cabal-install should be fairly straightforward.

    I have put up a quick experiment here. Feel free to use it as a starting point. The remaining work is the following:

    • fix the logic (i.e. the find command in my experiment) for locating and copying the executable
    • modify the Linux job in my experiment to rather use the CentOS 7 build instead of Debian 9 (this ensures that we build against an old glibc, allowing us to use the same executable across all glibc-based distributions)
    • Possibly freeze the Hackage index date?
    • Add jobs for (using the GHC .gitlab-ci.yml as a template):
      • AArch64 Linux
      • ARMv7 Linux
      • Darwin (macOS)
      • Windows
      • x86-64 FreeBSD
      • x86-64 Alpine Linux (musl)
      • any other platforms that I have forgotten
    • add --enable-split-sections to the cabal command line
    • build and package the documentation?
    • possibly package the build products into a tarball?
    • cache the Cabal store?

    The platforms which don't use Docker are a bit tricky; on these platforms (Windows, Darwin, FreeBSD) GHC's .gitlab/ci.sh script is responsible for installing a GHC binary distribution. You'll need to replicate this functionality.

    I would be happy to set up a chat to discuss any details if this would be helpful. Alternatively, find me in #ghc on irc.freenode.net.

    Thanks for volunteering!

  4. hasufell commented on Apr 18, 2020

    @hasufell
    Member

    fix the logic (i.e. the find command in my experiment) for locating and copying the executable

        - mkdir -p out
        - cabal update
        - cabal new-install --install-method=copy --overwrite-policy=always --installdir=$(pwd)/out cabal-install

    If you want to use new-build and then find the exe, do:

        - mkdir -p out
        - cabal update
        - cabal new-build
        - cp "$(cabal new-exec --verbose=0 --offline sh -- -c 'command -v cabal')" out/cabal
  5. bgamari commented on Apr 18, 2020

    @bgamari
    Contributor

    Thanks @hasufell! I adopted the v2-install approach in my branch.

  6. samuela commented on Apr 18, 2020

    @samuela

    @samuela, great! Essentially, the task is to write a .gitlab-ci.yml similar to GHC's which uses the same build environments to build and package cabal-install. The GHC build environments already include cabal-install (since it's necessary to build GHC's Hadrian build system) so the task of building cabal-install should be fairly straightforward.

    Thanks for all the info! Since this project is hosted on GitHub whereas GHC is hosted on GitLab, we'll need to do something different than .gitlab-ci.yml, right? It looks as though cabal is currently using GitHub Actions and Travis. So is the ultimate goal to do these builds on cabal GH Actions, cabal Travis, or ghc gitlab CI?

  7. samuela commented on Apr 18, 2020

    @samuela

    @bgamari Oh, I think I may have misunderstood! So your fork lives on gitlab and has a .gitlab-ci.yml file. So which of these CI systems is/should be producing the bindists?

  8. bgamari commented on Apr 18, 2020

    @bgamari
    Contributor

    @samuela the plan here is to use GHC's GitLab CI to prepare the cabal-install binary distributions since then we can easily piggy-back on the existing work put into GHC's infrastructure (not to mention, neither GitHub Actions nor Travis support the range of platforms supported by GHC).

  9. samuela commented on Apr 19, 2020

    @samuela

    Ok, so in order to start adapting https://gitlab.haskell.org/bgamari/cabal-build-test/-/commit/50b81bcf1208dbd7ea566d0a2e0fa428dbdd4d00 to work with centos, we need a new docker image in ci-images. Here's an attempt: https://gitlab.haskell.org/samuela/ci-images/-/commit/b50c3c8049321d8542e7bc29bb03c4e815765621 but it fails with

    Step 10/25 : RUN curl -L https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-armv7-centos7-linux.tar.xz | tar -Jx
     ---> Running in 1ee41616a1d9
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   178  100   178    0     0    217      0 --:--:-- --:--:-- --:--:--   217
    xz: (stdin): File format not recognized
    tar: Child returned status 1
    tar: Error is not recoverable: exiting now
    The command '/bin/bash -o pipefail -c curl -L https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-armv7-centos7-linux.tar.xz | tar -Jx' returned a non-zero code: 2
    

    So we'll need ghc-8.8.3-armv7-centos7-linux.tar.xz first...

  10. hasufell commented on Apr 19, 2020

    @hasufell
    Member
  11. bgamari commented on Apr 19, 2020

    @bgamari
    Contributor

    @samuela I would say let's stick with building on Debian 9 on ARMv7 and AArch64. We don't currently build CentOS bindists on these platforms; it's something that ideally we would ideally do but this will take time and most people tend to use Debian-based distributions on these platforms anyways.

  12. samuela commented on Apr 19, 2020

    @samuela

    Ok, I've started some work on this branch. Here are the pipeline results. So far armv7-linux-deb9 and aarch64-linux-deb9 seem to be working but x86_64-freebsd failed.

  13. hasufell commented on Apr 20, 2020

    @hasufell
    Member

    @samuela nice, a few comments

    1. I think the FreeBSD runner doesn't have a cabal-3.x yet. I also manually update it in the ghcup CI. You can download FreeBSD binaries here: https://hasufell.de/d/d3e215db133e4fcaa61e/ (I signed the hash file). @hvr hasn't responded to my request of adding those tarballs to downloads.haskell.org yet.

    2. I believe the idea was to add this CI in the actual cabal repository and then build the current in-tree version of cabal-install: https://gitlab.haskell.org/bgamari/cabal-build-test I believe your version currently builds from hackage? @phadej there seems to be no cabal mirror on gitlab.haskell.org yet?

  14. samuela commented on Apr 20, 2020

    @samuela

    I think the FreeBSD runner doesn't have a cabal-3.x yet. I also manually update it in the ghcup CI. You can download FreeBSD binaries here: https://hasufell.de/d/d3e215db133e4fcaa61e/ (I signed the hash file). @hvr hasn't responded to my request of adding those tarballs to downloads.haskell.org yet.

    Hmm, this is unfortunate. Ideally we could just update the Docker image? I guess that would require having the downloads up on downloads.haskell.org? For the sake of this issue should we just go ahead and skip freebsd? Or will we need all the platforms in order to switch over?

    I believe the idea was to add this CI in the actual cabal repository and then build the current in-tree version of cabal-install: https://gitlab.haskell.org/bgamari/cabal-build-test I believe your version currently builds from hackage?

    I'm a little confused where this CI is supposed to live. We've got a bunch of different repos flying around across GitHub and GitLab! I'm happy to put them wherever. I interpreted this comment to mean that they should be added to GHC's GitLab repo, but perhaps I misunderstood?

  15. bgamari commented on Apr 20, 2020

    @bgamari
    Contributor

    Hmm, this is unfortunate. Ideally we could just update the Docker image?

    @samuela, right, I'm not opposed to updating the Docker image to pull FreeBSD binaries from @hasufell's server for now.

    Or will we need all the platforms in order to switch over?

    We don't, although it would be nice to do it in one swoop.

    I believe the idea was to add this CI in the actual cabal repository and then build the current in-tree version of cabal-install: https://gitlab.haskell.org/bgamari/cabal-build-test I believe your version currently builds from hackage?

    No, https://gitlab.haskell.org/bgamari/cabal-build-test is a fork of this repository and builds Cabal and cabal-install from said repository.

    I'm a little confused where this CI is supposed to live. We've got a bunch of different repos flying around across GitHub and GitLab! I'm happy to put them wherever. I interpreted this comment to mean that they should be added to GHC's GitLab repo, but perhaps I misunderstood?

    The idea is that we add a .gitlab-ci.yml to this repository (as I did in my experiment). https://gitlab.haskell.org/ can then host a mirror https://github.com/haskell/cabal which CI will run on. The binary artifacts that are produced from this CI can then be used as release artifacts.

  16. 28 remaining items

  17. samuela commented on May 23, 2020

    @samuela

    Well ARM support could be accomplished through self-hosted runners, which is actually the same as what the GitLab CI does. We could probably scavenge a Raspberry Pi or two to run those. I personally don't care about FreeBSD, but that can be run in docker on an Ubuntu runner, so it's not out of the question. Should we just forge ahead with GitHub Actions then? The work done here can be migrated to use GitHub Actions?

  18. samuela commented on May 31, 2020

    @samuela

    The Raspberry Pi folks seem to be moving towards 64 bit builds, which makes armv7 less important in my mind. Of course aarch64 is still very much needed, and many devices will be running armv7 for a while to come.

  19. gbaz commented on Oct 6, 2021

    @gbaz
    Collaborator

    I think this is now done?

  20. phadej commented on Oct 6, 2021

    @phadej
    CollaboratorAuthor

    Does release.py do anything special?

    Not really, I guess.

  21. Mikolaj commented on Oct 6, 2021

    @Mikolaj
    Member

    Does release.py do anything special?

    Not really, I guess.

    Seriously, what kind of passive-aggressive conversation is that? @hasufell, release.py is a lot of, until very recently, actively developed code, of course it does a lot of special things. @phadej: could you please say something less witty, but more useful?

  22. phadej commented on Oct 6, 2021

    @phadej
    CollaboratorAuthor

    @Mikolaj release.py doesn't do anything special, honestly.

    It takes some configuration via command line interface

    cabal/release.py

    Lines 282 to 290 in 6a8c3f8

    parser.add_argument('-w', '--with-compiler', type=str, default='ghc', help='path to GHC')
    parser.add_argument('-C', '--with-cabal', type=str, default='cabal', help='path to cabal-install')
    parser.add_argument('-i', '--index-state', type=str, default=DEFAULT_INDEXSTATE, help='index state of Hackage to use')
    parser.add_argument('--enable-static-executable', '--disable-static-executable', dest='static', nargs=0, default=False, action=EnableDisable, help='Statically link cabal executable')
    parser.add_argument('--enable-ofd-locking', '--disable-ofd-locking', dest='ofd_locking', nargs=0, default=True, action=EnableDisable, help='OFD locking (lukko)')
    parser.add_argument('--tarlib', dest='tarlib', required=True, metavar='LIBTAR', help='path to Cabal-version.tar.gz')
    parser.add_argument('--tarsolver', dest='tarsolver', required=True, metavar='SOLVERTAR', help='path to cabal-install-solver-version.tar.gz')
    parser.add_argument('--tarexe', dest='tarexe', required=True, metavar='EXETAR', help='path to cabal-install-version.tar.gz')
    parser.add_argument('--builddir', dest='builddir', type=str, default='_build', help='build directory')
    , (tries it best to) setup clean environment, but at the end it's similar cabal v2-install as in gitlab setup; https://github.com/haskell/cabal/blob/6a8c3f80173b71436386d9724b64eb67ccb1cf40/.gitlab/ci.sh#L33-l41

    one benefit of release.py is that it can be run on any machine with tools installed (the clean env bit), but you may not value that, and it's fine.

  23. Mikolaj commented on Oct 6, 2021

    @Mikolaj
    Member

    @phadej: but it has some tested and benchmarked options that have been accumulated over time, right? E.g,

    ghc-options: -fexpose-all-unfoldings -fspecialise-aggressively

    Or are such recommended options easily available from somewhere else than this script? Or is that the only example of special configuration that cabal install does not set up by default?

  24. phadej commented on Oct 6, 2021

    @phadej
    CollaboratorAuthor

    there is https://github.com/haskell/cabal/blob/master/cabal.project.release, which however should probably be renamed to cabal.project.bootstrap as it's used for that purpose only atm. And IMO it would be good to have a bootstrap specific cabal.project, as it may be slightly or a lot different then release / other projects, e.g. that optimization is probably not important for bootstrapping (in fact, i'm not sure we need to optimize Cabal at all in boostrapped cabal-install - it depends on what bootstrapped cabal-install is used for)

  25. jneira commented on Mar 11, 2022

    @jneira
    Member

    for better or worse release.py does not exist anymore, neither https://github.com/haskell/cabal/blob/master/.github/workflows/artifacts.yml.
    gitlab was used for the last release and likely will be used for the next ones, with the config in https://github.com/haskell/cabal/blob/master/.gitlab-ci.yml and https://github.com/haskell/cabal/tree/master/.gitlab
    so i think taking in account the original issue title and this comment from @phadej:

    I'd consider this done when there is only one way to build release artifacts used.

    , it would be done

  26. jneira commented on Mar 11, 2022

    @jneira
    Member

    @Mikolaj there were some pending cuestions like the missing flags you mentioned here: #6616 (comment)
    do you think it would need a new issue to track it?

    I really appreciate @phadej thoughts on ci exposed here, like

    Please send an email to [email protected] to discuss that. I have put way too much time (month of work in the beginning of this year) into current CI setup which works reliably enough to actually be useful but that might be my familiarity bias. GitHub Actions don't offer not-self-run ARM nor FreeBSD runners, so adding them in current setup is not possible. Changing CI is not what I want to be part of. In principle it should be easy, "run ./validate.hs".

    And there are other open questions about actual ci, like gitlab artifacts not being tested, but i think they would need new issues (if they do not exists already)

  27. Mikolaj commented on Mar 11, 2022

    @Mikolaj
    Member

    @Mikolaj there were some pending cuestions like the missing flags you mentioned here: #6616 (comment)
    do you think it would need a new issue to track it?

    Let's let it rest. I was booed into closing a ticket about testing the benefit of these options last time I tried, and the partial test results were strange --- I couldn't apply the options to the actual compilation of the cabal executable despite including them in the used cabal.project. So that would require some extra time, which the collective maintainer is not inclined to donate (but we took a similarly large time arguing why the potential measurements can't show anything useful, if completed).

    Regarding scavenging anything of value from validate.hs or release.py or other removed scripts or @phadej skull, that's very worthwhile IMHO, but not trivial. :)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions