diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae116b56b..ed37d6b2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,12 +11,45 @@ name: Test default: false jobs: + set-platforms: + name: Set platforms + runs-on: ubuntu-latest + + outputs: + platforms: ${{ steps.set-platforms.outputs.result }} + + steps: + - name: Checkout + # yamllint disable-line rule:line-length + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set platforms + id: set-platforms + uses: mikefarah/yq@c35ec752e38ea0c096d3c44e13cfc0797ac394d8 # v4.43.1 + with: + cmd: > + yq --output-format=json --indent=0 + '[.platforms[].name]' + ansible/molecule/default/molecule.yml + test: name: Test - runs-on: macos-12 + runs-on: ubuntu-latest + needs: set-platforms continue-on-error: ${{ inputs.continue-on-error }} + strategy: + matrix: + platform: ${{ fromJson(needs.set-platforms.outputs.platforms) }} steps: + # GitHub Actions hosted runners provide around 21GB of free storage, but + # the instances need around 25GB. This action frees up an additional + # 24GB, giving us a total of 45GB, which is enough disk space to run each + # VM. + - name: Free disk space + # yamllint disable-line rule:line-length + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + - name: Checkout # yamllint disable-line rule:line-length uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -38,8 +71,13 @@ jobs: python-version: 3.12.2 cache: pip + - name: Update apt + run: sudo apt update + - name: Install dependencies - run: just install-dependencies + run: | + sudo apt install vagrant virtualbox + just install-dependencies - name: Cache Vagrant boxes # yamllint disable-line rule:line-length @@ -52,9 +90,4 @@ jobs: restore-keys: ${{ runner.os }}-vagrant- - name: Test - run: > - echo "Tests are temporarily disabled. - See: - - https://github.com/actions/runner-images/issues/8730 - - https://github.com/actions/runner-images/issues/8642 - " + run: just test --platform-name=${{ matrix.platform }} diff --git a/README.md b/README.md index cb440e5c2..e6edaad4b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Install the following software - [just](https://github.com/casey/just) - [mise](https://github.com/jdx/mise) +- [![Vagrant](docs/images/vagrant.svg) Vagrant](https://www.vagrantup.com) - [![VirtualBox](docs/images/virtualbox.svg) VirtualBox](https://www.virtualbox.org) ### Usage diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index d64305d49..4a07e6bb6 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -3,8 +3,6 @@ inventory=inventories/prod remote_user=ansible -roles_path=galaxy/roles:roles -collections_path=galaxy/collections:collections inventory_plugins=inventory_plugins vault_identity_list = dev@vault-password-dev.txt, prod@vault-password-prod.sh diff --git a/ansible/justfile b/ansible/justfile index 00ed656ed..ab2f0e03b 100755 --- a/ansible/justfile +++ b/ansible/justfile @@ -18,37 +18,37 @@ install-dependencies: test *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} test + molecule test {{extra_args}} # Create hosts locally up *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} create + molecule create {{extra_args}} # Create and configure hosts locally run *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} converge + molecule converge {{extra_args}} # Create and configure hosts locally for `test` tags run-test *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} converge -- --tags test -vv + molecule converge {{extra_args}} -- --tags test -vv # Create and configure hosts locally with debug logs run-debug *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule --debug {{extra_args}} converge -- -vvv + molecule --debug converge {{extra_args}} -- -vvv # Create and configure hosts locally for `test` tags with debug logs run-test-debug *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} converge -- --tags test -vvv + molecule converge {{extra_args}} -- --tags test -vvv # Log in to a locally created host login host: @@ -60,7 +60,7 @@ login host: down *extra_args: #!/usr/bin/env bash source env/bin/activate - molecule {{extra_args}} destroy + molecule destroy {{extra_args}} # Edit dev vault edit-dev-vault: diff --git a/ansible/molecule/default/molecule.yml b/ansible/molecule/default/molecule.yml index bf9062d16..bf805a5d6 100644 --- a/ansible/molecule/default/molecule.yml +++ b/ansible/molecule/default/molecule.yml @@ -9,20 +9,24 @@ driver: name: vagrant default_box: ubuntu/jammy64 +# We currently use a 4-core ubuntu-latest instance in the +# '.github/workflows/test.yml' workflow. After performance testing the runners +# with different platform core and memory allocations, we found that 2-core +# platforms with 2GB of memory were the optimal configurations for test +# runtime. Higher core counts were slower, most likely due to inefficient +# virtualisation in GitHub Action runners, which led to increased resource +# contention and I/O overhead. +# +# See: +# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources platforms: - name: workstation-pop-os groups: [workstations] - # `cpus` need to roughly match the core count used by the CI. Currently, we - # are using a 3-core macos-12 instance in '.github/workflows/test.yml', - # therefore we are using 2x 2-core instances with vagrant. - # See: - # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources cpus: 2 memory: 2048 - name: server-nas groups: [servers] - # See note on `cpus` above cpus: 2 # server-nas needs extra memory primarily due to the amount of docker apps # that are running @@ -30,7 +34,6 @@ platforms: - name: server-pi groups: [servers] - # See note on `cpus` above cpus: 2 memory: 2048 diff --git a/ansible/requirements.txt b/ansible/requirements.txt index 7ec79aa22..df5eb8140 100644 --- a/ansible/requirements.txt +++ b/ansible/requirements.txt @@ -1,4 +1,4 @@ ansible-core==2.16.5 -molecule==5.1.0 -molecule-plugins[vagrant]==23.5.0 +molecule==24.2.0 +molecule-plugins[vagrant]==23.5.3 netaddr==1.2.1 diff --git a/docs/DEVELOPERS_GUIDE.md b/docs/DEVELOPERS_GUIDE.md index 2a3a6743b..422dc8e43 100644 --- a/docs/DEVELOPERS_GUIDE.md +++ b/docs/DEVELOPERS_GUIDE.md @@ -25,6 +25,7 @@ Install the following software - [just](https://github.com/casey/just) - [mise](https://github.com/jdx/mise) +- [![Vagrant](images/vagrant.svg) Vagrant](https://www.vagrantup.com) - [![VirtualBox](images/virtualbox.svg) VirtualBox](https://www.virtualbox.org) ## Useful Commands