I am trying to use a self-hosted Windows-VM to run west for repo management, python to run some scripts, and git to push back to the repo.
The work is to generate files using python from repo-A
as artifacts to check-into repo-B
. I had to use Windows because the file generation tools only works on Windows.
I have a self-hosted build agent setup and able to run github actions on it.
On the VM side, these are the path to the relevant commands (showing that they are properly added to $PATH)
PS C:\TouchGFXProjects\wallSwitch-gui-hesPrototype-480-272> gcm west; gcm tgfx.exe; gcm python; gcm git
CommandType Name Version Source
----------- ---- ------- ------
Application west.exe 0.0.0.0 C:\Users\tgfx\AppData\Local\Programs\Python\Python39\Scripts\west.exe
Application tgfx.exe 4.16.1.0 C:\TouchGFX\4.16.1\designer\tgfx.exe
Application python.exe 3.9.515... C:\Users\tgfx\AppData\Local\Programs\Python\Python39\python.exe
Application git.exe 2.31.1.1 C:\Program Files\Git\cmd\git.exe
The VM's execution Policy is set to:
PS C:\Windows\system32> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Bypass
All the scrips and execution steps ran well when executed from powerShell on the VM itself.
But when I invoke the github runner, the behaviour indicates that it does not know where the executables are, despite it being known in $PATH
(see debug output below).
github runner script:
name: CI
on:
workflow_dispatch:
pull_request:
branches:
- master
- 'feature/**'
jobs:
# Test-path access using powerShell shell
test-path-powerShell:
runs-on: [self-hosted, Windows, X64, touchGFX]
steps:
- name: Display the path
run: echo ${env:PATH}
shell: powershell
continue-on-error: true
- name: Check that we know where python is
run: gcm python
shell: powershell
continue-on-error: true
- name: Test calling "python.exe --version" via powershell
run: python.exe --version
shell: powershell
continue-on-error: true
- name: Test calling "python.exe --version" via powershell (abs path)
run: C:\Users\tgfx\AppData\Local\Programs\Python\Python39\python.exe --version
shell: powershell
continue-on-error: true
When running on the github runner, the echo ${env:PATH} command shows:
Run echo ${env:PATH}
C:\TouchGFX\4.16.1\designer;C:\Users\tgfx\AppData\Local\Programs\Python\Python39\;C:\Users\tgfx\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\tgfx\AppData\Local\Programs\Python\Python39\Lib\site-packages;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\WindowsApps
Which means it should have the location for python.exe
However, all commands that attempts to access it (even with Absolute path) returns errors like this:
Run gcm python
gcm : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\actions-runner\_work\_temp\c19697cd-d5e0-4102-a7b6-5f357f82aa91.ps1:2 char:1
+ gcm python
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
I also tried appending python to $GITHUB_PATH with:
echo "C:\Users\tgfx\AppData\Local\Programs\Python\Python39" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
But that just extends the output of echo ${env:PATH} and still leads to the same error on execution.
What am I missing?
Thanks for everyone's time.
In my setup, the missing piece is the access permissions of the
Github Action Runner Service
. The default ofNT AUTHORITY\NETWORK SERVICE
used when installing the runner as a service does not work. I tested changing the service's permission to bothLocal Service
andLocal System
and found thatLocal System
works.You need to restart the service when changing the permissions for it to take effect.
Within the github runner workflow, you can validate the settings using the
whoami
command from powershell.