fix: improve taskfiles and e2e test (#1615)

This commit is contained in:
Devin Buhl authored and GitHub committed 2024-10-26 14:01:59 -04:00
1 parent d71c3e163d
commit 68e07e7807
6 files changed
+102 -60

No files matched your search

+39 -1
View File
@@ -12,6 +12,44 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
archlinux:
name: workstation (archlinux)
runs-on: ubuntu-latest
container:
image: greyltc/archlinux-aur:yay
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Arch dependencies
shell: bash
run: >-
sudo -E -u ab -D~ bash -c '
cd $GITHUB_WORKSPACE;
yay -Syu --needed --noconfirm --noprogressbar go-task;
go-task workstation:arch
'
generic-linux:
name: workstation (generic-linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Homebrew
id: setup-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Setup Workflow Tools
shell: bash
run: brew install go-task
- name: Run Workstation Generic linux tasks
shell: bash
run: task workstation:generic-linux
configure: configure:
if: ${{ github.repository == 'onedr0p/cluster-template' }} if: ${{ github.repository == 'onedr0p/cluster-template' }}
name: configure name: configure
@@ -33,7 +71,7 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
id: setup-python id: setup-python
with: with:
python-version: "3.11" # minimum supported version python-version: "3.11"
- name: Cache homebrew packages - name: Cache homebrew packages
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
+22 -6
View File
@@ -76,14 +76,30 @@ tasks:
status: status:
- test -f {{.SOPS_AGE_KEY_FILE}} - test -f {{.SOPS_AGE_KEY_FILE}}
encrypt: template:
desc: Encrypt all Kubernetes SOPS secrets internal: true
cmd: '{{.VIRTUAL_ENV}}/bin/makejinja'
preconditions:
- msg: Missing virtual environment
sh: test -d {{.VIRTUAL_ENV}}
- msg: Missing Makejinja config file
sh: test -f {{.MAKEJINJA_CONFIG_FILE}}
- msg: Missing Makejinja plugin file
sh: test -f {{.BOOTSTRAP_DIR}}/scripts/plugin.py
- msg: Missing bootstrap config file
sh: test -f {{.BOOTSTRAP_CONFIG_FILE}}
secrets:
internal: true
cmds:
- for: { var: SECRET_FILES }
cmd: | cmd: |
find "{{.KUBERNETES_DIR}}" -type f -name "*.sops.*" | while read -r file; do if sops filestatus "{{.ITEM}}" | jq --exit-status ".encrypted == false" &>/dev/null; then
if sops filestatus "${file}" | jq --exit-status ".encrypted == false" &>/dev/null; then sops --encrypt --in-place "{{.ITEM}}"
sops --encrypt --in-place "${file}"
fi fi
done vars:
SECRET_FILES:
sh: find "{{.KUBERNETES_DIR}}" -type f -name "*.sops.*"
preconditions: preconditions:
- msg: Missing Sops config file - msg: Missing Sops config file
sh: test -f {{.SOPS_CONFIG_FILE}} sh: test -f {{.SOPS_CONFIG_FILE}}
+1
View File
@@ -10,6 +10,7 @@ jq
kubeconform kubeconform
kubectl-bin kubectl-bin
kustomize kustomize
minijinja
moreutils moreutils
sops sops
stern-bin stern-bin
+1
View File
@@ -12,6 +12,7 @@ brew "jq"
brew "kubeconform" brew "kubeconform"
brew "kubernetes-cli" brew "kubernetes-cli"
brew "kustomize" brew "kustomize"
brew "minijinja-cli"
brew "moreutils" brew "moreutils"
brew "siderolabs/tap/talosctl" brew "siderolabs/tap/talosctl"
brew "sops" brew "sops"
+27 -19
View File
@@ -9,10 +9,10 @@ tasks:
cmd: '{{.PKGMGR}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ROOT_DIR}}/.taskfiles/workstation/Archfile | xargs)' cmd: '{{.PKGMGR}} -Syu --needed --noconfirm --noprogressbar $(cat {{.ROOT_DIR}}/.taskfiles/workstation/Archfile | xargs)'
vars: vars:
PKGMGR: PKGMGR:
sh: command -v yay || command -v paru sh: command -v paru || command -v yay
preconditions: preconditions:
- msg: Missing yay or paru - msg: Missing paru or yay
sh: command -v brew &>/dev/null || command -v paru &>/dev/null sh: command -v paru &>/dev/null || command -v yay &>/dev/null
- msg: Missing Archfile - msg: Missing Archfile
sh: test -f {{.ROOT_DIR}}/.taskfiles/workstation/Archfile sh: test -f {{.ROOT_DIR}}/.taskfiles/workstation/Archfile
@@ -46,24 +46,32 @@ tasks:
platforms: ['linux/amd64', 'linux/arm64'] platforms: ['linux/amd64', 'linux/arm64']
cmds: cmds:
- for: - for:
- budimanjojo/talhelper?as=talhelper&type=script - budimanjojo/talhelper?as=talhelper
- cloudflare/cloudflared?as=cloudflared&type=script - cloudflare/cloudflared?as=cloudflared
- FiloSottile/age?as=age&type=script - FiloSottile/age?as=age
- fluxcd/flux2?as=flux&type=script - fluxcd/flux2?as=flux
- getsops/sops?as=sops&type=script - helmfile/helmfile?as=helmfile
- helmfile/helmfile?as=helmfile&type=script - jqlang/jq?as=jq
- jqlang/jq?as=jq&type=script - kubernetes-sigs/kustomize?as=kustomize
- kubernetes-sigs/kustomize?as=kustomize&type=script - mikefarah/yq?as=yq
- siderolabs/talos?as=talosctl&type=script - siderolabs/talos?as=talosctl
- yannh/kubeconform?as=kubeconform&type=script - yannh/kubeconform?as=kubeconform
- mikefarah/yq?as=yq&type=script cmd: curl -fsSL "https://i.jpillora.com/{{.ITEM}}&type=script" | bash
cmd: curl -fsSL "https://i.jpillora.com/{{.ITEM}}" | bash - cmd: |
- cmd: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl";
curl -sSfL -o sops https://github.com/getsops/sops/releases/latest/download/sops-v3.9.1.linux.amd64
platforms: ['linux/amd64'] platforms: ['linux/amd64']
- cmd: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl" - cmd: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl";
curl -sSfL -o sops https://github.com/getsops/sops/releases/latest/download/sops-v3.9.1.linux.arm64
platforms: ['linux/arm64'] platforms: ['linux/arm64']
- cmd: chmod +x kubectl - cmd: chmod +x kubectl sops
- cmd: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | USE_SUDO="false" HELM_INSTALL_DIR="." bash - cmd: curl -sSfL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- cmd: curl -sSfL https://github.com/mitsuhiko/minijinja/releases/latest/download/minijinja-cli-installer.sh | bash
env:
MINIJINJA_CLI_INSTALL_DIR: '.'
HELM_INSTALL_DIR: '.'
USE_SUDO: 'false'
venv: venv:
desc: Set up virtual environment desc: Set up virtual environment
+12 -34
View File
@@ -2,6 +2,9 @@
# yaml-language-server: $schema=https://taskfile.dev/schema.json # yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3' version: '3'
set: [pipefail]
shopt: [globstar]
vars: vars:
BOOTSTRAP_DIR: '{{.ROOT_DIR}}/bootstrap' BOOTSTRAP_DIR: '{{.ROOT_DIR}}/bootstrap'
KUBERNETES_DIR: '{{.ROOT_DIR}}/kubernetes' KUBERNETES_DIR: '{{.ROOT_DIR}}/kubernetes'
@@ -31,44 +34,19 @@ tasks:
init: init:
desc: Initialize configuration files desc: Initialize configuration files
cmds: cmd: cp {{.BOOTSTRAP_CONFIG_FILE | replace ".yaml" ".sample.yaml"}} {{.BOOTSTRAP_CONFIG_FILE}}
- cp {{if eq OS "darwin"}}-n{{else}}--update=none{{end}} {{.BOOTSTRAP_CONFIG_FILE | replace ".yaml" ".sample.yaml"}} {{.BOOTSTRAP_CONFIG_FILE}}
- echo "=== Configuration file copied ==="
- echo "Proceed with updating the configuration files..."
- echo "{{.BOOTSTRAP_CONFIG_FILE}}"
status: status:
- test -f {{.BOOTSTRAP_CONFIG_FILE}} - test -f {{.BOOTSTRAP_CONFIG_FILE}}
silent: true
configure: configure:
desc: Configure repository from bootstrap vars desc: Render and validate configuration files
prompt: Any conflicting config in the kubernetes directory will be overwritten... continue? prompt: Any conflicting config in the kubernetes directory will be overwritten... continue?
deps: ['workstation:direnv', 'workstation:venv', 'bootstrap:age-keygen', 'init'] deps:
cmds: - init
- task: template - bootstrap:age-keygen
- task: bootstrap:encrypt - workstation:direnv
- task: validate - workstation:venv
template:
internal: true
cmd: '{{.VIRTUAL_ENV}}/bin/makejinja'
preconditions:
- msg: Missing virtual environment
sh: test -d {{.VIRTUAL_ENV}}
- msg: Missing Makejinja config file
sh: test -f {{.MAKEJINJA_CONFIG_FILE}}
- msg: Missing Makejinja plugin file
sh: test -f {{.BOOTSTRAP_DIR}}/scripts/plugin.py
- msg: Missing bootstrap config file
sh: test -f {{.BOOTSTRAP_CONFIG_FILE}}
validate:
internal: true
cmds: cmds:
- task: bootstrap:template
- task: bootstrap:secrets
- task: kubernetes:kubeconform - task: kubernetes:kubeconform
- echo "=== Done rendering and validating YAML ==="
- '{{if eq .HOME_SOPS_AGE_KEY_FILE_EXISTS "true"}}echo "WARNING: SOPS Age key found in home directory, this may cause conflicts."{{end}}'
vars:
HOME_SOPS_AGE_KEY_FILE_EXISTS:
sh: test -f ~/.config/sops/age/keys.txt && echo true || echo false
silent: true