Giter VIP home page Giter VIP logo

molecule-action's People

Contributors

andiempettjisc avatar davestephens avatar dependabot[bot] avatar github-actions[bot] avatar gofrolist avatar koppor avatar lucascosti avatar marcemv90 avatar mnaser avatar rachmari avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

molecule-action's Issues

Molecule verify no more working

All tests failed on verify step, because it doesn't found pytest.

INFO     Executing Testinfra tests found in /github/workspace/roles/hm.rancher/molecule/default/tests/...
  DEBUG: ANSIBLE ENVIRONMENT:
  ANSIBLE_ASYNC_DIR: /tmp/.ansible_async
  ANSIBLE_COLLECTIONS_PATH: /github/home/.cache/ansible-compat/6a4f48/collections:/github/home/.cache/molecule/hm.rancher/default/collections:/github/home/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections
  ANSIBLE_CONFIG: /github/home/.cache/molecule/hm.rancher/default/ansible.cfg
  ANSIBLE_FILTER_PLUGINS: /usr/local/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/filter:/github/home/.cache/molecule/hm.rancher/default/plugins/filter:/github/workspace/roles/hm.rancher/plugins/filter:/github/home/.ansible/plugins/filter:/usr/share/ansible/plugins/filter
  ANSIBLE_FORCE_COLOR: '1'
  ANSIBLE_LIBRARY: /usr/local/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/modules:/usr/local/lib/python3.9/site-packages/molecule_plugins/vagrant/modules:/github/home/.cache/molecule/hm.rancher/default/library:/github/workspace/roles/hm.rancher/library:/github/home/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
  ANSIBLE_ROLES_PATH: /github/home/.cache/ansible-compat/6a4f48/roles:/github/home/.cache/molecule/hm.rancher/default/roles:/github/workspace/roles:/github/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/github/workspace/roles/hm.rancher/tests/roles:/github/home/.cache/ansible-compat/6a4f48/roles:/github/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/github/workspace/roles/hm.rancher/tests:/github/workspace/roles
  
  DEBUG: MOLECULE ENVIRONMENT:
  INPUT_MOLECULE_ARGS: --all -- --skip-tags notest
  INPUT_MOLECULE_COMMAND: test
  INPUT_MOLECULE_OPTIONS: --debug
  INPUT_MOLECULE_WORKING_DIR: roles/hm.rancher
  MOLECULE_DEBUG: 'True'
  MOLECULE_DEPENDENCY_NAME: galaxy
  MOLECULE_DRIVER_NAME: docker
  MOLECULE_ENV_FILE: /github/workspace/roles/hm.rancher/.env.yml
  MOLECULE_EPHEMERAL_DIRECTORY: /github/home/.cache/molecule/hm.rancher/default
  MOLECULE_FILE: /github/home/.cache/molecule/hm.rancher/default/molecule.yml
  MOLECULE_INSTANCE_CONFIG: /github/home/.cache/molecule/hm.rancher/default/instance_config.yml
  MOLECULE_INVENTORY_FILE: /github/home/.cache/molecule/hm.rancher/default/inventory/ansible_inventory.yml
  MOLECULE_PROJECT_DIRECTORY: /github/workspace/roles/hm.rancher
  MOLECULE_PROVISIONER_NAME: ansible
  MOLECULE_SCENARIO_DIRECTORY: /github/workspace/roles/hm.rancher/molecule/default
  MOLECULE_SCENARIO_NAME: default
  MOLECULE_STATE_FILE: /github/home/.cache/molecule/hm.rancher/default/state.yml
  MOLECULE_VERIFIER_NAME: testinfra
  MOLECULE_VERIFIER_TEST_DIRECTORY: /github/workspace/roles/hm.rancher/molecule/default/tests
  
  DEBUG: SHELL REPLAY:
  ANSIBLE_ASYNC_DIR=/tmp/.ansible_async ANSIBLE_COLLECTIONS_PATH=/github/home/.cache/ansible-compat/6a4f48/collections:/github/home/.cache/molecule/hm.rancher/default/collections:/github/home/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections ANSIBLE_CONFIG=/github/home/.cache/molecule/hm.rancher/default/ansible.cfg ANSIBLE_FILTER_PLUGINS=/usr/local/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/filter:/github/home/.cache/molecule/hm.rancher/default/plugins/filter:/github/workspace/roles/hm.rancher/plugins/filter:/github/home/.ansible/plugins/filter:/usr/share/ansible/plugins/filter ANSIBLE_FORCE_COLOR=1 ANSIBLE_LIBRARY=/usr/local/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/modules:/usr/local/lib/python3.9/site-packages/molecule_plugins/vagrant/modules:/github/home/.cache/molecule/hm.rancher/default/library:/github/workspace/roles/hm.rancher/library:/github/home/.ansible/plugins/modules:/usr/share/ansible/plugins/modules ANSIBLE_ROLES_PATH=/github/home/.cache/ansible-compat/6a4f48/roles:/github/home/.cache/molecule/hm.rancher/default/roles:/github/workspace/roles:/github/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/github/workspace/roles/hm.rancher/tests/roles:/github/home/.cache/ansible-compat/6a4f48/roles:/github/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/github/workspace/roles/hm.rancher/tests:/github/workspace/roles INPUT_MOLECULE_ARGS=--all -- --skip-tags notest INPUT_MOLECULE_COMMAND=test INPUT_MOLECULE_OPTIONS=--debug INPUT_MOLECULE_WORKING_DIR=roles/hm.rancher MOLECULE_DEBUG=True MOLECULE_DEPENDENCY_NAME=galaxy MOLECULE_DRIVER_NAME=docker MOLECULE_ENV_FILE=/github/workspace/roles/hm.rancher/.env.yml MOLECULE_EPHEMERAL_DIRECTORY=/github/home/.cache/molecule/hm.rancher/default MOLECULE_FILE=/github/home/.cache/molecule/hm.rancher/default/molecule.yml MOLECULE_INSTANCE_CONFIG=/github/home/.cache/molecule/hm.rancher/default/instance_config.yml MOLECULE_INVENTORY_FILE=/github/home/.cache/molecule/hm.rancher/default/inventory/ansible_inventory.yml MOLECULE_PROJECT_DIRECTORY=/github/workspace/roles/hm.rancher MOLECULE_PROVISIONER_NAME=ansible MOLECULE_SCENARIO_DIRECTORY=/github/workspace/roles/hm.rancher/molecule/default MOLECULE_SCENARIO_NAME=default MOLECULE_STATE_FILE=/github/home/.cache/molecule/hm.rancher/default/state.yml MOLECULE_VERIFIER_NAME=testinfra MOLECULE_VERIFIER_TEST_DIRECTORY=/github/workspace/roles/hm.rancher/molecule/default/tests
  
  /bin/sh: pytest: not found
WARNING  An error occurred during the test sequence action: 'verify'. Cleaning up.

Can you add it on docker image ?

Support `poetry run`

I need to run molecule under the poetry environment, so that I can use the pytest-subtests package in my testinfra tests.

I'm not sure if there's a way to do this without forking this repo and hacking it. Basically, instead of molecule being executed, I need poetry run molecule to be executed.

Suggestions?

CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting.

I'm running gofrolist/molecule-action@v2.
I've molecule/default/molecule.yml and molecule runs fine on local.
I've the repository checked out fine.
What I am missing?

##[debug]Result: '/home/runner/work/ansible-role-wine/ansible-role-wine'
##[debug]Loading env
Run gofrolist/molecule-action@v2
  with:
    molecule_command: test
    molecule_working_dir: /home/runner/work/ansible-role-wine/ansible-role-wine
...
/usr/bin/docker run --name gofrolistmoleculev2_8a536a --label 5bedb4 --workdir /github/workspace ... -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/ansible-role-wine/ansible-role-wine":"/github/workspace" gofrolist/molecule:v2
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.
##[debug]Docker Action run completed with exit code 1

Related: GH-2, but not solution is given.

Molecule version?

It'd be nice to have some info on the Molecule version used here.

I tried using this GH action to find it uses a Molecule version (2.x) incompatible with my project. This appears to not be changeable.

ansible-lint is unavailable

In the latest versions of v2 (since v2.2.25) ansible-lint is nog longer available in the action
because of this our CI action workflow using molecule doesn't work anymore

this seems to be because ansible-lint was removed from the pip lock file in this commit 283c847

and we can't use an earlier version of this action before ansible-lint was removed since the docker image used by the action is pinned at v2 https://github.com/gofrolist/molecule-action/blob/master/action.yml#L68

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

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?

Add molecule lint in docker image

Hi,

First of all I want to giva a positive feedback because this GH action is more flexible. At least this can change a working directory for molecule command: other available Molecule actions can't do this. So no ansible collection testing is possible, only roles. But I have a feature request.

Please add an opportunity to run lint molecule scenario like so:
poetry run pip install "molecule-plugins[lint]"

Otherwise this will fail:

INFO     default scenario test matrix: dependency, lint, destroy, syntax, create, prepare, converge, verify, side_effect, destroy
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
...
AttributeError: module 'molecule.command' has no attribute 'lint'. Did you mean: 'list'?

You can see a raw log on pastebin.

If you have an ansible galaxy dependencies already, this won't be installed using shell. So:

---

dependency:
  name: galaxy
  options:
    ignore-certs: true
    ignore-errors: true
  name: shell
  command: bash -c 'pip install "molecule-plugins[lint]" flake8 yamllint'
driver:
  name: docker

didn't worked for me.

Ofcourse, we can move linting to another job, but molecule lint scenario is quite standard. I also don't want to change all my tests files in default/ forlder when I use different testing environment (e.g. GitHub, GitLab, Travis CI, etc...)

May be also yamllint, it's on your choice. But ansible-lint use them also.

But I think pre-command before molecule run will be more usefull, people can install any packages, like:

  with:
    pre_command: pip install something

UPDATE:

Oh, Sorry for bothering, I was wrong about lint action: looks like it was removed since molecule v5. Here is a lot of URLs:

But pre-command is still good idea.

Failed to find required executable rsync

This actually suddenly stopped working for me a few days ago with the error
Molecule default > create

   TASK [Synchronization the context] *********************************************
  failed: [localhost] (item={'image': 'debian:10', 'name': 'instance'}) => {"ansible_index_var": "i", "ansible_loop_var": "item", "changed": false, "i": 0, "item": {"image": "debian:10", "name": "instance"}, "msg": "Failed to find required executable \"rsync\" in paths: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}

Here is a working job:
https://github.com/RedlineTriad/private_server/actions/runs/3131176997/jobs/5082243386

And here is a failing one with basically only markdown changes:
https://github.com/RedlineTriad/private_server/actions/runs/3215501015/jobs/5256673943#step:4:85

I tried to go to an older tag instead of just v2 but it didn't fix the issue.
And I also didn't find any issues in the github action runner repo referencing something like a change to remove rsync.
Haven't looked into this too much yet (like if rsync exists) since I need to go to sleep now.

Using earlier versons of action always uses latest version of container

When attempting to use older versions of the action, (either to get a version that has older versions of ansible/molecule or to pin the workflow to a known working version of the action), it always results in the latest version of the container.

Being able to pin a specific verios of the action/container would avoid unexpected issues such as: #138

It would be good if the versions of the action would either match the corresponding container version or if it would be possible to overwrite the container version used via a env variable for example.

Perhaps something like this could work?

runs:
  using: docker
  image: docker://gofrolist/molecule:v${MOLECULE_CONTAINER_VERSION}
  env:
    ANSIBLE_ASYNC_DIR: "/tmp/.ansible_async"
    ANSIBLE_FORCE_COLOR: "1"
    MOLECULE_CONTAINER_VERSION: "2"

Couldn't resolve module/action 'community.docker.docker_container'

I've been running the action for a while now, and recently (couple months?) is keeps failing with the following error:

  ERROR! couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.
  
  The error appears to be in '/app/.venv/lib/python3.11/site-packages/molecule_plugins/docker/playbooks/destroy.yml': line 15, column 7, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
  
  
      - name: Destroy molecule instance(s)
        ^ here
  CRITICAL Ansible return code was 4, command was: ansible-playbook --diff --inventory /github/home/.cache/molecule/authelia/default/inventory --skip-tags molecule-notest,notest /app/.venv/lib/python3.11/site-packages/molecule_plugins/docker/playbooks/destroy.yml
  WARNING  An error occurred during the test sequence action: 'destroy'. Cleaning up.

So it's as if Ansible within the action container can't see the module. I'm not the expert in dependency management here, but I can see ansible-core in the poetry.lock file and I can't see this community module added anywhere to this "minimalist language and runtime package" that ansible-core is.

One other github molecule action seems to be requiring the full "ansible" package:
https://github.com/robertdebock/docker-github-action-molecule/blob/master/requirements.txt

So is this a bug in molecule-action? If not, how else can I add comunity.docker.docker_container to my tests, in general, not to each role?

README: `molecule-working-dir` is invalid input name

As per README:

NOTE: By default molecule is going to look for configuration at molecule/*/molecule.yml, so if option molecule-working-dir is not provided,
checkout action needs to place the file in ${{ github.repository }} in order for Molecule to find your role. If your role is placed somewhere else
in the repository, ensure that molecule-working-dir is set up accordingly, in order to cd to that directory before issuing molecule command.

But molecule-working-dir doesn't exist (I've copied it from README and my job failed), and it took me a while to figure out that molecule_working_dir should be used instead. I think README should be clearer, especially when the input name is code formatted, it suggests it should be the valid and ready to copy-and-paste.

Make v1.1?

Hello!

Can you possibly release a v1.1 to the marketplace?

Thanks!
Till

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.