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

skip_changelog: ensure ansible-test molecule integration tests are present #135

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ansible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- reopened
- synchronize
- labeled
pull_request_target:
workflow_dispatch:

concurrency:
Expand All @@ -19,6 +20,7 @@ env:
ANSIBLE_GALAXY_SERVER_GALAXY_URL: "https://galaxy.ansible.com"
ANSIBLE_GALAXY_SERVER_GALAXY_TIMEOUT: 120
ANSIBLE_GALAXY_SERVER_LIST: "galaxy"
ANSIBLE_TEST_MOLECULE_VERSION: 0.1.3

jobs:
ansible-lint:
Expand Down Expand Up @@ -52,6 +54,47 @@ jobs:
with:
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}

ensure-ansible-test-molecule:
runs-on: ubuntu-latest
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: "Download ansible-test-molecule"
run: |
src="https://github.com/gardar/ansible-test-molecule/releases/download/${ANSIBLE_TEST_MOLECULE_VERSION}/ansible-test-molecule.sh"
if [[ -v GITHUB_TOKEN ]]
then
curl -L -s -H "Authorization: token $GITHUB_TOKEN" $src -o ansible-test-molecule.sh
else
curl -L -s $src -o ansible-test-molecule.sh
fi

- name: "Setup molecule integration tests for roles"
run: |
for dir in $(find roles -type d -name 'molecule'); do
role=$(basename $(dirname $dir))
for test in $(ls $dir); do
new_dir="tests/integration/targets/molecule-${role}-${test}"
echo "Creating integration test: ${new_dir}"
mkdir -p $new_dir

cp ansible-test-molecule.sh ${new_dir}/runme.sh
chmod +x ${new_dir}/runme.sh
done
done

- name: "Commit molecule integration tests"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: ansible-test molecule integration test"

discover-ansible-tests:
runs-on: ubuntu-latest
needs:
Expand Down