|
1 |
| -# checkout-codeql-test |
2 |
| -This repo is minimal test for the default CodeQL setup |
3 |
| -boop to trigger codeql |
| 1 | +# checkout-test |
| 2 | + |
| 3 | +This repo is minimal test to show that `actions/[email protected]` introduces a new requirement on consumers to use either a newer version of `git` or a newer version of other dependencies that need to handle the `repositoryformatversion` value of `1` in the `.git` directory. |
| 4 | + |
| 5 | +The difference between `actions/[email protected]` and `actions/[email protected]` is that `sparse-checkout` is disabled explicitly, which depending on the version of `git` being used, results in a `repositoryformatversion` value of `1` being written to the `.git` directory for older versions and a value of `0` for newer versions. What exact `git` version boundary this change occurs at is not clear. The following table shows the combinations of software and their results: |
| 6 | + |
| 7 | +| `actions/checkout` | `git` | `repositoryformatversion` | Test | |
| 8 | +|--------------------|-------|---------------------------| ---- | |
| 9 | +| `v4.1.1` | `2.34.1` | `0` | :heavy_check_mark: <https://github.com/hicksjacobp/checkout-codeql-test/actions/runs/8842167272/job/24280382043> | |
| 10 | +| `v4.1.4` | `2.34.1` | `1` | :x: <https://github.com/hicksjacobp/checkout-codeql-test/actions/runs/8842167272/job/24280382240> | |
| 11 | +| `v4.1.4` | `2.43.2` | `0` | :heavy_check_mark: <https://github.com/hicksjacobp/checkout-codeql-test/actions/runs/8842167272/job/24280382420> | |
| 12 | + |
| 13 | +The scenario of `actions/[email protected]` and `[email protected]` is what has caused us unforeseen pain. |
| 14 | +This scenario is exacerbated by the fact that `actions/[email protected]` comes with `[email protected]` and the default CodeQL workflow uses `actions/checkout@v4` (and therefore resolves to `actions/[email protected]` as of the time of writing). |
| 15 | +Performing an `apt-get install git` does NOT update `git` to a newer version because the base and ancestor images which `actions/runner` is based off of does not use the `apt` feed which has newer versions of git, and is rather left behind at `2.34.1`. |
| 16 | + |
| 17 | +## Resolutions |
| 18 | + |
| 19 | +### Update `git` |
| 20 | + |
| 21 | +In order to update `git` to newer versions, in Ubuntu at least, you have to perform at least these steps: |
| 22 | + |
| 23 | +```bash |
| 24 | +apt update |
| 25 | +apt install software-properties-common |
| 26 | +add-apt-repository -y ppa:git-core/ppa |
| 27 | +apt install git |
| 28 | +``` |
| 29 | + |
| 30 | +See <https://git-scm.com/download/linux> for reference. |
| 31 | + |
| 32 | +> [!TIP] |
| 33 | +> Do this in `actions/runner`? |
| 34 | +
|
| 35 | +### Update dependencies to handle `repositoryformatversion` of `1` |
| 36 | + |
| 37 | +Personally, I found this issue through referencing `[email protected]`. With .NET SDK 8, there is now a `[email protected]` package (along with the transitive dependency which can now handle the `repositoryformatversion` of `1`). See <https://github.com/dotnet/sourcelink/pull/772>. |
| 38 | + |
| 39 | +### Downgrade `actions/checkout` to `v4.1.1` |
| 40 | + |
| 41 | +> [!WARNING] |
| 42 | +> This may not be possible for your situation, for example using the default CodeQL setup and using a CI infrastructure where updating `git` has not yet been done and is out of your control. |
| 43 | +
|
| 44 | +## References |
| 45 | + |
| 46 | +- `actions/[email protected]` is based off of `mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy` and none of these images do any additional setup for `git`: |
| 47 | + <https://github.com/actions/runner/blob/14cea13ab5e7a5f385d805bf8a9034947d25f1b6/images/Dockerfile> |
| 48 | + <https://github.com/dotnet/dotnet-docker/blob/main/src/runtime-deps/6.0/jammy/amd64/Dockerfile> |
| 49 | +- Install instructions for `git`: |
| 50 | + <https://git-scm.com/download/linux> |
0 commit comments