Files
vms/.github/workflows/test.yml
T

101 lines
2.8 KiB
YAML

name: Test the components of it
"on":
push:
branches:
- main
paths-ignore:
- '.github/workflow/build.yml'
pull_request:
workflow_dispatch:
jobs:
validate:
name: Validate Packer templates are reasonable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Install packer
uses: ./.github/actions/install_packer/
- name: Run syntax check
run: |
set -exo pipefail
for vars in distros/*; do
~/bin/packerio validate -except=upload -var-file=${vars} sources/
done
collect:
name: Collect all Ansible-related jobs
runs-on: ubuntu-latest
outputs:
all: ${{ steps.zipped.outputs.scenarios }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
- name: Install dependencies
run: |
set -ex
python -m pip install --upgrade tox
- name: Collect dependencies
id: collection
uses: greg-hellings/tox-list@v1
with:
tox-args: --ansible-driver docker --ansible-driver podman --ansible-driver containers
- id: vagrant
uses: greg-hellings/tox-list@v1
with:
tox-args: --ansible-driver vagrant
- id: zipped
name: Zip arrays together
shell: python
run: |
import json
ubuntu = json.loads('${{ steps.collection.outputs.tox-envs }}')
macos = json.loads('${{ steps.vagrant.outputs.tox-envs }}')
ub_zip = [{'os': 'ubuntu-latest', 'scenario': u} for u in ubuntu]
mac_zip = [{'os': 'macos-10.15', 'scenario': m} for m in macos]
print("::set-output name=scenarios::" + json.dumps(ub_zip + mac_zip))
lint:
name: Lint Ansible code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Python
uses: actions/setup-python@v2
- name: Install dependencies
run: |-
set -ex
python -m pip install --upgrade tox ansible
ansible-galaxy collection install -r ansible/requirements.yml
- name: Run lint
run: tox -e lint_all
build:
name: Ansible tests on roles
runs-on: ${{ matrix.scenarios.os }}
needs:
- collect
strategy:
fail-fast: false
matrix:
scenarios: "${{ fromJson(needs.collect.outputs.all) }}"
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Python
uses: actions/setup-python@v2
- name: Install dependencies
run: python -m pip install --upgrade tox
- name: Run scenario
run: tox -e "${{ matrix.scenarios.scenario }}"