Skip to content

Commit

Permalink
fix: ensure compatibility with ansible's 'free' strategy (#417)
Browse files Browse the repository at this point in the history
* fix: ensure playbook is compatible with free ansible strategy

* run multiple disros in strategy-free scenario

* fix oauth variables after CI refactor

* remove temporary trigger
  • Loading branch information
artis3n authored Jan 19, 2024
1 parent 39d43c9 commit 21cd4b1
Show file tree
Hide file tree
Showing 18 changed files with 247 additions and 191 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ name: Run Molecule Test
on:
workflow_call:
inputs:
image:
scenario:
required: true
type: string
image:
required: false
type: string
default: 'ghcr.io/artis3n/docker-ubuntu2204-ansible:latest'
command:
required: true
required: false
type: string
runner:
required: false
Expand All @@ -24,8 +28,8 @@ env:
ANSIBLE_FORCE_COLOR: '1'

jobs:
run-molecule:
name: "Run Molecule"
run-scenario:
name: "Run Molecule Scenario - ${{ inputs.image }} / ${{ inputs.scenario }}"
runs-on: ${{ inputs.runner }}
environment: E2E

Expand All @@ -48,14 +52,7 @@ jobs:
run: poetry install --no-interaction

- name: Default scenario
run: poetry run molecule test --scenario-name default
env:
MOLECULE_DISTRO: "${{ inputs.image }}"
MOLECULE_COMMAND: "${{ inputs.command }}"
TAILSCALE_CI_KEY: "${{ secrets.tailscale_key }}"

- name: Uninstall scenario
run: poetry run molecule test --scenario-name state-absent
run: poetry run molecule test --scenario-name "${{ inputs.scenario }}"
env:
MOLECULE_DISTRO: "${{ inputs.image }}"
MOLECULE_COMMAND: "${{ inputs.command }}"
Expand Down
149 changes: 45 additions & 104 deletions .github/workflows/pull_request_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
molecule:
name: "Test Distro"
name: "Test Distros"
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -47,12 +47,13 @@ jobs:
with:
image: ${{ matrix.image }}
command: ${{ matrix.command }}
scenario: 'default'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

# Systems that aren't working with cgroups v2 on ubuntu 22.04, but works on ubuntu 20.04
molecule-legacy:
name: "Test Legacy Distro"
name: "Test Legacy Distros"
strategy:
fail-fast: false
matrix:
Expand All @@ -74,119 +75,58 @@ jobs:
with:
image: ${{ matrix.image }}
command: ${{ matrix.command }}
scenario: 'default'
runner: ubuntu-20.04
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

molecule-skip-auth:
name: "Test Skip Authentication"
runs-on: ubuntu-22.04
environment: E2E

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install dependency manager
run: pipx install poetry

- name: Set up Python 3.x
id: setup-python
uses: actions/[email protected]
with:
python-version-file: pyproject.toml
cache: 'poetry'

- name: Install packages
run: poetry install --no-interaction
molecule-state-absent:
name: "Run Molecule Scenario: state-absent"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'state-absent'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

- name: Molecule - Skip Authentication
run: poetry run molecule test --scenario-name skip-authentication
molecule-skip-auth:
name: "Run Molecule Scenario: skip-authentication"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'skip-authentication'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

molecule-args:
name: "Test Up Args"
runs-on: ubuntu-22.04
environment: E2E

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install dependency manager
run: pipx install poetry

- name: Set up Python 3.x
id: setup-python
uses: actions/[email protected]
with:
python-version-file: pyproject.toml
cache: 'poetry'

- name: Install packages
run: poetry install --no-interaction

- name: Molecule - Custom Arguments Validation
run: poetry run molecule test --scenario-name args
env:
TAILSCALE_CI_KEY: "${{ secrets.TAILSCALE_CI_KEY }}"
name: "Run Molecule Scenario: args"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'args'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

molecule-state-present:
name: "Test State Idempotency"
runs-on: ubuntu-22.04
environment: E2E

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install dependency manager
run: pipx install poetry

- name: Set up Python 3.x
id: setup-python
uses: actions/[email protected]
with:
python-version-file: pyproject.toml
cache: 'poetry'

- name: Install packages
run: poetry install --no-interaction

- name: Molecule - State Present
run: poetry run molecule test --scenario-name state-present
env:
TAILSCALE_CI_KEY: "${{ secrets.TAILSCALE_CI_KEY }}"

molecule-state-oauth:
name: "Test OAuth key support"
runs-on: ubuntu-22.04
environment: E2E

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install dependency manager
run: pipx install poetry

- name: Set up Python 3.x
id: setup-python
uses: actions/[email protected]
with:
python-version-file: pyproject.toml
cache: 'poetry'
name: "Run Molecule Scenario: state-idempotency"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'state-idempotency'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

- name: Install packages
run: poetry install --no-interaction
molecule-oauth:
name: "Run Molecule Scenario: oauth"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'oauth'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }}

- name: Molecule - State Present
run: poetry run molecule test --scenario-name oauth
env:
TAILSCALE_OAUTH_CLIENT_SECRET: "${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }}"
molecule-strategy-free:
name: "Run Molecule Scenario: strategy-free"
uses: ./.github/workflows/molecule.yml
with:
scenario: 'strategy-free'
secrets:
tailscale_key: ${{ secrets.TAILSCALE_CI_KEY }}

molecule-headscale:
name: "Test Headscale Compatibility"
Expand All @@ -199,6 +139,7 @@ jobs:
- default
- state-absent
- idempotent-up
- strategy-free

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ else
poetry run molecule test --scenario-name oauth
endif

.PHONY: test-strategy-free
test-strategy-free:
ifndef TAILSCALE_CI_KEY
$(error TAILSCALE_CI_KEY is not set)
else
poetry run molecule test --scenario-name strategy-free
endif

.PHONY: test-headscale
test-headscale:
USE_HEADSCALE=true poetry run molecule test --scenario-name default
Loading

0 comments on commit 21cd4b1

Please sign in to comment.