Skip to content

Commit

Permalink
ci: refactor action + expose on host
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Sep 16, 2023
1 parent b7abf75 commit 18fcb58
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 81 deletions.
57 changes: 57 additions & 0 deletions .github/actions/molecule/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Molecule
description: |
Run an Atmosphere Molecule test.
inputs:
scenario:
required: true
description: Scenario to run.
network_backend:
required: false
description: Network backend type.
default: ovn
csi_driver:
required: false
description: CSI driver to test.
default: local-path-provisioner

runs:
using: composite
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Install Poetry
shell: bash
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
with:
cache: poetry

- name: Install dependencies
shell: bash
run: poetry install --no-interaction --with dev

# NOTE(mnaser): LVM commands take a long time if there are any existing
# loop devices created by "snapd", so we uninstall it.
- name: Uninstall "snapd"
shell: bash
run: sudo apt-get purge -y snapd

- name: Turn off swap
shell: bash
run: sudo swapoff -a

- name: Set environment variables
shell: bash
run: |
echo "HOST_IP=$(hostname -I | awk '{print $1}')" >> $GITHUB_ENV
- name: Run Molecule
shell: bash
run: poetry run molecule test -s ${{ inputs.scenario }}
env:
ATMOSPHERE_NETWORK_BACKEND: ${{ inputs.network_backend }}
MOLECULE_CSI_DRIVER: ${{ inputs.csi_driver }}
33 changes: 4 additions & 29 deletions .github/workflows/ceph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,8 @@ jobs:
group: ${{ github.ref }}-${{ matrix.network_backend }}
cancel-in-progress: true
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
- name: Run tests
uses: ./.github/actions/molecule
with:
cache: poetry

- name: Install dependencies
run: poetry install --no-interaction --with dev

# NOTE(mnaser): LVM commands take a long time if there are any existing
# loop devices created by "snapd", so we uninstall it.
- name: Uninstall "snapd"
run: sudo apt-get purge -y snapd

- name: Turn off swap
run: sudo swapoff -a

- name: Set environment variables
run: |
echo "HOST_IP=$(hostname -I | awk '{print $1}')" >> $GITHUB_ENV
- name: Run Molecule
run: poetry run molecule test -s ceph
env:
ATMOSPHERE_NETWORK_BACKEND: ${{ matrix.network_backend }}
scenario: ceph
network_backend: ${{ matrix.network_backend }}
34 changes: 5 additions & 29 deletions .github/workflows/csi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,9 @@ jobs:
- local-path-provisioner
- rbd
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
- name: Run tests
uses: ./.github/actions/molecule
with:
cache: poetry

- name: Install dependencies
run: poetry install --no-interaction --with dev

# NOTE(mnaser): LVM commands take a long time if there are any existing
# loop devices created by "snapd", so we uninstall it.
- name: Uninstall "snapd"
run: sudo apt-get purge -y snapd

- name: Turn off swap
run: sudo swapoff -a

- name: Set environment variables
run: |
echo "HOST_IP=$(hostname -I | awk '{print $1}')" >> $GITHUB_ENV
- name: Run Molecule
run: poetry run molecule test -s csi
env:
MOLECULE_CSI_DRIVER: ${{ matrix.driver }}
scenario: ceph
network_backend: ${{ matrix.network_backend }}
csi_driver: ${{ matrix.driver }}
25 changes: 3 additions & 22 deletions .github/workflows/magnum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,7 @@ jobs:
molecule:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
- name: Run tests
uses: ./.github/actions/molecule
with:
cache: poetry

- name: Install dependencies
run: poetry install --no-interaction --with dev

- name: Turn off swap
run: sudo swapoff -a

- name: Set environment variables
run: |
echo "HOST_IP=$(hostname -I | awk '{print $1}')" >> $GITHUB_ENV
- name: Run Molecule
run: poetry run molecule test -s magnum
scenario: magnum
5 changes: 4 additions & 1 deletion molecule/ceph/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependency:
driver:
name: docker
platforms:
- name: instance
- name: ${MOLECULE_SCENARIO_NAME}
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
Expand All @@ -38,6 +38,9 @@ platforms:
networks:
- name: mgmt
- name: public
published_ports:
- 80:80
- 443:443
security_opts:
- apparmor=unconfined
volumes:
Expand Down

0 comments on commit 18fcb58

Please sign in to comment.