mirror of
https://github.com/kairos-io/provider-kairos.git
synced 2025-08-17 23:16:39 +00:00
Use re-usable linting workflow (#376)
as part of https://github.com/kairos-io/kairos/issues/1234 --------- Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
80cec50138
commit
c633dbd7fa
17
.github/bump_k3s_versions.sh
vendored
17
.github/bump_k3s_versions.sh
vendored
@ -6,13 +6,14 @@ verlte() {
|
|||||||
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
|
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
versions=($(curl https://update.k3s.io/v1-release/channels | jq -rc '[ .data[] | select(.type == "channel") | select(.name | test("testing") | not) | .latest ] | unique | .[]'))
|
# https://www.shellcheck.net/wiki/SC2207
|
||||||
|
mapfile -t versionsArray < <(curl https://update.k3s.io/v1-release/channels | jq -rc '[ .data[] | select(.type == "channel") | select(.name | test("testing") | not) | .latest ] | unique | .[]')
|
||||||
|
|
||||||
# Filter only versions above v1.20.0 (https://stackoverflow.com/a/40375567)
|
# Filter only versions above v1.20.0 (https://stackoverflow.com/a/40375567)
|
||||||
for index in "${!versions[@]}" ; do
|
for index in "${!versionsArray[@]}" ; do
|
||||||
(verlte ${versions[$index]} v1.20.0) && unset -v 'versions[$index]'
|
(verlte "${versionsArray[$index]}" v1.20.0) && unset -v 'versionsArray[$index]'
|
||||||
done
|
done
|
||||||
versions="${versions[@]}"
|
versions="${versionsArray[*]}"
|
||||||
|
|
||||||
amd64_flavor=("opensuse-leap" "opensuse-tumbleweed" "alpine-ubuntu" "alpine-opensuse-leap" "ubuntu" "ubuntu-20-lts" "ubuntu-22-lts" "fedora" "debian")
|
amd64_flavor=("opensuse-leap" "opensuse-tumbleweed" "alpine-ubuntu" "alpine-opensuse-leap" "ubuntu" "ubuntu-20-lts" "ubuntu-22-lts" "fedora" "debian")
|
||||||
arm64_flavor=("opensuse-leap-arm-rpi" "opensuse-tumbleweed-arm-rpi" "alpine-arm-rpi")
|
arm64_flavor=("opensuse-leap-arm-rpi" "opensuse-tumbleweed-arm-rpi" "alpine-arm-rpi")
|
||||||
@ -22,14 +23,14 @@ releases_arm="[]"
|
|||||||
|
|
||||||
for row in $versions; do
|
for row in $versions; do
|
||||||
for flavor in "${amd64_flavor[@]}"; do
|
for flavor in "${amd64_flavor[@]}"; do
|
||||||
releases=$(echo $releases | jq ". += [{ \"flavor\": \"$flavor\", \"k3s_version\": \"$row\" }]" )
|
releases=$(echo "$releases" | jq ". += [{ \"flavor\": \"$flavor\", \"k3s_version\": \"$row\" }]" )
|
||||||
done
|
done
|
||||||
for flavor in "${arm64_flavor[@]}"; do
|
for flavor in "${arm64_flavor[@]}"; do
|
||||||
for model in "${arm64_models[@]}"; do
|
for model in "${arm64_models[@]}"; do
|
||||||
releases_arm=$(echo $releases_arm | jq ". += [{ \"flavor\": \"$flavor\", \"model\": \"$model\", \"k3s_version\": \"$row\" }]" )
|
releases_arm=$(echo "$releases_arm" | jq ". += [{ \"flavor\": \"$flavor\", \"model\": \"$model\", \"k3s_version\": \"$row\" }]" )
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $releases_arm | jq > releases-arm.json
|
echo "$releases_arm" | jq > releases-arm.json
|
||||||
echo $releases | jq > releases.json
|
echo "$releases" | jq > releases.json
|
||||||
|
8
.github/bump_repositories.sh
vendored
8
.github/bump_repositories.sh
vendored
@ -1,8 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
root_dir=$(git rev-parse --show-toplevel)
|
|
||||||
|
|
||||||
reference() {
|
reference() {
|
||||||
nr=$1
|
nr=$1
|
||||||
tag=$2
|
tag=$2
|
||||||
@ -14,13 +12,13 @@ YQ=${YQ:-docker run --rm -v "${PWD}":/workdir mikefarah/yq}
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
last_commit_snapshot() {
|
last_commit_snapshot() {
|
||||||
echo $(docker run --rm quay.io/skopeo/stable list-tags docker://$1 | jq -rc '.Tags | map(select( (. | contains("-repository.yaml")) )) | sort_by(. | sub("v";"") | sub("-repository.yaml";"") | sub("-";"") | split(".") | map(tonumber) ) | .[-1]' | sed "s/-repository.yaml//g")
|
docker run --rm quay.io/skopeo/stable list-tags "docker://$1" | jq -rc '.Tags | map(select( (. | contains("-repository.yaml")) )) | sort_by(. | sub("v";"") | sub("-repository.yaml";"") | sub("-";"") | split(".") | map(tonumber) ) | .[-1]' | sed "s/-repository.yaml//g"
|
||||||
}
|
}
|
||||||
|
|
||||||
latest_tag=$(last_commit_snapshot quay.io/kairos/packages)
|
latest_tag=$(last_commit_snapshot quay.io/kairos/packages)
|
||||||
latest_tag_arm64=$(last_commit_snapshot quay.io/kairos/packages-arm64)
|
latest_tag_arm64=$(last_commit_snapshot quay.io/kairos/packages-arm64)
|
||||||
|
|
||||||
$YQ eval "$(reference 0 $latest_tag)" -i repository.yaml
|
$YQ eval "$(reference 0 "$latest_tag")" -i repository.yaml
|
||||||
$YQ eval "$(reference 1 $latest_tag_arm64)" -i repository.yaml
|
$YQ eval "$(reference 1 "$latest_tag_arm64")" -i repository.yaml
|
||||||
|
|
||||||
|
|
||||||
|
16
.github/workflows/lint.yml
vendored
16
.github/workflows/lint.yml
vendored
@ -5,17 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
call-workflow:
|
||||||
runs-on: ubuntu-latest
|
uses: kairos-io/linting-composite-action/.github/workflows/reusable-linting.yaml@main
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
yamldirs: "."
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: '^1.18'
|
|
||||||
- name: Run Lint checks
|
|
||||||
run: |
|
|
||||||
./earthly.sh +lint
|
|
||||||
|
3
.github/workflows/release-arm.yaml
vendored
3
.github/workflows/release-arm.yaml
vendored
@ -114,7 +114,8 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@master
|
uses: docker/setup-buildx-action@master
|
||||||
- name: Build 🔧
|
- name: Build 🔧
|
||||||
run: |
|
run: |
|
||||||
K3S_LATEST=$(curl -s https://update.k3s.io/v1-release/channels | jq -rc '[ .data[] | select(.type == "channel") | select(.name | test("testing") | not) | .latest ] | unique | .[-1]')
|
K3S_LATEST=$(curl -s https://update.k3s.io/v1-release/channels | \
|
||||||
|
jq -rc '[ .data[] | select(.type == "channel") | select(.name | test("testing") | not) | .latest ] | unique | .[-1]')
|
||||||
earthly -P +all-arm-generic --FLAVOR=${{ matrix.flavor }} --K3S_VERSION=$K3S_LATEST
|
earthly -P +all-arm-generic --FLAVOR=${{ matrix.flavor }} --K3S_VERSION=$K3S_LATEST
|
||||||
sudo mv build release
|
sudo mv build release
|
||||||
- name: Push to quay
|
- name: Push to quay
|
||||||
|
@ -5,6 +5,7 @@ rules:
|
|||||||
line-length:
|
line-length:
|
||||||
max: 150
|
max: 150
|
||||||
level: warning
|
level: warning
|
||||||
|
ignore: "tests/assets/qrcode.yaml" # tokens are big
|
||||||
|
|
||||||
# accept both key:
|
# accept both key:
|
||||||
# - item
|
# - item
|
||||||
@ -19,3 +20,7 @@ rules:
|
|||||||
|
|
||||||
document-start:
|
document-start:
|
||||||
present: false
|
present: false
|
||||||
|
ignore: "*" # There are multiple yamls in the same file, we need this sometimes
|
||||||
|
|
||||||
|
comments:
|
||||||
|
ignore: "tests/assets/*" # our #cloud-config header doesn't take a space after the "#"
|
||||||
|
44
Earthfile
44
Earthfile
@ -24,7 +24,9 @@ ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools:v0.6.0
|
|||||||
|
|
||||||
## External deps pinned versions
|
## External deps pinned versions
|
||||||
ARG LUET_VERSION=0.33.0
|
ARG LUET_VERSION=0.33.0
|
||||||
ARG GOLINT_VERSION=1.52.2
|
ARG GOLANGCILINT_VERSION=v1.52-alpine
|
||||||
|
ARG HADOLINT_VERSION=2.12.0-alpine
|
||||||
|
ARG SHELLCHECK_VERSION=v0.9.0
|
||||||
ARG GO_VERSION=1.20
|
ARG GO_VERSION=1.20
|
||||||
|
|
||||||
ARG OS_ID=kairos
|
ARG OS_ID=kairos
|
||||||
@ -407,19 +409,39 @@ run-proxmox-tests:
|
|||||||
RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/e2e/
|
RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/e2e/
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
BUILD +golint
|
BUILD +hadolint
|
||||||
|
BUILD +renovate-validator
|
||||||
|
BUILD +shellcheck-lint
|
||||||
|
BUILD +golangci-lint
|
||||||
BUILD +yamllint
|
BUILD +yamllint
|
||||||
|
|
||||||
golint:
|
hadolint:
|
||||||
ARG GO_VERSION
|
FROM hadolint/hadolint:${HADOLINT_VERSION}
|
||||||
FROM golang:$GO_VERSION
|
COPY . /work
|
||||||
ARG GOLINT_VERSION
|
WORKDIR /work
|
||||||
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION
|
RUN find . -name "Dockerfile*" -print | xargs -r -n1 hadolint
|
||||||
WORKDIR /build
|
|
||||||
COPY . .
|
renovate-validator:
|
||||||
|
FROM renovate/renovate
|
||||||
|
COPY . /work
|
||||||
|
WORKDIR /work
|
||||||
|
ENV RENOVATE_VERSION="35"
|
||||||
|
RUN renovate-config-validator
|
||||||
|
|
||||||
|
shellcheck-lint:
|
||||||
|
FROM koalaman/shellcheck-alpine:${SHELLCHECK_VERSION}
|
||||||
|
COPY . /work
|
||||||
|
WORKDIR /work
|
||||||
|
RUN find . -name "*.sh" -print | xargs -r -n1 shellcheck
|
||||||
|
|
||||||
|
golangci-lint:
|
||||||
|
FROM golangci/golangci-lint:${GOLANGCILINT_VERSION}
|
||||||
|
COPY . /work
|
||||||
|
WORKDIR /work
|
||||||
RUN golangci-lint run --timeout 360s
|
RUN golangci-lint run --timeout 360s
|
||||||
|
|
||||||
yamllint:
|
yamllint:
|
||||||
FROM cytopia/yamllint
|
FROM cytopia/yamllint
|
||||||
COPY . .
|
COPY . /work
|
||||||
RUN yamllint .github/workflows/
|
WORKDIR /work
|
||||||
|
RUN find . -name "*.yml" -or -name "*.yaml" -print | xargs -r -n1
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock --rm -t -v $(pwd):/workspace -v earthly-tmp:/tmp/earthly:rw earthly/earthly:v0.6.21 --allow-privileged $@
|
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock --rm -t -v "$(pwd):/workspace" -v earthly-tmp:/tmp/earthly:rw earthly/earthly:v0.6.21 --allow-privileged "$@"
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
for n in $(k3s kubectl get namespace -A | tr -s ' ' | cut -f1 -d' ' | tail -n +2); do
|
for n in $(k3s kubectl get namespace -A | tr -s ' ' | cut -f1 -d' ' | tail -n +2); do
|
||||||
for p in $(k3s kubectl get pods -n $n | tr -s ' ' | cut -f1 -d' ' | tail -n +2); do
|
for p in $(k3s kubectl get pods -n "$n" | tr -s ' ' | cut -f1 -d' ' | tail -n +2); do
|
||||||
echo ---------------------------
|
echo ---------------------------
|
||||||
echo $n - $p
|
echo "$n" - "$p"
|
||||||
echo ---------------------------
|
echo ---------------------------
|
||||||
k3s kubectl logs $p -n $n
|
k3s kubectl logs "$p" -n "$n"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
stages:
|
stages:
|
||||||
initramfs:
|
initramfs:
|
||||||
- name: "Set user and password"
|
- name: Set user and password
|
||||||
users:
|
users:
|
||||||
kairos:
|
kairos:
|
||||||
passwd: "kairos"
|
passwd: kairos
|
||||||
|
|
||||||
k3s:
|
k3s:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
write_files:
|
write_files:
|
||||||
- path: /var/lib/rancher/k3s/server/manifests/suc.yaml
|
- path: /var/lib/rancher/k3s/server/manifests/suc.yaml
|
||||||
permissions: "0644"
|
permissions: "0644"
|
||||||
|
Loading…
Reference in New Issue
Block a user