From c8d8ab306c50aa19faafed7f2df0c8da4bcaa18a Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Mon, 25 Nov 2024 22:09:36 -0500 Subject: [PATCH] fix(ci): Build all features for each package and build all archs --- .github/workflows/build-pr.yml | 4 ++-- .github/workflows/build.yml | 6 +++--- .github/workflows/tag.yml | 4 ++-- Earthfile | 36 ++++++++++++++++++++++++++-------- justfile | 3 +++ 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 007b00d..3264010 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -115,7 +115,7 @@ jobs: - name: Run build id: build run: | - earthly --ci --push -P +build-images + earthly --ci --push -P +build-images-all build-scripts: timeout-minutes: 5 @@ -140,7 +140,7 @@ jobs: - name: Run build id: build run: | - earthly --ci --push -P +build-scripts + earthly --ci --push -P +build-scripts-all integration-tests: permissions: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee30e38..551064d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,7 +172,7 @@ jobs: - name: Run build id: build run: | - earthly --ci --push -P +build-scripts + earthly --ci --push -P +build-scripts-all build-images: permissions: @@ -215,11 +215,11 @@ jobs: - name: Run build if: github.repository == 'blue-build/cli' - run: earthly --push --ci -P +build-images + run: earthly --push --ci -P +build-images-all - name: Run build fork if: github.repository != 'blue-build/cli' - run: earthly --ci -P +build-images + run: earthly --ci -P +build-images-all integration-tests: permissions: diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 58e4a63..8eb1255 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -102,7 +102,7 @@ jobs: LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) CARGO_PACKAGE_VERSION="v$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')" LATEST=$(test "$CARGO_PACKAGE_VERSION" = "$LATEST_TAG" && echo true || echo false) - earthly --ci --push +build-scripts --TAGGED="true" --LATEST="$LATEST" + earthly --ci --push +build-scripts-all --TAGGED="true" --LATEST="$LATEST" build-images: permissions: @@ -140,4 +140,4 @@ jobs: LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) CARGO_PACKAGE_VERSION="v$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "blue-build") .version')" LATEST=$(test "$CARGO_PACKAGE_VERSION" = "$LATEST_TAG" && echo true || echo false) - earthly --push --ci -P +build-images --TAGGED="true" --LATEST="$LATEST" + earthly --push --ci -P +build-images-all --TAGGED="true" --LATEST="$LATEST" diff --git a/Earthfile b/Earthfile index 766bd91..583846c 100644 --- a/Earthfile +++ b/Earthfile @@ -16,6 +16,12 @@ run-checks: BUILD +lint BUILD +test +build-images-all: + BUILD --platform=linux/amd64 --platform=linux/arm64 +build-images + +build-scripts-all: + BUILD --platform=linux/amd64 --platform=linux/arm64 +build-scripts + build-images: BUILD +blue-build-cli BUILD +blue-build-cli-distrobox @@ -31,12 +37,7 @@ lint: DO rust+CARGO --args="clippy" DO rust+CARGO --args="clippy --all-features" DO rust+CARGO --args="clippy --no-default-features" - FOR feat IN $( \ - cargo metadata --format-version 1 \ - | jq -cr '.packages[] | select(.name == "blue-build") | .features | keys | .[] | select(. != "default")' \ - ) - DO rust+CARGO --args="clippy --no-default-features --features $feat" - END + DO +EACH_PACKAGE --args="clippy --no-default-features" test: FROM +common @@ -46,11 +47,30 @@ test: DO rust+CARGO --args="test --workspace" DO rust+CARGO --args="test --workspace --all-features" DO rust+CARGO --args="test --workspace --no-default-features" + DO +EACH_PACKAGE --args="test --no-default-features" + +EACH_PACKAGE: + FUNCTION + ARG --required args + + FOR package IN $( \ + cargo metadata --format-version 1 \ + | jq -cr '.workspace_members | .[]' \ + | sed 's|.*#||' | sed 's|@.*||' \ + ) + DO --pass-args +EACH_FEAT --package="$package" + END + +EACH_FEAT: + FUNCTION + ARG --required args + ARG --required package + FOR feat IN $( \ cargo metadata --format-version 1 \ - | jq -cr '.packages[] | select(.name == "blue-build") | .features | keys | .[] | select(. != "default")' \ + | jq -cr ".packages[] | select(.name == \"$package\") | .features | keys | .[] | select(. != \"default\")" \ ) - DO rust+CARGO --args="test --workspace --features $feat" + DO rust+CARGO --args="$args --package $package --features $feat" END install: diff --git a/justfile b/justfile index af617c3..0ae64fe 100644 --- a/justfile +++ b/justfile @@ -97,6 +97,9 @@ tools: release *args: #!/usr/bin/env bash set -euxo pipefail + + earthly --ci +run-checks + # --workspace: updating all crates in the workspace # --no-tag: do not push tag for each new version # --no-confirm: don't look for user input, just run the command