GitTools / actions

GitHub Action that installs and uses the GitVersion and GitReleaseManager tools
MIT License
218 stars 63 forks source link

[ISSUE]: Incorrect path to gitversion on windows #1196

Closed Notten02 closed 1 month ago

Notten02 commented 1 month ago

Prerequisites

GitVersion package

GitHub Actions

What are you seeing?

We are running self hosted windows runners. We are using V2.0.1 of this action but also see the behavior in V2.0.0. The action will successfully download the gitversion dotnet tool. But try's calling it on a incorrect path.

In the log:

Running on: 'GitHub Actions'
Disable Telemetry
--------------------------
Acquiring GitVersion.Tool for version spec: 5.x
--------------------------
Querying tool versions for GitVersion.Tool@5.x 
Found matching version: 5.12.0
Looking for local tool GitVersion.Tool@5.12.0
Found tool GitVersion.Tool@5.12.0 at D:\workspaces\_tool\GitVersion.Tool\5.12.0
--------------------------
GitVersion.Tool version: 5.12.0 found in local cache at D:\workspaces\_tool\GitVersion.Tool\5.12.0.
--------------------------
Prepending D:\workspaces\_tool\GitVersion.Tool\5.12.0 to PATH
Updated PATH: D:\workspaces\_tool\GitVersion.Tool\5.12.0;[REDACTED]
Set GITVERSION_PATH to D:\workspaces\_tool\GitVersion.Tool\5.12.0

Some other unrelated build steps take place here

Run gittools/actions/gitversion/execute@v2.0.1
Running on: 'GitHub Actions'
Disable Telemetry
Executing GitVersion
Command: git -C D:/workspaces/Voortman.TcLib.Base/Voortman.TcLib.Base rev-parse --is-shallow-repository
Command: D:\workspaces\_tool\GitVersion.Tool\5.12.0\dotnet-gitversion.exe D:/workspaces/Voortman.TcLib.Base/Voortman.TcLib.Base /output json /output buildserver /config GitVersion.yml
Error: Command failed: D:\workspaces\_tool\GitVersion.Tool\5.12.0\dotnet-gitversion.exe D:/workspaces/Voortman.TcLib.Base/Voortman.TcLib.Base /output json /output buildserver /config GitVersion.yml
'D:\workspaces\_tool\GitVersion.Tool\5.12.0\dotnet-gitversion.exe' is not recognized as an internal or external command,
operable program or batch file.

I've looked at the build node. In the log it appears to be calling gitversion at D:\workspaces\_tool\GitVersion.Tool\5.12.0\dotnet-gitversion.exe. On file system the tool is located at D:\workspaces\_tool\GitVersion.Tool\5.12.0\x64\dotnet-gitversion.exe

What is expected?

For the action to generate a version number and not give a command failed error

Steps to Reproduce

Call the action on a self hosted runner with Windows server 2019 as OS (perhaps also other operating systems but I don't have those running out here)

Output log or link to your CI build (if appropriate).

See log file in general description
arturcic commented 1 month ago

@Notten02 Can you post the relevant GitHub Actions workflow file?

arturcic commented 1 month ago

@Notten02 this is an example of a run on windows https://github.com/GitTools/actions-test/actions/runs/10038833569/job/27741576219 and this is an example of workflow file https://github.com/GitTools/actions-test/blob/main/.github/workflows/ci.yml

Notten02 commented 1 month ago

I cannot post the file in its entirety, the action is wrapped into an internal action, but I can post some relevant parts

workflow:

name: Build

on:
  push:
    branches-ignore:
      - "master"
      - "main"

concurrency:
  group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
  cancel-in-progress: true

jobs:
  Build:
    timeout-minutes: 10
    runs-on: [self-hosted, tcbuild]
    outputs:
      fullSemVer: ${{ steps.buildstep.outputs.fullSemVer }}

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: internal/repository/build-twincat-library@v2
        id: buildstep
        with:
          solution: Voortman.TcLib.Base.sln
          project: Voortman.TcLib.Base
          compiledLibrary: false
       #other steps that are irrelevant

build-twincat-library:

#some setup with inputs and name here
runs:
  using: composite
  steps:
    #some irrelevant steps for compilation here
    - name: Install gitversion
      uses: gittools/actions/gitversion/setup@v2.0.1
      with:
        versionSpec: '5.x'
     #more irrelevant steps
    - name: Run gitversion
      id: gitversion
      uses: gittools/actions/gitversion/execute@v2.0.1
      with:
        useConfigFile: true
   #more steps that depend on the semver from gitversion

While not one to one it seems pretty much the same as in the example?

arturcic commented 1 month ago

to me it seems the GITVERSION_PATH variable it's not correctly set in the setup action, and it's used for the execute action

arturcic commented 1 month ago

unfortunately there is no easy way for me to repro this. Can you fork https://github.com/GitTools/actions-test instead and try to run on those self-hosted agents?

Notten02 commented 1 month ago

Sorry I had a day off yesterday, I will fork and run the code later today and send you the logs

Notten02 commented 1 month ago

I ran the CI build on our internal server, The V5 of gitversion seems to fail. The log archive is attached.

I did a copy paste of the repo instead of a fork. I did not want to expose the internal buildnodes to a public repository. The found version numbers might be a little different then what you'd expect

logs_26412363140.zip

arturcic commented 1 month ago

I would say use the version that does work if you don't have time to investigate further. Just one question, in the V5 version can you check the location where the tool is installed if the exe file is actually there

Notten02 commented 1 month ago

The tool is there and installed, only the path is different. For V5 it adds a x64 folder for the installation. D:\Workspaces\_tool\GitVersion.Tool\5.12.0\x64\dotnet-gitversion.exe would be the correct path on our build agent

arturcic commented 1 month ago

what about the version 6.0.0? which path its on?

Notten02 commented 1 month ago

D:\Workspaces\_tool\GitVersion.Tool\6.0.0\dotnet-gitversion.exe

arturcic commented 1 month ago

In that case just use v6