ros-controls / ros2_control_ci

This repository holds reusable workflows for CI of the ros2_control framework.
https://control.ros.org
Apache License 2.0
2 stars 1 forks source link

ICI workflow: Cache is shared between different jobs #33

Closed christophfroehlich closed 4 months ago

christophfroehlich commented 5 months ago

if the jobs are unique for different branches, then this would solve the case from above?

Not necessarily. Caches from PRs and scheduled builds would still get mixed up. That might be fine in most cases, but might as well lead to strange errors as the one mentioned above.

I guess, the cleanest would be:

  • Use a proper job identifier (e.g. github.workflow)
  • Use three possbile restore keys:
    • ...${{ github.base_ref }}-${{ github.ref }}
    • ...${{ github.base_ref }}
    • ...${{ github.ref }}

This way on a PR it would search for a cache e.g. ...master-my_feature and if it doesn't find that during the first build use ...master, while for a scheduled build it would use ...master, since ...master- and ... don't exist.

That could work, right?

Changing things to actual actions rather than reusable workflow could be a separate discussion, I think.

_Originally posted by @fmauch in https://github.com/ros-controls/ros2_control_ci/issues/30#issuecomment-1997049189_

christophfroehlich commented 4 months ago

@fmauch have you had time to look into this?

I had only a quick look now.

I realized that the workflow is designed to cache the target_ws itself, before anything is checked out (happens in the ici step itself). This means, that the hash function returns an empty string. Does it make sense to cache the workspace at all, how much is the speed benefit compared to only caching ccache?

Maybe we should remove the workspace cache and avoid such strange cache errors.

https://github.com/ros-controls/ros2_control_ci/blob/0b49c46320bf7f234510b40b187a0e0c989d1678/.github/workflows/reusable-industrial-ci-with-cache.yml#L81-L96

christophfroehlich commented 4 months ago

Summarizing tests

name: Reusable test contexts

on:
  workflow_call:

jobs:
  reusable-test:
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Reusable Github.job ${{ github.job }}"
          echo "Reusable Github.workflow ${{ github.workflow }}"
name: Test contexts

on:
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Github.job ${{ github.job }}"
          echo "Github.workflow ${{ github.workflow }}"
  call_reusable_test:
    uses: ./.github/workflows/reusable_test_contexts.yml

gives

| Github.job test
| Github.workflow Test contexts
| Reusable Github.job reusable-test
| Reusable Github.workflow Reusable test contexts

--> github.workflow does not help here because we still don't get the name of the calling workflow.

fmauch commented 4 months ago

I'll try to have a look tonight