laminas / automatic-releases

Automated release process for `laminas/` projects, usable as github action
Other
140 stars 22 forks source link

fatal: not a valid object name: '4.0.x' #241

Open Spomky opened 1 year ago

Spomky commented 1 year ago

Bug Report

Q A
Version(s) 1.24.0

Summary

Job is failing: https://github.com/web-token/jwt-framework/actions/runs/5016108869/jobs/8992552443 Previous executions were fine: https://github.com/web-token/jwt-framework/actions/runs/4392789931/jobs/7692769201 No changes in the Github Action file. I cannot find what is missing.

Current behavior

Github Action fails with the following error code and detail.

In execute.php line 180:

  [Psl\Shell\Exception\FailedExecutionException (128)]                         
  Shell command "exec git 'branch' 'temporary-branchHVM4BAIn' '4.0.x'" return  
  ed an exit code of "128".                                                    

  STDOUT:                                                                      

  STDERR:                                                                      
      fatal: not a valid object name: '4.0.x'                                  

Exception trace:
  at /app/vendor/azjezz/psl/src/Psl/Shell/execute.php:180
 Psl\Shell\execute() at /app/src/Git/PushViaConsole.php:25
 Laminas\AutomaticReleases\Git\PushViaConsole->__invoke() at /app/src/Application/Command/SwitchDefaultBranchToNextMinor.php:61
 Laminas\AutomaticReleases\Application\Command\SwitchDefaultBranchToNextMinor->execute() at /app/vendor/symfony/console/Command/Command.php:312
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:1022
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:3[14](https://github.com/web-token/jwt-framework/actions/runs/5016108869/jobs/8992552443#step:6:15)
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:[16](https://github.com/web-token/jwt-framework/actions/runs/5016108869/jobs/8992552443#step:6:17)8
 Symfony\Component\Console\Application->run() at /app/bin/console.php:[18](https://github.com/web-token/jwt-framework/actions/runs/5016108869/jobs/8992552443#step:6:19)0
 Laminas\AutomaticReleases\WebApplication\{closure}() at /app/bin/console.php:181

laminas:automatic-releases:switch-default-branch-to-next-minor

How to reproduce

The error is issued during normal Github Action call.

Expected behavior

The branch '4.0.x' already exists. It is expected for the action to correctly find it and continue its execution.

Ocramius commented 1 year ago

I've seen this a number of times now: I think the action is not fetching all branches :thinking:

Spomky commented 1 year ago

I modified the action to make sure all branches are fetched. Unfortunately, the result is the same.

Xerkus commented 8 months ago

This does not make much sense. It tries to create new default branch from latest release branch not taking into account release major version. If release happened for previous major like 3.10.0 while 4.0.x branch exists it attempts to create new default branch from 4.0.x. I wonder what new branch name is, I suspect it is 3.11.x meaning major changes can get backported on branch switch.

Xerkus commented 8 months ago

I looked closely at this issue. I am pretty sure I know what is going on here.

Checkout action by default does depth 1 shallow checkout. Doing git fetch in shallow repository prevents fetching refs that are not in .git/shallow.

https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---update-shallow

--update-shallow

By default when fetching from a shallow repository, git fetch refuses refs that require updating .git/shallow. This option updates .git/shallow and accepts such refs.

Since release normally happens from latest release branch it ends up available in happy path condition. However, when latest available release branch is for the next major it is not fetched to local repository which causes this failure.

It is for the good actually. If not for this bug the more sinister bug would have been uncovered: next minor branch for current major would have been created from the next major branch.

Fix here is two-fold: