Skip to content

Commit 4b79eef

Browse files
committed
remove needs from build workflows
Signed-off-by: Corey Hemminger <hemminger@hotmail.com>
1 parent cefb8d8 commit 4b79eef

8 files changed

Lines changed: 79 additions & 87 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,30 @@ jobs:
1515
secrets: inherit
1616

1717
pkr-bld-amazonlinux:
18-
needs: ci-lint
1918
uses: ./.github/workflows/pkr-bld-amazonlinux.yml
2019
secrets: inherit
2120

2221
pkr-bld-hyperv:
23-
needs: ci-lint
2422
uses: ./.github/workflows/pkr-bld-hyperv.yml
2523
secrets: inherit
2624

2725
pkr-bld-parallels:
28-
needs: ci-lint
2926
uses: ./.github/workflows/pkr-bld-parallels.yml
3027
secrets: inherit
3128

3229
pkr-bld-qemu:
33-
needs: ci-lint
3430
uses: ./.github/workflows/pkr-bld-qemu.yml
3531
secrets: inherit
3632

3733
pkr-bld-utm:
38-
needs: ci-lint
3934
uses: ./.github/workflows/pkr-bld-utm.yml
4035
secrets: inherit
4136

4237
pkr-bld-virtualbox:
43-
needs: ci-lint
4438
uses: ./.github/workflows/pkr-bld-virtualbox.yml
4539
secrets: inherit
4640

4741
pkr-bld-vmware:
48-
needs: ci-lint
4942
uses: ./.github/workflows/pkr-bld-vmware.yml
5043
secrets: inherit
5144

.github/workflows/pkr-bld-amazonlinux.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ jobs:
5252
./${{ matrix.os }}-x86_64-virtualbox-build.sh
5353
ls -alh builds/build_complete
5454
cat builds/build_complete/${{ matrix.os }}*-x86_64._metadata.json
55+
- name: Remove VM in case of canceled job
56+
if: cancelled()
57+
run: |
58+
VM="$(VBoxManage list vms | grep '${{ matrix.os }}' | awk -F'"' '{print $2}')"
59+
echo "VM Name: $VM"
60+
VBoxManage controlvm "$VM" poweroff 2>/dev/null || true
61+
sleep 2
62+
VBoxManage unregistervm "$VM" --delete 2>/dev/null || true
5563
- name: Bento Test
5664
run: |
5765
eval "$(chef shell-init bash)"
@@ -86,13 +94,11 @@ jobs:
8694
- name: Remove VM in case of canceled job
8795
if: cancelled()
8896
run: |
89-
VM="$(VBoxManage list vms | grep ${{ matrix.os }} | cut -d " " -f 1)"
97+
VM="$(VBoxManage list vms | grep '${{ matrix.os }}' | awk -F'"' '{print $2}')"
9098
echo "VM Name: $VM"
91-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-aarch64
92-
VBoxManage controlvm $VM poweroff
93-
sleep 1
94-
vboxmanage unregistervm $VM --delete
99+
VBoxManage controlvm "$VM" poweroff 2>/dev/null || true
95100
sleep 2
101+
VBoxManage unregistervm "$VM" --delete 2>/dev/null || true
96102
- name: Bento Test
97103
run: |
98104
eval "$(chef shell-init bash)"

.github/workflows/pkr-bld-hyperv.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ jobs:
5858
run: packer init -upgrade packer_templates
5959
- name: Packer build
6060
run: packer build -timestamp-ui -only="${{ matrix.provider }}.vm" -var 'sources_enabled=["hyperv-iso.vm"]' -var-file="os_pkrvars/$("${{ matrix.os }}".Split('-')[0])/${{ matrix.os }}-x86_64.pkrvars.hcl" packer_templates
61+
- name: Remove VM in case of canceled job
62+
if: cancelled()
63+
shell: pwsh
64+
run: |
65+
$vm = Get-VM | Where-Object { $_.Name -like "*${{ matrix.os }}*" } | Select-Object -First 1
66+
if ($vm) {
67+
Write-Host "Stopping and removing VM: $($vm.Name)"
68+
Stop-VM -Name $vm.Name -Force -TurnOff -ErrorAction SilentlyContinue
69+
Start-Sleep -Seconds 2
70+
Remove-VM -Name $vm.Name -Force -ErrorAction SilentlyContinue
71+
}
6172
- name: Bento Test
6273
run: |
6374
chef shell-init powershell

.github/workflows/pkr-bld-parallels.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ jobs:
4848
- name: Remove VM in case of canceled job
4949
if: cancelled()
5050
run: |
51-
VM="$(prlctl list -a | grep ${{ matrix.os }} | cut -d " " -f 1)"
52-
echo "VM Name: $VM"
53-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-x86_64
54-
prlctl stop "$VM" --kill 2> /dev/null
55-
sleep 1
56-
prlctl delete "$VM" 2> /dev/null
51+
VM="$(prlctl list -a | grep '${{ matrix.os }}' | awk '{print $1}')"
52+
echo "VM UUID: $VM"
53+
prlctl stop "$VM" --kill 2>/dev/null || true
5754
sleep 2
55+
prlctl delete "$VM" 2>/dev/null || true
5856
- name: Bento Test
5957
run: |
6058
eval "$(chef shell-init bash)"
@@ -91,13 +89,11 @@ jobs:
9189
- name: Remove VM in case of canceled job
9290
if: cancelled()
9391
run: |
94-
VM="$(prlctl list -a | grep ${{ matrix.os }} | cut -d " " -f 1)"
95-
echo "VM Name: $VM"
96-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-aarch64
97-
prlctl stop "$VM" --kill 2> /dev/null
98-
sleep 1
99-
prlctl delete "$VM" 2> /dev/null
92+
VM="$(prlctl list -a | grep '${{ matrix.os }}' | awk '{print $1}')"
93+
echo "VM UUID: $VM"
94+
prlctl stop "$VM" --kill 2>/dev/null || true
10095
sleep 2
96+
prlctl delete "$VM" 2>/dev/null || true
10197
- name: Bento Test
10298
run: |
10399
eval "$(chef shell-init bash)"

.github/workflows/pkr-bld-qemu.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ jobs:
7878
bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl"
7979
ls -alh builds/build_complete/
8080
cat builds/build_complete/${{ matrix.os }}*-x86_64._metadata.json
81+
- name: Remove VM in case of canceled job
82+
if: cancelled()
83+
run: |
84+
VM="$(virsh list --all | grep '${{ matrix.os }}' | awk '{print $2}')"
85+
echo "VM Name: $VM"
86+
virsh destroy "$VM" 2>/dev/null || true
87+
sleep 2
88+
virsh undefine "$VM" --remove-all-storage 2>/dev/null || true
8189
- name: Bento Test
8290
run: |
8391
eval "$(chef shell-init bash)"
@@ -111,6 +119,14 @@ jobs:
111119
bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-aarch64.pkrvars.hcl"
112120
ls -alh builds/build_complete/
113121
cat builds/build_complete/${{ matrix.os }}*-aarch64._metadata.json
122+
- name: Remove VM in case of canceled job
123+
if: cancelled()
124+
run: |
125+
VM="$(virsh list --all | grep '${{ matrix.os }}' | awk '{print $2}')"
126+
echo "VM Name: $VM"
127+
virsh destroy "$VM" 2>/dev/null || true
128+
sleep 2
129+
virsh undefine "$VM" --remove-all-storage 2>/dev/null || true
114130
- name: Bento Test
115131
run: |
116132
eval "$(chef shell-init bash)"

.github/workflows/pkr-bld-utm.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ jobs:
4848
- name: Remove VM in case of canceled job
4949
if: cancelled()
5050
run: |
51-
VM="$(utmctl list -a | grep ${{ matrix.os }} | cut -d " " -f 1)"
52-
echo "VM Name: $VM"
53-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-x86_64
54-
utmctl stop "$VM"
55-
sleep 1
56-
utmctl delete "$VM"
51+
VM="$(utmctl list | grep '${{ matrix.os }}' | awk '{print $1}')"
52+
echo "VM UUID: $VM"
53+
utmctl stop "$VM" 2>/dev/null || true
5754
sleep 2
55+
utmctl delete "$VM" 2>/dev/null || true
5856
- name: Bento Test
5957
run: |
6058
eval "$(chef shell-init bash)"
@@ -91,13 +89,11 @@ jobs:
9189
- name: Remove VM in case of canceled job
9290
if: cancelled()
9391
run: |
94-
VM="$(utmctl list -a | grep ${{ matrix.os }} | cut -d " " -f 1)"
95-
echo "VM Name: $VM"
96-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-aarch64
97-
utmctl stop "$VM"
98-
sleep 1
99-
utmctl delete "$VM"
92+
VM="$(utmctl list | grep '${{ matrix.os }}' | awk '{print $1}')"
93+
echo "VM UUID: $VM"
94+
utmctl stop "$VM" 2>/dev/null || true
10095
sleep 2
96+
utmctl delete "$VM" 2>/dev/null || true
10197
- name: Bento Test
10298
run: |
10399
eval "$(chef shell-init bash)"

.github/workflows/pkr-bld-virtualbox.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ jobs:
7171
bento build -o ${{ matrix.provider }}.vm os_pkrvars/$(echo ${{ matrix.os }} | cut -d "-" -f 1)/"${{ matrix.os }}-x86_64.pkrvars.hcl"
7272
ls -alh builds/build_complete/
7373
cat builds/build_complete/${{ matrix.os }}*-x86_64._metadata.json
74+
- name: Remove VM in case of canceled job
75+
if: cancelled()
76+
run: |
77+
VM="$(VBoxManage list vms | grep '${{ matrix.os }}' | awk -F'"' '{print $2}')"
78+
echo "VM Name: $VM"
79+
VBoxManage controlvm "$VM" poweroff 2>/dev/null || true
80+
sleep 2
81+
VBoxManage unregistervm "$VM" --delete 2>/dev/null || true
7482
- name: Bento Test
7583
run: |
7684
eval "$(chef shell-init bash)"
@@ -108,13 +116,11 @@ jobs:
108116
- name: Remove VM in case of canceled job
109117
if: cancelled()
110118
run: |
111-
VM="$(VBoxManage list vms | grep ${{ matrix.os }} | cut -d " " -f 1)"
119+
VM="$(VBoxManage list vms | grep '${{ matrix.os }}' | awk -F'"' '{print $2}')"
112120
echo "VM Name: $VM"
113-
echo Powering off and deleting any existing VMs named ${{ matrix.os }}*-aarch64
114-
VBoxManage controlvm $VM poweroff
115-
sleep 1
116-
vboxmanage unregistervm $VM --delete
121+
VBoxManage controlvm "$VM" poweroff 2>/dev/null || true
117122
sleep 2
123+
VBoxManage unregistervm "$VM" --delete 2>/dev/null || true
118124
- name: Bento Test
119125
run: |
120126
eval "$(chef shell-init bash)"

.github/workflows/pkr-bld-vmware.yml

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,13 @@ jobs:
4848
- name: Remove VM in case of canceled job
4949
if: cancelled()
5050
run: |
51-
# Set your VM directory path
52-
VM_DIR="$HOME/Documents/Virtual Machines.localized"
53-
# VM name to search for (case-sensitive)
54-
TARGET_VM_NAME="${{ matrix.os }}"
55-
# List all VMs
56-
echo "Listing all VMs in $VM_DIR..."
57-
VM_PATHS=$(find "$VM_DIR" -name "*.vmx")
58-
# Loop through each VM and match by name
59-
for VMX in $VM_PATHS; do
60-
if grep -q "$TARGET_VM_NAME" <<< "$VMX"; then
61-
echo "Found VM: $VMX"
62-
# Stop the VM
63-
echo "Stopping VM..."
64-
vmrun stop "$VMX" soft
65-
# Wait a bit to ensure it's stopped
66-
sleep 5
67-
# Delete the VM directory
68-
VM_FOLDER=$(dirname "$VMX")
69-
echo "Deleting VM folder: $VM_FOLDER"
70-
rm -rf "$VM_FOLDER"
71-
echo "VM '$TARGET_VM_NAME' has been stopped and deleted."
72-
fi
73-
done
51+
VMX="$(find "$HOME/Documents/Virtual Machines.localized" -name "*.vmx" | grep '${{ matrix.os }}' | head -1)"
52+
echo "VMX Path: $VMX"
53+
if [ -n "$VMX" ]; then
54+
vmrun stop "$VMX" hard 2>/dev/null || true
55+
sleep 3
56+
rm -rf "$(dirname "$VMX")"
57+
fi
7458
- name: Bento Test
7559
run: |
7660
eval "$(chef shell-init bash)"
@@ -107,29 +91,13 @@ jobs:
10791
- name: Remove VM in case of canceled job
10892
if: cancelled()
10993
run: |
110-
# Set your VM directory path
111-
VM_DIR="$HOME/Documents/Virtual Machines.localized"
112-
# VM name to search for (case-sensitive)
113-
TARGET_VM_NAME="${{ matrix.os }}"
114-
# List all VMs
115-
echo "Listing all VMs in $VM_DIR..."
116-
VM_PATHS=$(find "$VM_DIR" -name "*.vmx")
117-
# Loop through each VM and match by name
118-
for VMX in $VM_PATHS; do
119-
if grep -q "$TARGET_VM_NAME" <<< "$VMX"; then
120-
echo "Found VM: $VMX"
121-
# Stop the VM
122-
echo "Stopping VM..."
123-
vmrun stop "$VMX" soft
124-
# Wait a bit to ensure it's stopped
125-
sleep 5
126-
# Delete the VM directory
127-
VM_FOLDER=$(dirname "$VMX")
128-
echo "Deleting VM folder: $VM_FOLDER"
129-
rm -rf "$VM_FOLDER"
130-
echo "VM '$TARGET_VM_NAME' has been stopped and deleted."
131-
fi
132-
done
94+
VMX="$(find "$HOME/Documents/Virtual Machines.localized" -name "*.vmx" | grep '${{ matrix.os }}' | head -1)"
95+
echo "VMX Path: $VMX"
96+
if [ -n "$VMX" ]; then
97+
vmrun stop "$VMX" hard 2>/dev/null || true
98+
sleep 3
99+
rm -rf "$(dirname "$VMX")"
100+
fi
133101
- name: Bento Test
134102
run: |
135103
eval "$(chef shell-init bash)"

0 commit comments

Comments
 (0)