Skip to content

Commit

Permalink
Merge pull request #23 from RedlineTriad/improve-testing
Browse files Browse the repository at this point in the history
test: run action instead of image
  • Loading branch information
RedlineTriad authored Nov 13, 2022
2 parents edc3007 + 5038b6f commit e5b4b31
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Molecule default pipeline
env:
ANSIBLE_FORCE_COLOR: '1'
- name: Install Molecule on Runner
run: |
python3 -m pip install molecule molecule-vagrant
- name: Create molecule scenario
run: |
docker run \
-v /var/run/libvirt/virtqemud-sock:/var/run/libvirt/virtqemud-sock \
-v $(pwd)/test_files/:/var/test_files \
${{ env.IMAGE }}:test \
sh -c "\
molecule --version \
&& molecule init role --driver-name vagrant redlinetriad.validate \
&& cd validate \
&& cp /var/test_files/molecule.yml molecule/default/molecule.yml \
&& sed -i 's/redlinetriad.//g' molecule/default/converge.yml \
&& molecule test \
"
mkdir test
cd test
molecule init role --driver-name vagrant test.validate
cp ../test_files/molecule.yml validate/molecule/default/molecule.yml
sed -i 's/test.//g' validate/molecule/default/converge.yml
- name: Test Molecule default pipeline
uses: ./ # Uses an action in the root directory
with:
molecule_working_dir: test/validate
image: "${{ env.IMAGE }}:test"
28 changes: 22 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ branding:
color: green

inputs:
image:
description: |
Container image to use for running molecule testing.
This is generally not needed and mostly useful for tests.
required: true
default: docker://ghcr.io/redlinetriad/molecule-vagrant-qemu-action:v1

molecule_options:
description: |
Options:
Expand Down Expand Up @@ -61,11 +68,20 @@ inputs:
Path to another directory in the repository, where molecule command will be issued from.
Useful in those cases where Ansible roles are not in git repository root.
required: false
default: ${{ github.workspace }}
default: "."

runs:
using: docker
image: docker://ghcr.io/redlinetriad/molecule-vagrant-qemu-action:v1
env:
ANSIBLE_ASYNC_DIR: "/tmp/.ansible_async"
ANSIBLE_FORCE_COLOR: "1"
using: composite
steps:
- run: >
docker run
-v $(pwd)/:${{ github.workspace }}
--workdir=${{ github.workspace }}
-e "ANSIBLE_ASYNC_DIR=/tmp/.ansible_async"
-e "ANSIBLE_FORCE_COLOR=1"
-e "INPUT_MOLECULE_OPTIONS=${{ inputs.molecule_options }}"
-e "INPUT_MOLECULE_COMMAND=${{ inputs.molecule_command }}"
-e "INPUT_MOLECULE_ARGS=${{ inputs.molecule_args }}"
-e "INPUT_MOLECULE_WORKING_DIR=${{ inputs.molecule_working_dir }}"
${{ inputs.image }}
shell: bash

0 comments on commit e5b4b31

Please sign in to comment.