Skip to content

Commit

Permalink
Fix bash linting errors and +ci invocations in pipelines
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Karakasilis <[email protected]>
  • Loading branch information
jimmykarily committed Oct 12, 2023
1 parent a8ed0c9 commit 846824a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 28 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/reusable-build-flavor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,36 +81,41 @@ jobs:
- name: Build PR 🔧
if: ${{ github.event_name == 'pull_request' }}
env:
FLAVOR: ${{ inputs.flavor }}
FAMILY: ${{ inputs.family }}
ARTIFACT: ${{ inputs.artifact }}
BASE_IMAGE: ${{ inputs.base_image }}
VERSION: latest
run: |
# Desired artifact names:
# container image: quay.io/kairos/ubuntu:22.04-core-amd64-generic-v2.4.0
# iso: kairos-ubuntu-20.04-core-amd64-generic-v2.4.1-ipxe.iso
#
# TODO:
# - Consume the base-image the right way and fix all pipelines
# - Merge
# - New branch:
# - Merge alma, rocky, fedora to one family dockerfile
# - Move rest of logic from Earthfile to Dockerfiles
# - Create a reusable worflow that simply calls docker build passing the required build-args
# - Delete the earthly base-image target and force the use of the above workflow anywhere needed
# - Make all remaining earthly targets to use a pre-cooked KAIROS_IMAGE rather than calling +base-image
earthly +ci --SECURITY_SCANS=false --VARIANT=core --IMAGE=quay.io/kairos/$ARTIFACT:core-$FLAVOR-amd64-generic-$VERSION --FLAVOR=$FLAVOR --BASE_IMAGE=$BASE_IMAGE --MODEL=generic --FAMILY=$FAMILY
earthly +ci \
--SECURITY_SCANS=false \
--VARIANT=${{ inputs.variant }} \
--FLAVOR=${{ inputs.flavor }} \
--FLAVOR_RELEASE=${{ inputs.flavor_release }} \
--BASE_IMAGE=${{ inputs.base_image }} \
--MODEL=${{ inputs.model }} \
--FAMILY=${{ inputs.family }}
sudo mv build/* .
sudo rm -rf build
- name: Build master 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
FLAVOR: ${{ inputs.flavor }}
# TODO: use inputs.artifact like above
IMAGE: quay.io/kairos/core-${{ inputs.flavor }}:latest
run: |
earthly +ci --VARIANT=core --IMAGE=$IMAGE --FLAVOR=$FLAVOR
earthly +ci \
--SECURITY_SCANS=false \
--VARIANT=${{ inputs.variant }} \
--FLAVOR=${{ inputs.flavor }} \
--FLAVOR_RELEASE=${{ inputs.flavor_release }} \
--BASE_IMAGE=${{ inputs.base_image }} \
--MODEL=${{ inputs.model }} \
--FAMILY=${{ inputs.family }}
sudo mv build/* .
sudo rm -rf build
mkdir sarif
Expand Down Expand Up @@ -153,5 +158,7 @@ jobs:
cosign attest --type spdx --predicate $spdx $image_ref
- name: Push to testing
run: |
docker tag quay.io/kairos/${{ inputs.artifact }}:core-${{ inputs.flavor }}-amd64-generic-latest ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}:24h
docker push ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}:24h
_IMG=$(cat IMAGE)
TEST_IMAGE="ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}:24h"
docker tag $_IMG $TEST_IMAGE
docker push $TEST_IMAGE
14 changes: 11 additions & 3 deletions .github/workflows/reusable-build-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ jobs:
K3S_VERSION=$(sudo luet --config framework-profile.yaml search -o json k8s/k3s | jq '.packages | map(.version) | unique | last')
earthly +ci \
--SECURITY_SCANS=false \
--IMAGE=ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}-provider:24h \
--VARIANT=${{ inputs.variant }} \
--FLAVOR=${{ inputs.flavor }} \
--VARIANT=standard -K3S_VERSION=${K3S_VERSION}
--FLAVOR_RELEASE=${{ inputs.flavor_release }} \
--BASE_IMAGE=${{ inputs.base_image }} \
--MODEL=${{ inputs.model }} \
--FAMILY=${{ inputs.family }} \
--K3S_VERSION=${K3S_VERSION}
sudo mv build/* .
sudo rm -rf build
- uses: actions/upload-artifact@v3
Expand All @@ -80,4 +85,7 @@ jobs:
if-no-files-found: error
- name: Push to testing
run: |
docker push ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}-provider:24h
_IMG=$(cat IMAGE)
TEST_IMAGE="ttl.sh/kairos-${{ inputs.flavor }}-${{ github.sha }}-provider:24h"
docker tag $_IMG $TEST_IMAGE
docker push $TEST_IMAGE
1 change: 1 addition & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ci:

# args for base-image target
ARG --required FLAVOR
ARG --required FLAVOR_RELEASE
ARG --required BASE_IMAGE
ARG --required MODEL
ARG --required VARIANT
Expand Down
28 changes: 17 additions & 11 deletions naming.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
# It's meant to be the single point of truth for artifacts names.

common_artifact_name() {
local flavor_release=$(echo $1 | jq -r .flavorRelease)
local variant=$(echo $1 | jq -r .variant)
local arch=$(echo $1 | jq -r .arch)
local model=$(echo $1 | jq -r .model)
local flavor_release
local variant
local arch
local model
flavor_release=$(echo "$1" | jq -r .flavorRelease)
variant=$(echo "$1" | jq -r .variant)
arch=$(echo "$1" | jq -r .arch)
model=$(echo "$1" | jq -r .model)

if [ "$#" -ne 2 ]; then
echo "Usage: common_artifact_name 'artifactjson' kairos_version"
return 1
fi

if [ -z "$flavor_release" ]; then
echo "flavor_release not define in the given json"
echo "flavor_release not defined in the given json"
exit 1
fi
if [ -z "$variant" ]; then
Expand All @@ -43,13 +47,14 @@ bootable_artifact_name() {
return 1
fi

local flavor=$(echo $1 | jq -r .flavor)
local flavor
flavor=$(echo "$1" | jq -r .flavor)
if [ -z "$flavor" ]; then
echo "flavor not define in the given json"
exit 1
fi

echo kairos-$flavor-$(common_artifact_name $@)
echo "kairos-$flavor-$(common_artifact_name $@)"
}

container_artifact_name() {
Expand All @@ -59,19 +64,20 @@ container_artifact_name() {
fi

# quay.io doesn't accept "+" in the repo name
local version=$(echo $2 | sed 's/+/-/')
local version
version=$(echo "$2" | sed 's/+/-/')
local tag=$(common_artifact_name $1 $version)

local flavor=$(echo $1 | jq -r .flavor)
local flavor
flavor=$(echo "$1" | jq -r .flavor)
if [ -z "$flavor" ]; then
echo "flavor not define in the given json"
exit 1
fi

echo $3/$flavor:$tag
echo "$3/$flavor:$tag"
}


function_name="$1"
shift

Expand Down

0 comments on commit 846824a

Please sign in to comment.