Clean up salt requisites #374
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
# 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@v4 | |
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 | |
# 2. Install OS on VM using teckhost-sda.iso (testing option) | |
# 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@v3 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install virtualbox 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-sda.iso | |
env: | |
THT_GRUBTEST: TEMPLATE_METHOD=lvm 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 }} | |
- name: Save ISO (teckhost-sda.iso) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: teckhost-sda_${{ github.sha }}.iso | |
path: teckhost-sda.iso | |
testinstall: | |
name: "Install and Validate" | |
needs: buildiso | |
strategy: | |
matrix: | |
#boot: [efi, bios] | |
boot: [efi] | |
#os: [debian11, debian12] | |
os: [debian12] | |
runs-on: macos-12 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Dependencies | |
run: | | |
brew install coreutils | |
#brew install --cask virtualbox | |
pip3 install pytest-testinfra distro | |
#sh ./test/vbox_extpack | |
- name: Pull ISO (teckhost-sda.iso) | |
uses: actions/download-artifact@v3 | |
with: | |
name: teckhost-sda_${{ github.sha }}.iso | |
# 2. Install OS on VM using teckhost-sda.iso (testing option) | |
- name: Create VM and Install (Testing) Teckhost | |
id: install_os | |
run: touch testseed.cfg; touch teckhost-sda.iso; make testpc1 | |
env: | |
TH_ISOPATH: teckhost-sda_${{ github.sha }}.iso | |
TH_SHOTS: testpc1-${{ matrix.boot }} | |
TH_BOOT: ${{ matrix.boot }} | |
- name: (on failure) Package Screenshots | |
if: failure() && steps.install_os.outcome == 'failure' | |
run: "tar -vcf testpc1-${{ matrix.boot }}.tar *.png" | |
- name: (on failure) Upload Screenshots | |
if: failure() && steps.install_os.outcome == 'failure' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: testpc1-${{ matrix.boot }}_screenshots.tar | |
path: testpc1-${{ matrix.boot }}.tar | |
# 3. Verify we can log in using the "testuser" account | |
- name: User (testuser) Login | |
id: basic_validation | |
run: | | |
make testprep | |
ssh -v -o "StrictHostKeyChecking=no" -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 | |
needs: [lint, testinstall] | |
if: github.ref == 'refs/heads/master' | |
permissions: | |
pull-requests: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
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 |