Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GITHUB_WORKSPACE evaluting to blank #1794

Closed
2 of 6 tasks
timheuer opened this issue Oct 12, 2020 · 6 comments
Closed
2 of 6 tasks

GITHUB_WORKSPACE evaluting to blank #1794

timheuer opened this issue Oct 12, 2020 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@timheuer
Copy link
Contributor

Description
Per the documentation: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
The GITHUB_WORKSPACE variable should evaluate to a path. When using in a workflow (after checkout) however, it is evaluating to nothing and not providing the path both on ubuntu-latest/windows-latest

Example: https://github.com/timheuer/buildtest/runs/1243185809?check_suite_focus=true#step:3:2 from workflow: https://github.com/timheuer/buildtest/blob/master/.github/workflows/build.yml#L40

Area for Triage:
Servers

Question, Bug, or Feature?:
Bug

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
I expect to see a full path to the workspace per documentation

Actual behavior
A blank variable is provided

Repro steps
See example repo that has an echo of the variable evaluating to nothing

@maxim-lobanov
Copy link
Contributor

Hello @timheuer , you use incorrect way to reference this variable.
If you would like to reference GITHUB_WORKSPACE as environment variable, you should use:

$env:GITHUB_WORKSPACE # powershell
$GITHUB_WORKSPACE # bash

If you would like to use {{}} syntax, you should use

${{ github.workspace }} 

Please follow documentation: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context

@LanceMcCarthy
Copy link

LanceMcCarthy commented Oct 12, 2020

That's the confusing part. Yes, you can directly use the GitHub context ${{ github.workspace }}. However, according to the docs, you can read the workspace GitHub context value as an environment variable.

image

Since we know this $env:GITHUB_WORKSPACE works in PowerShell... ${{ env:GITHUB_WORKSPACE }} should also work.

Is there an easy way to test commands on a local runner without requiring a trigger? Running commands inside PowerShell only gets you so far, especially when you rely on the way Actions packs up the steps as ps1 files.

@maxim-lobanov
Copy link
Contributor

I don't have much context about this logic because it is owned by https://github.com/actions/runner.
In my understanding, ${{ env:* }} is not equal PS $env:*. Through ${{ env: }} you can only access the variables that are set by your workflow because such expressions are evaluated by runner and they don't have an access to machine environment.

The env context contains environment variables that have been set in a workflow, job, or step

so you can access only variables that are set in YAML like below or similar

env:
  SERVER: production

@LeonidLapshin LeonidLapshin added question Further information is requested and removed needs triage labels Oct 12, 2020
@maxim-lobanov maxim-lobanov self-assigned this Oct 13, 2020
@maxim-lobanov
Copy link
Contributor

Closing this one but please let me know if you have any questions

@edwardskrod
Copy link

That's the confusing part. Yes, you can directly use the GitHub context ${{ github.workspace }}. However, according to the docs, you can read the workspace GitHub context value as an environment variable.

image

Since we know this $env:GITHUB_WORKSPACE works in PowerShell... ${{ env:GITHUB_WORKSPACE }} should also work.

Is there an easy way to test commands on a local runner without requiring a trigger? Running commands inside PowerShell only gets you so far, especially when you rely on the way Actions packs up the steps as ps1 files.

I just ran into this same issue, thinking I could use "${{ env:GITHUB_WORKSPACE }}"

7h3Rabbit added a commit to Webperf-se/webperf_core that referenced this issue Dec 22, 2022
michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue Feb 9, 2023
@michael-hawker
Copy link

Ran into this as well... these variables are still called out in this doc here: https://docs.github.com/en/actions/learn-github-actions/variables (which I find very unhelpful at explaining how to setup and use env properly).

The note in blue at the bottom of the long list of variable examples is not highlighted well enough:

Most of the default variables have a corresponding, and similarly named, context property. For example, the value of the GITHUB_REF variable can be read during workflow processing using the ${{ github.ref }} context property.

michael-hawker added a commit to CommunityToolkit/Labs-Windows that referenced this issue Feb 21, 2023
* Moved project heads to common folder

* Fixed broken reference to props file

* Fix broken path references

* Fixed broken file references

* Fixed broken path

* Move asset references to props file

* Consolidated ProjectHeads and supporting infrastructure

* Migrating projects to new infra

* Migrating files to new infra

* Added missing assemblyname and rootnamespace declaration

* Fixed building WinAppSdk

* Fixed build errors for UWP under "All" solution

* Fixed working directory for UseTargetFrameworks.ps1

* Switch GenerateSingleSampleHeads.ps1 to use dotnet templating tool

Update WindowsAppSDK version and MSTest tools
Add properties to allow tests to run on 1.2.x, see microsoft/testfx#1127
Remove solution files from experiments
Add bat file to copy heads and run slngen
Tested locally running all heads and tests for an experiment

* Update folder for linux CI build and Codespaces to WASM project

* Clean-up and re-work build script for testing the project template

* Use expanded form for environment variables everywhere

* Use repo root path for script when in working directory of template

* Use github syntax for environment variable for path, see actions/runner-images#1794

* Re-work path structure for project template test in ci

* Setup paths again to use full path into GenerateSingleSampleHeads script

* Fixed comment referencing outdated file name

* Use absolute path for project references in the "All" solution

* Removed leading directory separator on generated path

* Update slngen to fix build issues with not finding SDK due to global.json

See details in microsoft/slngen#453

* Add flag to build to enable easily getting diagnostics from tools

* Clean-up labels and conditions for diagnostics

* Add COREHOST_TRACE diagnostics for dotnet

* Move conditional for COREHOST_TRACE into step

* Just have COREHOST_TRACE defined at top

* Add calling dotnet --info

* Fixed missing markdown/cs files. Changed "Experiment" to "ToolkitComponent"

* Revert initial work renaming Experiment to Component.

* Fixed markdown exclude path

* Moved project out of double nested folder

* Removed restored files that should have been deleted

* Move SourceGenerators.Tests project up a folder and fix in build.yml path

Wasn't being built as was excluded from wildcard in solution generator

* Fixed path for test output

* Improved and shortened project names

* Rename LabsUITestMethod to UIThreadTestMethod

* Renamed to CommunityToolkit.Tooling.TestGen

* New names for UITestMethodAttribute and UITestMethodGenerator

* Fixed incorrect namespace

* Fixed a bad find/replace

* Renamed "all" component heads and App/Test shared projects

* Added "App" to app head names

* Fixed runtime error

* Move SourceGenerators.Tests project up a folder and fix in build.yml path

Wasn't being built as was excluded from wildcard in solution generator

* Fixed path for test output

* Improved and shortened project names

* Rename LabsUITestMethod to UIThreadTestMethod

* Renamed to CommunityToolkit.Tooling.TestGen

* New names for UITestMethodAttribute and UITestMethodGenerator

* Renamed "all" component heads and App/Test shared projects

* Added "App" to app head names

* Turn off diagnostics for our powershell scripts as slngen has error with diagnostics

Fix diagnostic flag detection

* Enable git long path support for the clean operation

* Update microsoft/setup-msbuild github action

* Cleaned up moved files that weren't deleted properly

* Update slngen to 9.5.4

Should hopefully resolve CI issues from microsoft/slngen#453 and its initial fix

---------

Co-authored-by: michael-hawker <24302614+michael-hawker@users.noreply.github.com>
michael-hawker added a commit to CommunityToolkit/Tooling-Windows-Submodule that referenced this issue Mar 14, 2023
* Moved project heads to common folder

* Fixed broken reference to props file

* Fix broken path references

* Fixed broken file references

* Fixed broken path

* Move asset references to props file

* Consolidated ProjectHeads and supporting infrastructure

* Migrating projects to new infra

* Migrating files to new infra

* Added missing assemblyname and rootnamespace declaration

* Fixed building WinAppSdk

* Fixed build errors for UWP under "All" solution

* Fixed working directory for UseTargetFrameworks.ps1

* Switch GenerateSingleSampleHeads.ps1 to use dotnet templating tool

Update WindowsAppSDK version and MSTest tools
Add properties to allow tests to run on 1.2.x, see microsoft/testfx#1127
Remove solution files from experiments
Add bat file to copy heads and run slngen
Tested locally running all heads and tests for an experiment

* Update folder for linux CI build and Codespaces to WASM project

* Clean-up and re-work build script for testing the project template

* Use expanded form for environment variables everywhere

* Use repo root path for script when in working directory of template

* Use github syntax for environment variable for path, see actions/runner-images#1794

* Re-work path structure for project template test in ci

* Setup paths again to use full path into GenerateSingleSampleHeads script

* Fixed comment referencing outdated file name

* Use absolute path for project references in the "All" solution

* Removed leading directory separator on generated path

* Update slngen to fix build issues with not finding SDK due to global.json

See details in microsoft/slngen#453

* Add flag to build to enable easily getting diagnostics from tools

* Clean-up labels and conditions for diagnostics

* Add COREHOST_TRACE diagnostics for dotnet

* Move conditional for COREHOST_TRACE into step

* Just have COREHOST_TRACE defined at top

* Add calling dotnet --info

* Fixed missing markdown/cs files. Changed "Experiment" to "ToolkitComponent"

* Revert initial work renaming Experiment to Component.

* Fixed markdown exclude path

* Moved project out of double nested folder

* Removed restored files that should have been deleted

* Move SourceGenerators.Tests project up a folder and fix in build.yml path

Wasn't being built as was excluded from wildcard in solution generator

* Fixed path for test output

* Improved and shortened project names

* Rename LabsUITestMethod to UIThreadTestMethod

* Renamed to CommunityToolkit.Tooling.TestGen

* New names for UITestMethodAttribute and UITestMethodGenerator

* Fixed incorrect namespace

* Fixed a bad find/replace

* Renamed "all" component heads and App/Test shared projects

* Added "App" to app head names

* Fixed runtime error

* Move SourceGenerators.Tests project up a folder and fix in build.yml path

Wasn't being built as was excluded from wildcard in solution generator

* Fixed path for test output

* Improved and shortened project names

* Rename LabsUITestMethod to UIThreadTestMethod

* Renamed to CommunityToolkit.Tooling.TestGen

* New names for UITestMethodAttribute and UITestMethodGenerator

* Renamed "all" component heads and App/Test shared projects

* Added "App" to app head names

* Turn off diagnostics for our powershell scripts as slngen has error with diagnostics

Fix diagnostic flag detection

* Enable git long path support for the clean operation

* Update microsoft/setup-msbuild github action

* Cleaned up moved files that weren't deleted properly

* Update slngen to 9.5.4

Should hopefully resolve CI issues from microsoft/slngen#453 and its initial fix

---------

Co-authored-by: michael-hawker <24302614+michael-hawker@users.noreply.github.com>
Baka632 referenced this issue in Baka632/aneot-vintage Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants