docs icon indicating copy to clipboard operation
docs copied to clipboard

`fromJSON` should include an example of an array for `runs-on`

Open jsoref opened this issue 3 years ago • 12 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on

What part(s) of the article would you like to see updated?

Add an example-returning-a-runs-on-array similar to https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object

Additional information

Normally in JSON, the basic types are:

  • null
  • booleans
  • numbers
  • strings
  • arrays
  • maps

In GitHub Workflows, strings are strange in that, maybe? they don't need to be wrapped in quotes, some of the time?

Except, in the example https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object, keys and values are wrapped in quotes:

        run: echo "::set-output name=matrix::{\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"},{\"project\":\"bar\",\"config\":\"Release\"}]}"

When I tried to add some magic for a dynamic runs-on that would sometimes be a string and sometimes be an array, I naively assumed that I'd need to wrap my array elements in quotes, but that didn't do the right thing.

See this PR: https://github.com/commercialhaskell/stack/pull/5856#discussion_r966158231

We can't seem to get this to work...

merge change https://github.com/commercialhaskell/stack/runs/8254107160?check_suite_focus=true

Requested labels: [self-hosted, linux, ARM64]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8254719771?check_suite_focus=true

Requested labels: "[self-hosted, linux, ARM64]"
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8255017367?check_suite_focus=true

Requested labels: ["self-hosted", "linux", "ARM64"]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8255163889?check_suite_focus=true

Requested labels: [self-hosted, linux, ARM64]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

The last output appears to match the output for the working world workflow https://github.com/commercialhaskell/stack/runs/8255316015?check_suite_focus=true

    runs-on: [self-hosted, linux, ARM64]

jsoref avatar Sep 08 '22 17:09 jsoref

The working example is apparently https://github.com/commercialhaskell/stack/pull/5856/commits/ba7008251f8bcec6ac0bd11f26031b760b7d68e6 Updated based on the deprecation of ::set-output: https://github.com/commercialhaskell/stack/commit/963ba3381ce933da4421146686d034d8381d4afa

https://github.com/commercialhaskell/stack/blob/1931538a4a3e5058d9432bff68b397c6804a96f2/.github/workflows/integration-tests.yml#L163

          echo "arm64=['self-hosted', 'linux', 'ARM64']" >> $GITHUB_OUTPUT

https://github.com/commercialhaskell/stack/blob/ba7008251f8bcec6ac0bd11f26031b760b7d68e6/.github/workflows/integration-tests.yml#L122

    runs-on: ${{ fromJSON(needs.configuration.outputs.arm64) }}

jsoref avatar Sep 08 '22 19:09 jsoref

👋 @jsoref Thanks for opening an issue. We appreciate all the details, too.

I'll get this triaged for review. ⚡

cmwilson21 avatar Sep 09 '22 12:09 cmwilson21

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on

What part(s) of the article would you like to see updated?

Add an example-returning-a-runs-on-array similar to https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object

Additional information

Normally in JSON, the basic types are:

  • null
  • booleans
  • numbers
  • strings
  • arrays
  • maps

In GitHub Workflows, strings are strange in that, maybe? they don't need to be wrapped in quotes, some of the time?

Except, in the example https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object, keys and values are wrapped in quotes:

        run: echo "::set-output name=matrix::{\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"},{\"project\":\"bar\",\"config\":\"Release\"}]}"

When I tried to add some magic for a dynamic runs-on that would sometimes be a string and sometimes be an array, I naively assumed that I'd need to wrap my array elements in quotes, but that didn't do the right thing.

See this PR: commercialhaskell/stack#5856 (comment)

We can't seem to get this to work...

merge change https://github.com/commercialhaskell/stack/runs/8254107160?check_suite_focus=true

Requested labels: [self-hosted, linux, ARM64]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8254719771?check_suite_focus=true

Requested labels: "[self-hosted, linux, ARM64]"
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8255017367?check_suite_focus=true

Requested labels: ["self-hosted", "linux", "ARM64"]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

merge change https://github.com/commercialhaskell/stack/runs/8255163889?check_suite_focus=true

Requested labels: [self-hosted, linux, ARM64]
Job defined at: commercialhaskell/stack/.github/workflows/integration-tests.yml@refs/pull/5856/merge
Waiting for a runner to pick up this job...

The last output appears to match the output for the working world workflow https://github.com/commercialhaskell/stack/runs/8255316015?check_suite_focus=true

    runs-on: [self-hosted, linux, ARM64]

sergcarpov avatar Sep 13 '22 08:09 sergcarpov

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Nov 02 '22 06:11 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Dec 09 '22 16:12 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jan 07 '23 16:01 github-actions[bot]

new year new task here's to bigger, brighter and, how could it get any better guys.

ray2glicense avatar Jan 07 '23 17:01 ray2glicense

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Feb 07 '23 16:02 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Mar 08 '23 16:03 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Apr 06 '23 16:04 github-actions[bot]

Help me establish a link to github for an otp on the missing simcard

Mashudaamri avatar Apr 11 '23 16:04 Mashudaamri

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar May 10 '23 16:05 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jun 08 '23 16:06 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jul 07 '23 16:07 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Aug 06 '23 16:08 github-actions[bot]

I've had a look at this but am not familiar enough with this area to know whether, where, and how this should be documented, so I've asked for some SME assistance. Hopefully we can move this issue along soon.

hubwriter avatar Aug 24 '23 13:08 hubwriter

The answer I've had on this is that the strings provided as the value of runs-on can be quoted but don't need to be where a simple word is used, like:

runs-on: [self-hosted, linux, x64, gpu]

Expressions must be quoted:

runs-on: [self-hosted, "${{ inputs.chosen-os }}"]

Perhaps to resolve this issue we could add some clarification of this to the syntax details for runs-on: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on

hubwriter avatar Sep 13 '23 10:09 hubwriter