Skip to content

Commit

Permalink
feat(ci): auto discover molecule scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
gardar authored and bbaassssiiee committed Oct 5, 2022
1 parent 38b2d40 commit ee2d820
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,57 @@ on:
- '*'
pull_request:

env:
ANSIBLE_FORCE_COLOR: '1'
PY_COLORS: '1'

jobs:
discover-scenarios:
runs-on: ubuntu-latest
outputs:
scenarios: ${{ steps.set-scenarios.outputs.scenarios }}
steps:
- name: Check out codebase
uses: actions/checkout@v3

- name: Discover scenarios
id: set-scenarios
# Find path to all scenarios
run: |
export scenarios="[`for x in $(ls -1 molecule -I _tests -I '*.yml'); do echo "'$x'"; done | tr '\n' ',' | sed '$s/,$//'`]"
echo "::set-output name=scenarios::$scenarios"
lint:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs:
- discover-scenarios
strategy:
matrix:
scenario:
- ${{ fromJson(needs.discover-scenarios.outputs.scenarios)[0] }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
uses: actions/checkout@v3
- name: molecule
uses: robertdebock/molecule-action@2.6.8
uses: gofrolist/molecule-action@v2
with:
command: lint
molecule_command: lint
molecule_args: --scenario-name ${{ matrix.scenario }}

test:
needs:
- lint
runs-on: ubuntu-20.04
- discover-scenarios
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scenario: ${{ fromJson(needs.discover-scenarios.outputs.scenarios) }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
uses: actions/checkout@v3
- name: molecule
uses: robertdebock/molecule-action@2.6.8
uses: gofrolist/molecule-action@v2
with:
image: ${{ matrix.config.image }}
tag: ${{ matrix.config.tag }}
molecule_command: test
molecule_args: --scenario-name ${{ matrix.scenario }}

0 comments on commit ee2d820

Please sign in to comment.