flip-link icon indicating copy to clipboard operation
flip-link copied to clipboard

GHA support

Open thejpster opened this issue 4 years ago • 15 comments

Is there a way to use flip-link in a Github Action, without building it from source every time?

See https://github.com/Neotron-Compute/Neotron-BMC/runs/3152027601?check_suite_focus=true as an example.

thejpster avatar Jul 24 '21 20:07 thejpster

Is there a way to use flip-link in a Github Action, without building it from source every time?

You mean providing build artifacts in this repo so that third party CI can "binary install" those? I know trust (Travis CI template) provided that functionality but I don't know if actions-rs provides similar functionality.

japaric avatar Aug 02 '21 11:08 japaric

cc https://github.com/actions-rs/meta/issues/21 and also https://github.com/actions-rs/install

The trust template was ported to GHA and extended here: https://github.com/XAMPPRocky/mean-bean-ci-template

We could potentially use that to release binaries, but waiting for actions-rs to gain this functionality might be better, given that flip-link already builds very quickly.

jonas-schievink avatar Aug 02 '21 12:08 jonas-schievink

For some value of quickly. It takes 58 seconds against my actual code build of 43 second.

thejpster avatar Aug 08 '21 19:08 thejpster

Reading https://github.com/rust-embedded/embedonomicon/pull/72, perhaps it would suffice to offer an example of how to enable caching so that flip-link builds are bypassed that way instead.

thejpster avatar Aug 09 '21 20:08 thejpster

I think providing build artifacts for releases is quite possible. I would limit it to a few major targets for the beginning and then wait for action-rs for a more holistic solution.

What do you think @thejpster?

Urhengulas avatar Aug 19 '21 13:08 Urhengulas

Sure. I only need whatever GHA runs - x64 Linux I assume .

thejpster avatar Aug 19 '21 13:08 thejpster

Sure. I only need whatever GHA runs - x64 Linux I assume .

Yes. My thought was to just support the GHA targets for their linux, windows and macos machines. Thereby we cover the CI usecase, which should be enough for now.

Urhengulas avatar Aug 19 '21 15:08 Urhengulas

The last flip-link release which you're using in CI has this dependency tree (and builds, without crate downloads, in 5.5s on my machine):

flip-link v0.1.4 (/home/jonas/dev/flip-link)
├── anyhow v1.0.40
├── env_logger v0.8.3
│   ├── atty v0.2.14
│   │   └── libc v0.2.94
│   ├── humantime v2.1.0
│   ├── log v0.4.14
│   │   └── cfg-if v1.0.0
│   ├── regex v1.5.4
│   │   ├── aho-corasick v0.7.18
│   │   │   └── memchr v2.4.0
│   │   ├── memchr v2.4.0
│   │   └── regex-syntax v0.6.25
│   └── termcolor v1.1.2
├── log v0.4.14 (*)
├── object v0.24.0
└── tempfile v3.2.0
    ├── cfg-if v1.0.0
    ├── libc v0.2.94
    ├── rand v0.8.3
    │   ├── libc v0.2.94
    │   ├── rand_chacha v0.3.0
    │   │   ├── ppv-lite86 v0.2.10
    │   │   └── rand_core v0.6.2
    │   │       └── getrandom v0.2.3
    │   │           ├── cfg-if v1.0.0
    │   │           └── libc v0.2.94
    │   └── rand_core v0.6.2 (*)
    └── remove_dir_all v0.5.3

Current main branch only has this (and builds in 3 seconds on my machine):

flip-link v0.1.4 (/home/jonas/dev/flip-link)
├── anyhow v1.0.40
├── env_logger v0.8.3
│   └── log v0.4.14
│       └── cfg-if v1.0.0
├── log v0.4.14 (*)
├── object v0.25.2
│   └── memchr v2.4.0
└── tempfile v3.2.0
    ├── cfg-if v1.0.0
    ├── libc v0.2.94
    ├── rand v0.8.3
    │   ├── libc v0.2.94
    │   ├── rand_chacha v0.3.0
    │   │   ├── ppv-lite86 v0.2.10
    │   │   └── rand_core v0.6.2
    │   │       └── getrandom v0.2.3
    │   │           ├── cfg-if v1.0.0
    │   │           └── libc v0.2.94
    │   └── rand_core v0.6.2 (*)
    └── remove_dir_all v0.5.3

With https://github.com/knurling-rs/flip-link/pull/51, the dependencies are further reduced (and it now builds in 2.5s):

flip-link v0.1.4 (/home/jonas/dev/flip-link)
├── anyhow v1.0.40
├── env_logger v0.8.3
│   └── log v0.4.14
│       └── cfg-if v1.0.0
├── getrandom v0.2.3
│   ├── cfg-if v1.0.0
│   └── libc v0.2.94
├── log v0.4.14 (*)
└── object v0.25.2
    └── memchr v2.4.0

jonas-schievink avatar Aug 19 '21 19:08 jonas-schievink

How long does it take in GHA?

thejpster avatar Aug 20 '21 10:08 thejpster

How long does it take in GHA?

From trying it only one time the main branch currently takes 32 seconds (see).

Urhengulas avatar Aug 20 '21 12:08 Urhengulas

How long does it take in GHA?

5 seconds from scratch including crate download time: https://github.com/knurling-rs/flip-link/runs/4811186841?check_suite_focus=true#step:4:33 when build without optimizations: cargo install --debug


in any case, I looked into doing GitHub releases from GitHub Actions and, well, it doesn't look there's a canonical way to go about it. there are several options

so I too would prefer to wait until actions-rs provides something that works out of the box, preferably something that builds tarballs with some standardized name and that interops with actions-rs/install

japaric avatar Jan 14 '22 15:01 japaric

perhaps it would suffice to offer an example of how to enable caching so that flip-link builds are bypassed that way instead.

PR #74 has an example of how to cache Cargo's registry and the target directory. I don't think that would help with cargo install-ed things though because the build artifacts for those crates are not placed in target but built in a separate directory (temporary directory maybe?)

if you want to cache the .cargo/bin directory, where cargo-install-ed things are stored, I think you would need to hash a file that contains the names and versions of the tools you install and use that as the cache key. also you would only get a speedups on a full cache hit because the "target directory" of cargo install would not be cached, only the final program binary would -- unless you use cargo install --target-dir I guess (haven't used that before).

japaric avatar Jan 14 '22 15:01 japaric

For what it's worth I have been happily using https://github.com/softprops/action-gh-release for one of my projects.

But I can live with a five second install. Thank you all for working on this!

thejpster avatar Jan 14 '22 19:01 thejpster

Just to come back to this, installing flip-link in GHA is taking 45 seconds, even with cargo install --debug flip-link. I can see in your latest CI run it's taking 37 seconds (and you have stuff cached whereas I don't).

thejpster avatar Aug 13 '22 13:08 thejpster

@thejpster said:

Just to come back to this, installing flip-link in GHA is taking 45 seconds, even with cargo install --debug flip-link. I can see in your latest CI run it's taking 37 seconds (and you have stuff cached whereas I don't).

I will investigate why the compile time regressed and work on releasing pre-build binaries.

Urhengulas avatar Aug 17 '22 10:08 Urhengulas

You can now download binaries from the releases page, e.g. https://github.com/knurling-rs/flip-link/releases/tag/v0.1.8

Urhengulas avatar Mar 07 '24 14:03 Urhengulas