GithubHelp home page GithubHelp logo

Comments (4)

ShahradR avatar ShahradR commented on August 29, 2024

Because both the entrypoint and args both expect lists, we can't call taskcat directly without a script to tokenize the string and create a CMD array for Docker to consume. While there is some string manipulation available from yaml when running the tests (not sure if it's provided by YAML itself, act, or if it's even available from GitHub Actions), it probably isn't enough to make it work without the need for a Dockerfile and an entrypoint script to split the command into tokens.

Using the .split() function to return a list

A .split() function actually works against stings. Unfortunately, the array is cast back into a string when passed to the Docker container and taskcat still throws an error.

action.yaml

runs:
  using: docker
  image: docker://taskcat/taskcat:latest
  entrypoint:
    - taskcat
  args:
    - ${{ inputs.commands.split(" ") }}

.github/workflow

steps:
  - uses: actions/checkout@v2
  - name: taskcat
    uses: ./../../../../
    with:
      commands: test run

act output

[main.yaml/taskcat] ⭐  Run taskcat
[main.yaml/taskcat]   🐳  docker run image=taskcat/taskcat:latest entrypoint=["taskcat"] cmd=["test,run"]
[main.yaml/taskcat]   |  _            _             _   
[main.yaml/taskcat]   | | |_ __ _ ___| | _____ __ _| |_ 
[main.yaml/taskcat]   | | __/ _` / __| |/ / __/ _` | __|
[main.yaml/taskcat]   | | || (_| \__ \   < (_| (_| | |_ 
[main.yaml/taskcat]   |  \__\__,_|___/_|\_\___\__,_|\__|
[main.yaml/taskcat]   |                                 
[main.yaml/taskcat]   | 
[main.yaml/taskcat]   | 
[main.yaml/taskcat]   | version 0.9.18
[main.yaml/taskcat]   | usage: taskcat [args] <command> [args] [subcommand] [args] 
[main.yaml/taskcat]   | taskcat: error: argument : invalid choice: 'test,run' (choose from 'delete', 'deploy', 'lint', 'list', 'package', 'test', 'update-ami', 'upload')
[main.yaml/taskcat]   ❌  Failure - taskcat

Passing list values using the index

Because the split() function actually returns an array, we can get individual items by referencing its index. However, because we can't predict how many arguments will be passed, this is useless without the ability to iterate and dynamically build the args list.

action.yaml

runs:
  using: docker
  image: docker://taskcat/taskcat:latest
  entrypoint:
    - taskcat
  args:
    - ${{ inputs.commands.split(" ")[0] }}

.github/workflow

steps:
  - uses: actions/checkout@v2
  - name: taskcat
    uses: ./../../../../
    with:
      commands: test run

act output

[main.yaml/taskcat] ⭐  Run taskcat
[main.yaml/taskcat]   🐳  docker run image=taskcat/taskcat:latest entrypoint=["taskcat"] cmd=["test"]
[main.yaml/taskcat]   |  _            _             _   
[main.yaml/taskcat]   | | |_ __ _ ___| | _____ __ _| |_ 
[main.yaml/taskcat]   | | __/ _` / __| |/ / __/ _` | __|
[main.yaml/taskcat]   | | || (_| \__ \   < (_| (_| | |_ 
[main.yaml/taskcat]   |  \__\__,_|___/_|\_\___\__,_|\__|
[main.yaml/taskcat]   |                                 
[main.yaml/taskcat]   | 
[main.yaml/taskcat]   | 
[main.yaml/taskcat]   | version 0.9.18
[main.yaml/taskcat]   | usage: taskcat [args] test [args] [subcommand] [args] 
[main.yaml/taskcat]   | taskcat [args] <command> [args] [subcommand] [args] test: error: the following arguments are required: 
[main.yaml/taskcat]   ❌  Failure - taskcat

from action-taskcat.

github-actions avatar github-actions commented on August 29, 2024

πŸŽ‰ This issue has been resolved in version 1.0.0-develop.2 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

from action-taskcat.

github-actions avatar github-actions commented on August 29, 2024

πŸŽ‰ This issue has been resolved in version 1.0.3-develop.1 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

from action-taskcat.

github-actions avatar github-actions commented on August 29, 2024

πŸŽ‰ This issue has been resolved in version 1.0.3 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€

from action-taskcat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.