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

Directly use the taskcat/taskcat Docker container #20

Closed
ShahradR opened this issue Jul 11, 2020 · 4 comments · Fixed by #32 or #33
Closed

Directly use the taskcat/taskcat Docker container #20

ShahradR opened this issue Jul 11, 2020 · 4 comments · Fixed by #32 or #33
Assignees

Comments

@ShahradR
Copy link
Owner

Eliminate the need for a local Dockerfile—we can directly use the taskcat/taskcat:latest container image on Docker Hub. Custom scripts can be executed without the need to define a Dockerfile by using the pre-entrypoint and post-entrypoint.

ShahradR added a commit that referenced this issue Jul 11, 2020
Add a test to verify the success scenario, where taskcat is provided
with valid AWS credentials and deploys a CloudFormation template.

Because the mock layer has not yet been implemented, we are actually
hitting AWS to run these tests. The AWS credentials are provided to the
test via Maven Surefire parameters passed through the `mvn` command from
the workflow. The credentials themselves are stored as repository
secrets.

We implement the success scenario ahead of the changes to the Docker
container to ensure that the action works both before and after we use
the taskcat/taskcat container instead of the local Dockerfile.

Associated issue: #20
@ShahradR ShahradR self-assigned this Jul 11, 2020
@ShahradR ShahradR added the enhancement New feature or request label Jul 11, 2020
ShahradR added a commit that referenced this issue Jul 11, 2020
When running the JUnit tests through GitHub Actions, we often end up
with "java.lang.IllegalThreadStateExceptions" being thrown due to
asserts being ran before act has finished executing.

By adding the Process.waitFor() call before the assertions, we wait
until the act process has finished before running the rest of the tests.

Associated issue: #20
@ShahradR
Copy link
Owner Author

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

ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test that prints taskcat's help output by calling taskcat with no
commands. This test is designed to act as a starting point for the
implementation of a generic `commands` input to the GitHub Action,
allowing users the flexibility of running arbitrary tasckat commands,
rather than the hard-coded `taskcat test run`.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Allow users of this action to run any supported taskcat command, rather
than the previously hard-coded `taskcat test run`.

This commit also removes the dependency on the local Dockerfile, in
favor of the official taskcat/tasckat container hosted on Docker Hub.
Commands are passed to the container by overriding the entrypoint
through the action.yaml file.

The `taskcat` invocation itself is also handled by the action. Users
only need to specify the command, subcommands, and arguments to be
passed to run their tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test to verify the success scenario, where taskcat is provided
with valid AWS credentials and deploys a CloudFormation template.

Because the mock layer has not yet been implemented, we are actually
hitting AWS to run these tests. The AWS credentials are provided to the
test via Maven Surefire parameters passed through the `mvn` command from
the workflow. The credentials themselves are stored as repository
secrets.

We implement the success scenario ahead of the changes to the Docker
container to ensure that the action works both before and after we use
the taskcat/taskcat container instead of the local Dockerfile.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
When running the JUnit tests through GitHub Actions, we often end up
with "java.lang.IllegalThreadStateExceptions" being thrown due to
asserts being ran before act has finished executing.

By adding the Process.waitFor() call before the assertions, we wait
until the act process has finished before running the rest of the tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test that prints taskcat's help output by calling taskcat with no
commands. This test is designed to act as a starting point for the
implementation of a generic `commands` input to the GitHub Action,
allowing users the flexibility of running arbitrary tasckat commands,
rather than the hard-coded `taskcat test run`.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Allow users of this action to run any supported taskcat command, rather
than the previously hard-coded `taskcat test run`.

This commit also removes the dependency on the local Dockerfile, in
favor of the official taskcat/tasckat container hosted on Docker Hub.
Commands are passed to the container by overriding the entrypoint
through the action.yaml file.

The `taskcat` invocation itself is also handled by the action. Users
only need to specify the command, subcommands, and arguments to be
passed to run their tests.

Associated issue: #20
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.0-develop.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test to verify the success scenario, where taskcat is provided
with valid AWS credentials and deploys a CloudFormation template.

Because the mock layer has not yet been implemented, we are actually
hitting AWS to run these tests. The AWS credentials are provided to the
test via Maven Surefire parameters passed through the `mvn` command from
the workflow. The credentials themselves are stored as repository
secrets.

We implement the success scenario ahead of the changes to the Docker
container to ensure that the action works both before and after we use
the taskcat/taskcat container instead of the local Dockerfile.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
When running the JUnit tests through GitHub Actions, we often end up
with "java.lang.IllegalThreadStateExceptions" being thrown due to
asserts being ran before act has finished executing.

By adding the Process.waitFor() call before the assertions, we wait
until the act process has finished before running the rest of the tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test that prints taskcat's help output by calling taskcat with no
commands. This test is designed to act as a starting point for the
implementation of a generic `commands` input to the GitHub Action,
allowing users the flexibility of running arbitrary tasckat commands,
rather than the hard-coded `taskcat test run`.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Allow users of this action to run any supported taskcat command, rather
than the previously hard-coded `taskcat test run`.

This commit also removes the dependency on the local Dockerfile, in
favor of the official taskcat/tasckat container hosted on Docker Hub.
Commands are passed to the container by overriding the entrypoint
through the action.yaml file.

The `taskcat` invocation itself is also handled by the action. Users
only need to specify the command, subcommands, and arguments to be
passed to run their tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test to verify the success scenario, where taskcat is provided
with valid AWS credentials and deploys a CloudFormation template.

Because the mock layer has not yet been implemented, we are actually
hitting AWS to run these tests. The AWS credentials are provided to the
test via Maven Surefire parameters passed through the `mvn` command from
the workflow. The credentials themselves are stored as repository
secrets.

We implement the success scenario ahead of the changes to the Docker
container to ensure that the action works both before and after we use
the taskcat/taskcat container instead of the local Dockerfile.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
When running the JUnit tests through GitHub Actions, we often end up
with "java.lang.IllegalThreadStateExceptions" being thrown due to
asserts being ran before act has finished executing.

By adding the Process.waitFor() call before the assertions, we wait
until the act process has finished before running the rest of the tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Add a test that prints taskcat's help output by calling taskcat with no
commands. This test is designed to act as a starting point for the
implementation of a generic `commands` input to the GitHub Action,
allowing users the flexibility of running arbitrary tasckat commands,
rather than the hard-coded `taskcat test run`.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 12, 2020
Allow users of this action to run any supported taskcat command, rather
than the previously hard-coded `taskcat test run`.

This commit also removes the dependency on the local Dockerfile, in
favor of the official taskcat/tasckat container hosted on Docker Hub.
Commands are passed to the container by overriding the entrypoint
through the action.yaml file.

The `taskcat` invocation itself is also handled by the action. Users
only need to specify the command, subcommands, and arguments to be
passed to run their tests.

Associated issue: #20
ShahradR added a commit that referenced this issue Jul 19, 2020
After trying to reduce dependencies and eliminate the need to create a
new container to run taskcat in GitHub workflows, it seems that it might
be easier to simply control the execution from within a script,
bypassing the restrictions set by the GitHub Action's metadata syntax.

This commit re-introduces the entrypoint.sh script and the Dockerfile.
Building on the official taskcat/taskcat container, the script allows
users to pass arbitrary commands to taskcat from GitHub workflows, as
they would when invoking the taskcat from the command line.

Associated issues: #20, #26
ShahradR added a commit that referenced this issue Jul 19, 2020
Due to validation and implementation differences between act and the
GitHub hosted runners, we cannot solely rely on the JUnit tests to ensure
the correct functionality of the action.

To help catch errors, a job was added to this repository's GitHub
workflow, which runs the example in this project's README file against
the sample CloudFormation template used by the JUnit tests.

While we can only rely on the action's return code to determine if the
execution was successful, it can act as a simple tool to detect errors
that act might have missed.

Associated issue: #20, #26
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.3-develop.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

ShahradR added a commit that referenced this issue Nov 29, 2020
docs(readme): update the project's README file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment