johnwason / vcpkg-action

Simple vcpkg action to build and cache packages
MIT License
19 stars 6 forks source link

Collect logs on failure #26

Open jdoubleu opened 7 months ago

jdoubleu commented 7 months ago

This GitHub action is really helpful to me. I have a suggestion for a Quality-of-Life feature, that could really be helpful for debugging.

I often have to deal with failing builds of dependencies due to various reasons. When a dependency fails to build, vcpkg creates multiple log files somewhere in the buildtrees folder. I have to manually cat these in a separate step.

It would be nice, if this action adds a step which automatically collects all (error) logs and makes them available to the user somehow. I'm not too familiar with GitHub actions, but if you cannot upload the logs, you may simply cat them?

I'm not sure to always include this additional step, but constraint it to failing builds, or including it only when debug logging is active (i.e. when manually re-running the job).

My current, manual approach is to add the following step immediately after the action:

      - name: cat logs
        if: failure()
        run: cat /path/to/project/vcpkg/buildtrees/dependency/build-x64-linux-err.log
johnwason commented 7 months ago

Hi @jdoubleu

I find it is better to capture the logs using upload-artifact rather than trying to dump them to the console and decipher them.

Something like this should work, although I haven't tested this exact example:

- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: vcpkg-logs
    path: vcpkg/**/*.log
jdoubleu commented 7 months ago

Okay, thanks. I think this would work well.

How do you feel about adding an option (e.g. collect_logs: 'on-failure' // 'always', 'on-success', 'on-failure'), which automatically adds such a step?