karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.14k stars 813 forks source link

[CI] Restore cache failed: Dependencies file is not found #4901

Closed RainbowMango closed 1 week ago

RainbowMango commented 1 week ago

What would you like to be added: Investigate if there is something wrong with the GitHub Action to address the warning:

Restore cache failed: Dependencies file is not found in /home/runner/work/karmada/karmada. Supported file pattern: go.sum

You can get the warning from here: https://github.com/karmada-io/karmada/actions/runs/8957867986

References: https://github.com/actions/setup-go/issues/427

Why is this needed:

RainbowMango commented 1 week ago

cc @liangyuanpeng @zhzhuang-zju

liangyuanpeng commented 1 week ago

Tracing upstream issue:

liangyuanpeng commented 1 week ago

seems like the reason is this workflow have a specially workspace path: https://github.com/karmada-io/karmada/blob/5e1191ffd774d969b293d1622f879062279720ed/.github/workflows/ci.yml#L50

zhzhuang-zju commented 1 week ago

Refer to https://github.com/actions/setup-go/blob/cdcb36043654635271a94b9a6d1392de5bb323a7/src/cache-restore.ts#L52-L65, when cache restore occurs, it looks for the go.sum file at the next level of the directory ${{github.workspace}} and reports an error if it is not found. In our CI scenario, variable ${{github.workspace}} is /home/runner/work/karmada/karmada, but the path of file go.sum is /home/runner/work/karmada/karmada/src/github.com/karmada-io/karmada/go.sum, so the action cannot find file go.sum and print the warning log.

The reason for the inconsistency of the directory is what @liangyuanpeng said, this workflow have a specially workspace path. By tracing the history of the code, this specially workspace path was introduced in #1221 to solve the problem of ci failing to intercept the PR which introduced API change but without deepcopy update.

RainbowMango commented 1 week ago

Thanks for the details analysis, do we have a solution to fix it?

zhzhuang-zju commented 1 week ago

Thanks for the details analysis, do we have a solution to fix it?

The easiest way is to remove the specially workspace path. I gave it a try and submitting a PR which introduced API change but without deepcopy update and didn't end up with the problem described in #1221, so I guess I'll have to look into the reasons for adding the specially workspace path on PR #1221.

liangyuanpeng commented 1 week ago

https://github.com/actions/setup-go/issues/427#issuecomment-1946115668 as second choice

zhzhuang-zju commented 1 week ago

The easiest way is to remove the specially workspace path. I gave it a try and submitting a PR which introduced API change but without deepcopy update and didn't end up with the problem described in #1221, so I guess I'll have to look into the reasons for adding the specially workspace path on PR #1221.

Through experimentation, directly deleting the specially workspace path will not affect the functionality of the CI, as can be seen in https://github.com/zhzhuang-zju/karmada/actions/runs/8966655310/job/24622621482.

The specific reason for this is the addition of this code inside the file hack/update-codegen.sh https://github.com/karmada-io/karmada/blob/c7c8f4939663325a119b6341adb6bdd2de8066ec/hack/update-codegen.sh#L43-L45

This code sets the variable ${{GOPATH}} to a path under ${REPO_ROOT}, so CI doesn't need to run under path ${{ env.GOPATH }}/src/github.com/karmada-io/karmada

cc @RainbowMango @liangyuanpeng

RainbowMango commented 1 week ago

Good job! @zhzhuang-zju

1221 fixed the issue of CI, but with #1731, we don't need it anymore.

Can you send a PR for this?

zhzhuang-zju commented 1 week ago

/assign