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

Using molecule_working_dir leads to "can't cd - No such file or directory" #60

Closed
thedatabaseme opened this issue Jan 16, 2022 · 1 comment

Comments

@thedatabaseme
Copy link

I'm playing around with your Github Action and have created a sample role with a default molecule scenario. The Github repository root is not the Ansible role root directory, therefore I set the molecule_working_dir parameter accordingly (see tree below).

Here's my workflow file:

name: Molecule

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  molecule:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          path: "${{ github.repository }}"
          
      - name: Molecule
        uses: gofrolist/molecule-action@v2
        with:
          molecule_command: test
          molecule_args: -d docker
          molecule_working_dir: ansible/molecule/molecule_test_role
        env:
          ANSIBLE_FORCE_COLOR: '1'

When running the action. I receive the following error message using the upper definition:

/usr/bin/docker run --name gofrolistmoleculev2_d3497d --label 9916a7 --workdir /github/workspace --rm -e ANSIBLE_FORCE_COLOR -e INPUT_MOLECULE_COMMAND -e INPUT_MOLECULE_ARGS -e INPUT_MOLECULE_WORKING_DIR -e INPUT_MOLECULE_OPTIONS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/cookbooks/cookbooks":"/github/workspace" gofrolist/molecule:v2
/bin/sh: cd: line 1: can't cd to ansible/molecule/molecule_test_role: No such file or directory
tree
.
└── ansible
    ├── molecule
    │   └── molecule_test_role
    │       ├── README.md
    │       ├── defaults
    │       │   └── main.yml
    │       ├── files
    │       ├── handlers
    │       │   └── main.yml
    │       ├── meta
    │       │   └── main.yml
    │       ├── molecule
    │       │   └── default
    │       │       ├── converge.yml
    │       │       ├── molecule.yml
    │       │       └── verify.yml
    │       ├── tasks
    │       │   └── main.yml
    │       ├── templates
    │       ├── tests
    │       │   ├── inventory
    │       │   └── test.yml
    │       └── vars
    │           └── main.yml

Can you advise what I'm might doing wrong here?

@thedatabaseme
Copy link
Author

Ok, found it out by myself. Would be nice, if you update the README and adding an example call of molecule_working_dir.
It has to be like so:

molecule_working_dir: <GITHUB_USERNAME>/<GITHUB_REPO_NAME>/<PATH>/<TO>/<ROLE>/<ROOT>

So in my case it was:

molecule_working_dir: thedatabaseme/cookbooks/ansible/molecule/molecule_test_role

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

No branches or pull requests

1 participant