diff --git a/.github/actions/molecule/action.yml b/.github/actions/molecule/action.yml new file mode 100644 index 000000000..92b282ab3 --- /dev/null +++ b/.github/actions/molecule/action.yml @@ -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 }} diff --git a/.github/workflows/ceph.yml b/.github/workflows/ceph.yml index 3344461cb..50c9be2ad 100644 --- a/.github/workflows/ceph.yml +++ b/.github/workflows/ceph.yml @@ -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 }} diff --git a/.github/workflows/csi.yml b/.github/workflows/csi.yml index e473441fa..475316510 100644 --- a/.github/workflows/csi.yml +++ b/.github/workflows/csi.yml @@ -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 }} diff --git a/.github/workflows/magnum.yml b/.github/workflows/magnum.yml index d7dcb622d..a83befa79 100644 --- a/.github/workflows/magnum.yml +++ b/.github/workflows/magnum.yml @@ -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 diff --git a/molecule/ceph/molecule.yml b/molecule/ceph/molecule.yml index f640086fb..f4bae65c2 100644 --- a/molecule/ceph/molecule.yml +++ b/molecule/ceph/molecule.yml @@ -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 @@ -38,6 +38,9 @@ platforms: networks: - name: mgmt - name: public + published_ports: + - 80:80 + - 443:443 security_opts: - apparmor=unconfined volumes: