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

Special handling of cmake scripts #405

Closed

Conversation

winksaville
Copy link
Contributor

This fix only works with cmake, but I suspect other scripting languages
would have similar problems. I'm hoping there is a better solution, but
something like this does work for my particular problem.

The problem is having the first line of scripts be: Path="xxx:${PATH}"
where xxx is rc.ExtraPath, does not work for all scripting languages.
For example: 'cmake -P {0}' is used by Cristian Adam HelloWorld:
https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml#:~:text=shell:

Here is some test code:

name: CMake Build Matrix

on: [push, pull_request]

env:
CMAKE_VERSION: 3.18.3
NINJA_VERSION: 1.10.1
BUILD_TYPE: Release
CCACHE_VERSION: 3.7.7

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Latest GCC",
artifact: "Linux.7z",
os: ubuntu-latest,
cc: "gcc",
cxx: "g++",
}

steps:
  - uses: actions/checkout@v1

  - name: Test bash
    shell: bash
    run: |
      echo Using host CMake version: ${CMAKE_VERSION}

  - name: Test cmake
    shell: cmake -P {0}
    run: |
      message(STATUS "hello from cmake script")

Executing the above results in the following error:

$ ~/prgs/nektos/forks/act/act
[CMake Build Matrix/Ubuntu Latest GCC] 🧪 Matrix: map[config:map[artifact:Linux.7z cc:gcc cxx:g++ name:Ubuntu Latest GCC os:ubuntu-latest]]
[CMake Build Matrix/Ubuntu Latest GCC] 🚀 Start image=ubuntu-with-hello
[CMake Build Matrix/Ubuntu Latest GCC] 🐳 docker run image=ubuntu-with-hello entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[CMake Build Matrix/Ubuntu Latest GCC] 🐳 docker cp src=/home/wink/prgs/cmake/projects/gha-cmake-HelloWorld/. dst=/github/workspace
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run actions/checkout@v1
[CMake Build Matrix/Ubuntu Latest GCC] ✅ Success - actions/checkout@v1
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run Test bash
| Using host CMake version: 3.18.3
[CMake Build Matrix/Ubuntu Latest GCC] ✅ Success - Test bash
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run Test cmake
| CMake Error at /github/workflow/2:1:
| Parse error. Expected a command name, got unquoted argument with text
| "PATH=":${PATH}"".
|
|
| CMake Error: Error processing file: /github/workflow/2
[CMake Build Matrix/Ubuntu Latest GCC] ❌ Failure - Test cmake
Error: exit with FAILURE: 1

With this change the output is:

$ ~/prgs/nektos/forks/act/act
[CMake Build Matrix/Ubuntu Latest GCC] 🧪 Matrix: map[config:map[artifact:Linux.7z cc:gcc cxx:g++ name:Ubuntu Latest GCC os:ubuntu-latest]]
[CMake Build Matrix/Ubuntu Latest GCC] 🚀 Start image=ubuntu-with-hello
[CMake Build Matrix/Ubuntu Latest GCC] 🐳 docker run image=ubuntu-with-hello entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[CMake Build Matrix/Ubuntu Latest GCC] 🐳 docker cp src=/home/wink/prgs/cmake/projects/gha-cmake-HelloWorld/. dst=/github/workspace
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run actions/checkout@v1
[CMake Build Matrix/Ubuntu Latest GCC] ✅ Success - actions/checkout@v1
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run Test bash
| Using host CMake version: 3.18.3
[CMake Build Matrix/Ubuntu Latest GCC] ✅ Success - Test bash
[CMake Build Matrix/Ubuntu Latest GCC] ⭐ Run Test cmake
| -- hello from cmake script
[CMake Build Matrix/Ubuntu Latest GCC] ✅ Success - Test cmake

This fix only works with cmake, but I suspect other scripting languages
would have similar problems. I'm hoping there is a better solution, but
something like this does work for my particular problem.

The problem is having the first line of scripts be: Path="xxx:${PATH}"
where xxx is rc.ExtraPath, does not work for all scripting languages.
For example: 'cmake -P {0}' is used by Cristian Adam HelloWorld:
  https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml#:~:text=shell:

Here is some test code:

 name: CMake Build Matrix

 on: [push, pull_request]

 env:
  CMAKE_VERSION: 3.18.3
  NINJA_VERSION: 1.10.1
  BUILD_TYPE: Release
  CCACHE_VERSION: 3.7.7

 jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
          - {
              name: "Ubuntu Latest GCC",
              artifact: "Linux.7z",
              os: ubuntu-latest,
              cc: "gcc",
              cxx: "g++",
            }

    steps:
      - uses: actions/checkout@v1

      - name: Test bash
        shell: bash
        run: |
          echo Using host CMake version: ${CMAKE_VERSION}

      - name: Test cmake
        shell: cmake -P {0}
        run: |
          message(STATUS "hello from cmake script")


Executing the above results in the following error:

  $ ~/prgs/nektos/forks/act/act
  [CMake Build Matrix/Ubuntu Latest GCC] 🧪  Matrix: map[config:map[artifact:Linux.7z cc:gcc cxx:g++ name:Ubuntu Latest GCC os:ubuntu-latest]]
  [CMake Build Matrix/Ubuntu Latest GCC] 🚀  Start image=ubuntu-with-hello
  [CMake Build Matrix/Ubuntu Latest GCC]   🐳  docker run image=ubuntu-with-hello entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
  [CMake Build Matrix/Ubuntu Latest GCC]   🐳  docker cp src=/home/wink/prgs/cmake/projects/gha-cmake-HelloWorld/. dst=/github/workspace
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run actions/checkout@v1
  [CMake Build Matrix/Ubuntu Latest GCC]   ✅  Success - actions/checkout@v1
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run Test bash
  | Using host CMake version: 3.18.3
  [CMake Build Matrix/Ubuntu Latest GCC]   ✅  Success - Test bash
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run Test cmake
  | CMake Error at /github/workflow/2:1:
  |   Parse error.  Expected a command name, got unquoted argument with text
  |   "PATH=":${PATH}"".
  |
  |
  | CMake Error: Error processing file: /github/workflow/2
  [CMake Build Matrix/Ubuntu Latest GCC]   ❌  Failure - Test cmake
  Error: exit with `FAILURE`: 1

With this change the output is:

  $ ~/prgs/nektos/forks/act/act
  [CMake Build Matrix/Ubuntu Latest GCC] 🧪  Matrix: map[config:map[artifact:Linux.7z cc:gcc cxx:g++ name:Ubuntu Latest GCC os:ubuntu-latest]]
  [CMake Build Matrix/Ubuntu Latest GCC] 🚀  Start image=ubuntu-with-hello
  [CMake Build Matrix/Ubuntu Latest GCC]   🐳  docker run image=ubuntu-with-hello entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
  [CMake Build Matrix/Ubuntu Latest GCC]   🐳  docker cp src=/home/wink/prgs/cmake/projects/gha-cmake-HelloWorld/. dst=/github/workspace
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run actions/checkout@v1
  [CMake Build Matrix/Ubuntu Latest GCC]   ✅  Success - actions/checkout@v1
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run Test bash
  | Using host CMake version: 3.18.3
  [CMake Build Matrix/Ubuntu Latest GCC]   ✅  Success - Test bash
  [CMake Build Matrix/Ubuntu Latest GCC] ⭐  Run Test cmake
  | -- hello from cmake script
  [CMake Build Matrix/Ubuntu Latest GCC]   ✅  Success - Test cmake
@cplee
Copy link
Contributor

cplee commented Nov 1, 2020

thanks @winksaville - couple thoughts:

  • rather than explicitly skipping the PATH for cmake, can we change it to ONLY add path for a list of supported shells?
  • can you include a test case for this?

@winksaville
Copy link
Contributor Author

Closing this as I think PR #406 is better, but can resurrect this if this is the way you'd like to go.

@winksaville winksaville closed this Nov 2, 2020
@winksaville winksaville deleted the Special-handling-cmake-scripts branch November 2, 2020 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants