Test out Gitlab

This commit is contained in:
Greg Hellings
2023-12-18 02:04:17 +00:00
parent 255f6f68e6
commit c6d3cfac19
14 changed files with 121 additions and 304 deletions
-1
View File
@@ -1 +0,0 @@
* @greg-hellings
-39
View File
@@ -1,39 +0,0 @@
name: Install Packer
description: Installs the packerio executable and its attendant tools to /usr/local/bin
for Ubuntu hosts
inputs:
version:
description: Version of Packer to install
required: true
default: "1.9.4"
pup_version:
description: Version of Pup to install
required: true
default: "v0.4.0"
runs:
using: composite
steps:
- name: Install Packer and deps in Linux
shell: bash
if: runner.os == 'Linux'
run: |
set -exo pipefail
# Install virtualbox
sudo apt-get update
# Install QEmu, etc
sudo apt-get install -y unzip cloud-utils xorriso qemu-system-{x86,ppc} vagrant
# Install packer.io
curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip
unzip -o packer_${{ inputs.version }}_linux_amd64.zip -d /usr/local/bin
chmod +x /usr/local/bin/packer
# Install pup
curl -L -o pup.zip "https://github.com/ericchiang/pup/releases/download/${{ inputs.pup_version }}/pup_${{ inputs.pup_version }}_linux_amd64.zip"
sudo unzip pup.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/pup
- name: Install Packer's deps in macOS
shell: bash
if: runner.os == 'macOS'
run: |
set -exo pipefail
brew install pup dvdrtools xorriso coreutils gsed virtualbox vagrant
# Packer is already installed
-38
View File
@@ -1,38 +0,0 @@
# Format and labels
# https://github.com/marketplace/actions/github-labeler
- name: bug
color: "fbca04"
description: "This issue/PR relates to a bug."
- name: deprecated
color: "fef2c0"
description: "This issue/PR relates to a deprecated module."
- name: docs
color: "4071a5"
description: "This issue/PR relates to or includes documentation."
- name: enhancement
color: "ededed"
description: "This issue/PR relates to a feature request."
- name: feature
color: "006b75"
description: "This issue/PR relates to a feature request."
- name: major
color: "c6476b"
description: "Marks an important and likely breaking change."
- name: packaging
color: "4071a5"
description: "Packaging category"
- name: performance
color: "555555"
description: "Relates to product or testing performance."
- name: skip-changelog
color: "eeeeee"
description: "Can be missed from the changelog."
- name: stale
color: "eeeeee"
description: "Not updated in long time, will be closed soon."
- name: wontfix
color: "eeeeee"
description: "This will not be worked on"
- name: test
color: "0e8a16"
description: "This PR relates to tests, QA, CI."
-27
View File
@@ -1,27 +0,0 @@
# Format and labels used aim to match those used by Ansible project
categories:
- title: 'Major Changes'
labels:
- 'major' # c6476b
- title: 'Minor Changes'
labels:
- 'feature' # 006b75
- 'enhancement' # ededed
- 'performance' # 555555
- title: 'Bugfixes'
labels:
- 'fix'
- 'bugfix'
- 'bug' # fbca04
- 'docs' # 4071a5
- 'packaging' # 4071a5
- 'test' # #0e8a16
- title: 'Deprecations'
labels:
- 'deprecated' # fef2c0
exclude-labels:
- 'skip-changelog'
template: |
## Changes
$CHANGES
-106
View File
@@ -1,106 +0,0 @@
name: Build the boxes
"on":
workflow_dispatch:
release:
types:
- published
- prereleased
pull_request:
env:
PACKER_PLUGIN_PATH: ".config/packer/plugins"
jobs:
collect:
name: Discover distros
runs-on: ubuntu-latest
outputs:
boxen: ${{ steps.distros.outputs.some }}
build: ${{ steps.time.outputs.time }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3
cache: pip
cache-dependency-path: .github/workflows/build.yml
- name: Discover boxes
id: distros
run: |-
set -exo pipefail
pip install xonsh PyYAML
echo "all=$(xonsh build.xsh -a --list)" >> "$GITHUB_OUTPUT"
echo "some=$(xonsh build.xsh -b virtualbox-iso.amd64 -a --list)" >> "$GITHUB_OUTPUT"
- name: Find timestamp for versioning
id: time
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY.MM.DD.HH'
build:
name: Build boxes
runs-on: ${{ matrix.runner }}
needs:
- collect
strategy:
fail-fast: false
matrix: ${{ fromJson( needs.collect.outputs.boxen ) }}
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Run generator, if necessary
shell: bash
run: |
if [ -f "${{ matrix.distro }}.sh" ]; then
"./${{ matrix.distro }}.sh"
fi
- name: Restore Packer plugin cache
uses: actions/cache/restore@v3
id: cache-restore
with:
path: .config/packer/plugins
key: ${{ runner.os }}-${{ hashFiles('sources/build.pkr.hcl') }}
- name: Install Packer plugins
shell: bash
run: packer init sources
- name: Cache Packer plugins
uses: actions/cache/save@v3
if: always()
with:
path: .config/packer/plugins
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Build
shell: bash
run: |
set -e
# Add a retry in case something bogus like a network failure happens
packer build -only="${{ matrix.builder }}" \
-var-file="${{ matrix.distro }}" \
-var "build=${{ needs.collect.outputs.build }}" \
-var "cpus=2" \
-var "memory=4096" \
-var "http_port_min=${HTTP_PORT_MIN:-8000}" \
-var "http_port_max=${HTTP_PORT_MAX:-9000}" \
${{ github.event_name != 'release' && '-except=upload' || '' }} \
sources
env:
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
PACKER_LOG: 1
- name: Upload artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: serial-output
path: serial-output*
-18
View File
@@ -1,18 +0,0 @@
name: Release Drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
- 'releases/**'
- 'stable/**'
jobs:
update_release_draft:
runs-on: ubuntu-20.04
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-60
View File
@@ -1,60 +0,0 @@
name: Lint and validation
"on":
pull_request:
workflow_dispatch:
jobs:
validate:
name: Validate Packer templates are reasonable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Packer
uses: ./.github/actions/install_packer
- name: Restore Packer plugin cache
uses: actions/cache/restore@v3
id: cache-restore
with:
path: ~/.config/packer/plugins
key: ${{ runner.os }}-${{ hashFiles('sources/build.pkr.hcl') }}
- name: Install Packer plugins
shell: bash
run: packer init sources
- name: Cache Packer plugins
uses: actions/cache/save@v3
if: always()
with:
path: ~/.config/packer/plugins
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Run validate check
run: |
set -exo pipefail
for vars in $(find distros/ -name '*.pkrvars.hcl*'); do
if [[ "${vars}" == *.sh ]]; then
"./${vars}"
vars=${vars%.sh}
fi
packer validate -except=upload -var-file=${vars} sources/
done
- name: Run Packer format check
run: git ls-files | grep -E -e '.hcl$' | xargs -L 1 packer fmt -check
lint:
name: Lint shell code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install shellcheck
run: |
shellcheck --version
shellcheck $(find . -name '*.sh')
+3 -1
View File
@@ -18,4 +18,6 @@ __pycache__
*.pyo *.pyo
packer_cache packer_cache
.venv .venv
venv venv
.gitlab-ci-build.yml
+47
View File
@@ -0,0 +1,47 @@
# vim: set ft=yaml:
stages:
- build
.build:
stage: build
cache:
paths:
- /var/lib/gitlab-runner/.config/packer/plugins/
needs:
- pipeline: $PARENT_PIPELINE_ID
job: distros
artifacts: true
tags:
- ${tag}
script: |
set -exo pipefail
export PACKER_LOG=1
if [ -f "${distro}.sh" ]; then
./"${distro}.sh"
fi
packer init sources
packer build "${only}" \
-var-file="${distro}" \
-var "build=${BUILD}" \
-var "cpus=2" \
-var "memory=4096" \
-var "http_port_min=${HTTP_PORT_MIN:-8000}" \
-var "http_port_max=${HTTP_PORT_MAX:-9000}" \
-except=upload \
sources
qemu.amd64:
extends: .build
variables:
only: "-only=qemu.amd64"
tag: qemu
parallel:
matrix: []
virtualbox-iso.amd64:
extends: .build
variables:
only: "-only=virtualbox-iso.amd64"
tag: vbox
parallel:
matrix: []
+48
View File
@@ -0,0 +1,48 @@
stages:
- lint
- trigger
validate:
stage: lint
cache:
paths:
- /var/lib/gitlab-runner/.config/packer/plugins/
script: |-
set -exo pipefail
packer init sources
for vars in $(find distros/ -name '*.pkrvars.hcl*'); do
if [[ "${vars}" == *.sh ]]; then
"./${vars}"
vars=${vars%.sh}
fi
packer validate -except=upload -var-file=${vars} sources/
done
shell:
stage: lint
script: |-
shellcheck --version
shellcheck $(find . -name '*.sh')
distros:
stage: lint
artifacts:
reports:
dotenv: build.env
paths:
- .gitlab-ci-build.yml
script: |-
python3 -m venv venv
source venv/bin/activate
pip install -U xonsh PyYAML
xonsh ./build.xsh -a --list
echo "BUILD=$(date +'%Y.%m.%d.%H')" >> build.env
trigger:
stage: trigger
trigger:
include:
- artifact: .gitlab-ci-build.yml
job: distros
variables:
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
+11 -3
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env xonsh #!/usr/bin/env xonsh
from argparse import ArgumentParser
from pathlib import Path from pathlib import Path
import sys import sys
sys.path.append(str(Path(__file__).parent / "lib")) sys.path.append(str(Path(__file__).parent / "lib"))
@@ -7,6 +6,10 @@ from support import Support, BASE
import time import time
import json import json
from argparse import ArgumentParser
from functools import reduce
from yaml import dump, Dumper, load, Loader
source test.xsh source test.xsh
@@ -78,7 +81,12 @@ def do_build(build):
if args.all or args.list or (args.distro and args.version and args.build): if args.all or args.list or (args.distro and args.version and args.build):
process_all() process_all()
if args.list: if args.list:
my_list = [d.matrix for d in my_list if d.is_github] with open(".gitlab-ci-build.yml.in", "r") as fp:
print(json.dumps({"include": my_list})) y = load(fp, Loader=Loader)
for item in my_list:
if item.is_github:
y[ item.only[6:] ]["parallel"]["matrix"].append({"distro": item.var_path})
with open(".gitlab-ci-build.yml", "w") as fp:
dump(y, fp, Dumper=Dumper)
else: else:
print("Doing menu stuff") print("Doing menu stuff")
+7 -7
View File
@@ -1,16 +1,16 @@
distro = "debian" distro = "debian"
version = "12" version = "12"
iso = { iso = {
url = "http://cdimage.debian.org/cdimage/release/12.2.0/amd64/iso-cd/debian-12.2.0-amd64-netinst.iso" url = "http://cdimage.debian.org/cdimage/release/12.4.0/amd64/iso-cd/debian-12.4.0-amd64-netinst.iso"
checksum = "23ab444503069d9ef681e3028016250289a33cc7bab079259b73100daee0af66" checksum = "64d727dd5785ae5fcfd3ae8ffbede5f40cca96f1580aaa2820e8b99dae989d94"
} }
boot_command = [ boot_command = [
"<esc><wait>", "<esc><wait>",
"auto <wait>", "auto ",
"DEBIAN<wait>_FRONTEND<wait>=text <wait>", "DEBIAN_FRONTEND=text ",
"preseed<wait>/url<wait>=http://{{.HTTPIP}}<wait>:{{ .HTTPPort }}<wait>/preseed.cfg <wait>", "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ",
"console<wait>=tty0 <wait>", "console=tty0 ",
"--- <wait>net<wait>.ifnames<wait>=0 <wait>bios<wait>dev<wait>names=0 <wait>", "--- net.ifnames=0 biosdevnames=0 <wait>",
"<enter>" "<enter>"
] ]
http_directory = "distros/debian/12/http/" http_directory = "distros/debian/12/http/"
+3 -2
View File
@@ -1,4 +1,5 @@
d-i auto-install/enable boolean true d-i auto-install/enable boolean true
d-i apt-setup/disable-cdrom-entries boolean true
d-i debian-installer/locale string en_US d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us d-i keyboard-configuration/xkb-keymap select us
@@ -54,8 +55,8 @@ d-i preseed/early_command string
-e "/in-target/i echo 'discover=d' >> /target/etc/discover-pkginstall.conf" \ -e "/in-target/i echo 'discover=d' >> /target/etc/discover-pkginstall.conf" \
/usr/lib/pre-pkgsel.d/20install-hwpackages /usr/lib/pre-pkgsel.d/20install-hwpackages
d-i preseed/late_command string \ d-i preseed/late_command string \
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \ echo 'Defaults:vagrant !nrequiretty' > /target/etc/sudoers.d/vagrant; \
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \ echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
chmod 440 /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \
in-target apt-get update; \ in-target apt-get update; \
in-target apt-get upgarde -y in-target apt-get upgrade -y
+2 -2
View File
@@ -9,7 +9,7 @@ class Provider:
@property @property
def runner(self) -> str: def runner(self) -> str:
if self.name == "qemu": if self.name == "qemu":
return "isaiah" return "qemu"
elif self.name.startswith("virtualbox"): elif self.name.startswith("virtualbox"):
return "isaiah" return "virtualbox"
return None return None