-
Notifications
You must be signed in to change notification settings - Fork 2
196 lines (168 loc) · 5.47 KB
/
cicd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: CI/CD
##
# This github workflow is used to run tests on all commits to the master branch
# to verify all basic processes function correctly.
##
on:
push:
branches:
- master
jobs:
##
# Lint Checkers
# 1. Shellcheck
# 2. SLS Lint
# 3. Python Lint
##
lint:
name: Lint Checkers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 1. Shellcheck
# Looks for +x files
- name: ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore_names: '10_linux'
env:
SHELLCHECK_OPTS: -e SC1091
# 2. SLS Lint
- name: SLS Lint
uses: roaldnefs/salt-lint-action@master
# 3. Python Lint
- name: Set Up Python environment
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Flake8 Lint
uses: py-actions/flake8@v2
with:
# E501: Ignore long lines for tests
ignore: 'E501'
##
# Test installed OS from built ISO:
# 1. Build a "teckhost" iso from upstream release
# Replaced with OVA: 2. Install OS on VM using teckhost.iso (testing option)
# 2. Deploy Testing VM from Release OVA
# 3. Verify we can log in using the "testuser" account
# 4. Run validation tests against the installed OS
# 5. Ensure make clean produces no errors
##
buildiso:
name: Build Teckhost ISO
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install libarchive-tools syslinux xorriso isolinux python3-distro coreutils
# 1. Build a "teckhost" iso from upstream release
- name: Build Teckhost ISO
id: build_iso
run: make teckhost_debian12.iso
env:
THT_GRUBTEST: hostname=testpc1 BS_pillar_root=test/pillar TH_SALTGPG=https://raw.githubusercontent.com/MTecknology/teckhost/master/test/pillar/skeys.gpg BS_gitfs_pillar_base=master BS_gitfs_base=${{ github.sha }}
# Disabled: OVA
#- name: Save ISO (teckhost.iso)
# uses: actions/upload-artifact@v4
# with:
# name: teckhost_debian12-${{ github.sha }}.iso
# path: teckhost_debian12.iso
# compression-level: 0
testinstall:
name: "Install and Validate"
# Disabled:_OVA
#needs: buildiso
strategy:
matrix:
#boot: [efi, bios]
boot: [efi]
#os: [debian11, debian12]
os: [debian12]
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
brew install coreutils
brew install --cask virtualbox
pip3 install pytest-testinfra distro
sh ./test/vbox_extpack
# Disabled: OVA
#- name: Pull ISO (teckhost.iso)
# uses: actions/download-artifact@v4
# with:
# name: teckhost_debian12-${{ github.sha }}.iso
#
# 2. Install OS on VM using teckhost.iso (testing option)
#- name: Create VM and Install (Testing) Teckhost
# id: install_os
# run: make testpc1_${{ matrix.os }}
# env:
# TH_SHOTS: testpc1-${{ matrix.boot }}
# TH_BOOT: ${{ matrix.boot }}
#
#- name: (on failure) Package Screenshots
# if: failure() && steps.install_os.outcome == 'failure'
# run: "tar -vczf testpc1-${{ matrix.boot }}.tgz *.png"
#
#- name: (on failure) Upload Screenshots
# if: failure() && steps.install_os.outcome == 'failure'
# uses: actions/upload-artifact@v4
# with:
# name: testpc1-${{ matrix.boot }}_screenshots.tgz
# path: testpc1-${{ matrix.boot }}.tgz
# compression-level: 0
#
# 2. Deploy Testing VM from Release OVA
- name: Create VM from (Testing) OVA
id: install_os
run: |
touch teckhost_${{ matrix.os }}.iso
make import-testpc1_${{ matrix.os }}
VBoxManage modifyvm testpc1 --vram 7 --paravirtprovider legacy
VBoxManage startvm testpc1 --type headless
sleep 90
# 3. Verify we can log in using the "testuser" account
- name: Prep and Ping
id: basic_validation
run: |
make testprep
ssh -4 -v -o StrictHostKeyChecking=no -o ConnectTimeout=10 -i test/.ssh/id_ed25519 ssh://testuser@localhost:4222 'echo ping'
# 4. Run validation tests against the installed OS
- name: Validation Tests
id: validation_tests
run: make test
# 5. Ensure make clean produces no errors
- name: Run Cleanup
id: cleanup
run: make clean
##
# Merge master into cicd-release after tests pass
# NOTE: From this point forward, a force push is non-trivial!
##
deploy:
name: Deploy Changes
#OVA: needs: [lint, testinstall]
needs: [lint, buildiso, testinstall]
if: github.ref == 'refs/heads/master'
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
ref: cicd-release
- name: Merge Changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions"
git merge --no-ff "${{ github.sha }}" -m "[CICD-Pass] Merge ${{ github.sha }} into cicd-release"
# CICD: deploy->master
- name: Go Live!
run: |
git push origin cicd-release