ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Cron builds in Github Actions result in `Scope between bases` error #203

Open snowe2010 opened 1 month ago

snowe2010 commented 1 month ago

When running a scheduled github action (cron) with the last tag being an rc, we get the failure:

* What went wrong:
A problem occurred configuring root project 'tax-service'.
> Could not determine the dependencies of null.
   > Could not resolve all dependencies for configuration ':classpath'.
      > Failed to calculate the value of extension 'reckon' property 'version'.
         > Scope between bases 0.0.0 and 1.0.1-rc.1 must be same or 1 MAJOR/MINOR/PATCH increment apart and are not. Cannot determine correct action.

Running this locally with the same parameters, we get no such error. Locally the base is chosen as 1.0.0 correctly. Reckon doesn't have any logs in this area explaining why 0.0.0 was chosen, but you can see in debug mode that 1.0.0 does exist

2024-07-15T19:28:18.320+0000 [DEBUG] [org.ajoberstar.reckon.core.Reckoner] Retrieved the following VCS inventory: VcsInventory[baseNormal=0.0.0,baseVersion=1.0.1-rc.2,claimedVersions=[0.0.2-rc.20, 0.0.2-rc.21, 0.0.2-rc.22, 0.0.2-rc.23, 1.0.1-rc.1, 0.0.2-rc.1, 0.0.2-rc.2, 1.0.1-rc.2, 0.0.2-rc.3, 0.0.2-rc.4, 0.0.2-rc.5, 0.0.2-rc.6, 0.0.2-rc.7, 0.0.2-rc.8, 0.0.2-rc.9, 0.0.2-rc.10, 0.0.2-rc.11, 0.0.2-rc.12, 0.0.2-rc.13, 0.0.2-rc.14, 0.0.2-rc.15, 1.0.0, 0.0.2-rc.16, 0.0.1, 0.0.2-rc.17, 0.0.2-rc.18, 0.0.2-rc.19],clean=true,commitId=6fcd9cc,commitMessages=[Turn on debug mode for reckon (#145)

],commitsSinceBase=1,currentVersion=1.0.1-rc.2,parallelNormals=[]]

Our settings:

setDefaultInferredScope("patch")
stages("rc", "final")
setScopeCalc(calcScopeFromProp().or(calcScopeFromCommitMessages()))
setStageCalc(calcStageFromProp())

If I create a final tag then the error goes away in github actions. This still doesn't explain why it works perfectly fine locally but not in GHA.

Simplified GH Workflow:

name: "build"
on:
  schedule:
    - cron: "3/20 * * * *"

jobs:
  live:
    name: "run live tests"
    runs-on: ubuntu-latest
    steps:
      - name: Checkout latest
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: "true"

# ...
      - name: build
        run: ./gradlew build --debug
# ...
ajoberstar commented 1 month ago

Hi @snowe2010 the baseNormal is determined based on history of the current HEAD commit. An on: schedule job in Actions should run on the default branch's tip commit. Can you confirm locally that you are running on the same commit that the cron job used?

If you are, I'd also be interested in seeing a commit history graph: git log --decorate --oneline --graph --all

snowe2010 commented 1 month ago

it looks the same :(

In GHA

image
Run git rev-parse HEAD
915a25ce8ca3f9059e7d8a63995a1a456e6cd92d
Run git log --decorate --oneline --graph --all | head -n 10
* 915a25c (grafted, HEAD -> master, tag: 1.0.1-rc.6, origin/master) [debugging-3] Mountain time vs UTC... (#150)
* bdd4c48 (tag: 1.0.1-rc.5) [debugging-2] Change cron (#149)
* f6fb9bc (tag: 1.0.1-rc.4) Debug workflow for ajoberstar (#148)
| * 1540ef1 (origin/dependabot/github_actions/softprops/action-gh-release-2.0.8) Bump softprops/action-gh-release from 0.1.15 to 2.0.8
|/  
* 4bae603 (tag: v25, tag: 1.0.1-rc.3) [AAA-111] Redacted
* 6fcd9cc (tag: 1.0.1-rc.2) Turn on debug mode for reckon (#145)
* 98ddd0f (tag: 1.0.1-rc.1) Revert "fix scheduled tests (#143)" (#144)
* 91ad7c6 (tag: 1.0.0, tag: 0.0.2-rc.23) fix scheduled tests (#143)
* bd52bc4 (tag: 0.0.2-rc.22) [BB8-4446] Try to fix service virtualization scheduled tests (#142)

Locally

❯ git rev-parse HEAD
915a25ce8ca3f9059e7d8a63995a1a456e6cd92d
❯ git log --decorate --oneline --graph --all | head -n 10
* 915a25c (HEAD -> master, tag: 1.0.1-rc.6, origin/master, origin/HEAD) [debugging-3] Mountain time vs UTC... (#150)
* bdd4c48 (tag: 1.0.1-rc.5) [debugging-2] Change cron (#149)
* f6fb9bc (tag: 1.0.1-rc.4) Debug workflow for ajoberstar (#148)
| * 1540ef1 (origin/dependabot/github_actions/softprops/action-gh-release-2.0.8) Bump softprops/action-gh-release from 0.1.15 to 2.0.8
|/  
* 4bae603 (tag: v25, tag: 1.0.1-rc.3) [AAA-111] Redacted
* 6fcd9cc Turn on debug mode for reckon (#145)
* 98ddd0f (tag: 1.0.1-rc.2, tag: 1.0.1-rc.1) Revert "fix scheduled tests (#143)" (#144)
* 91ad7c6 (tag: 1.0.0, tag: 0.0.2-rc.23) fix scheduled tests (#143)
* bd52bc4 (tag: 0.0.2-rc.22) [BB8-4446] Try to fix service virtualization scheduled tests (#142)
ajoberstar commented 1 month ago

Sorry it took me a while to get back to this. Nothing standing out so far, but a couple more questions:

snowe2010 commented 4 weeks ago

From the ubuntu-latest in your sample workflow, can I take that this a GitHub-hosted runner? (that is, it's not a self-hosted one)

Yes it is a github hosted runner.

I do see a small discrepancy between the two, though I don't expect it's related to the issue. Locally 1.0.1-rc.2 is tagged on 98ddd0f while in GHA it's tagged on 6fcd9cc.

oh that's strange. I didn't even notice that. 🤔

Do you have any way to share the project or provide a reproducible sample I could do more testing against?

I can't provide the project, but I will work on a reproducible sample.