Skip to content

Add a github action to test the PR in a complete MC cluster with incus #56

Add a github action to test the PR in a complete MC cluster with incus

Add a github action to test the PR in a complete MC cluster with incus #56

Workflow file for this run

name: Test complete puppet environment
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.5.7"
- name: Install incus
run: |
sudo apt update
sudo apt install incus
- name: Init incus
run: |
sudo incus admin init --auto
sudo chgrp runner /var/lib/incus/unix.socket
- name: Reset the firewall
run: |
sudo nft flush ruleset
- name: Download Magic Castle Incus
run: |
curl -L -O https://raw.githubusercontent.com/ComputeCanada/magic_castle/refs/heads/main/examples/incus/main.tf
curl -L -O https://raw.githubusercontent.com/ComputeCanada/magic_castle/refs/heads/main/examples/incus/data.yaml
- name: Init and apply
id: create_cluster
run: |
sed -i "s;\"main\";\"${GITHUB_REF}\";" main.tf
terraform init
terraform apply -auto-approve
echo "incus_project=$(terraform output | grep -Po 'project = "\K[^"]+')">> "$GITHUB_OUTPUT"
- name: Wait for puppet catalog to be applied
continue-on-error: true
timeout-minutes: 20
run: |
incus project switch ${{ steps.create_cluster.outputs.incus_project }}
for nodename in $(incus list -c n -f csv); do
echo -n "${nodename}: "
until incus exec $nodename -- journalctl -u puppet | grep "Applied catalog"; do
sleep 10
done
echo
done
- name: Verify Puppet Prometheus report for errors
run: |
incus project switch ${{ steps.create_cluster.outputs.incus_project }}
incus file pull mgmt1/etc/puppetlabs/code/environments/production/utils/incus_report.sh .
exec >> $GITHUB_STEP_SUMMARY
bash incus_report.sh