Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/actions/build-eve/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ inputs:
cache-artifact:
required: true
description: "Name of the linuxkit cache artifact to download"
cover:
required: false
default: 'false'
description: "Build pillar with COVER=y so zedbox is coverage-instrumented"

runs:
using: composite
Expand All @@ -40,14 +44,30 @@ runs:
shell: bash
env:
PR_ID: ${{ github.event.pull_request.number }}
COVER: ${{ inputs.cover }}
run: |
COMMIT_ID=$(git describe --abbrev=8 --always)
echo "VERSION=0.0.0-pr$PR_ID-$COMMIT_ID" >> $GITHUB_ENV
echo "TAG=evebuild/pr:$PR_ID" >> $GITHUB_ENV
if [ "$COVER" = "true" ]; then
echo "VERSION=0.0.0-pr$PR_ID-$COMMIT_ID-cover" >> "$GITHUB_ENV"
echo "TAG=evebuild/pr-cover:$PR_ID" >> "$GITHUB_ENV"
echo "ARTIFACT_BASE=eve-cover-${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}" >> "$GITHUB_ENV"
else
echo "VERSION=0.0.0-pr$PR_ID-$COMMIT_ID" >> "$GITHUB_ENV"
echo "TAG=evebuild/pr:$PR_ID" >> "$GITHUB_ENV"
echo "ARTIFACT_BASE=eve-${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}" >> "$GITHUB_ENV"
fi
- name: Rebuild pillar with coverage instrumentation
if: ${{ inputs.cover == 'true' }}
shell: bash
run: |
make V=1 ROOTFS_VERSION="$VERSION" COVER=y PLATFORM=${{ inputs.platform }} \
HV=${{ inputs.hv }} ZARCH=${{ inputs.arch }} eve-pillar
- name: Build EVE ${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}
shell: bash
env:
COVER_FLAG: ${{ inputs.cover == 'true' && 'COVER=y' || '' }}
run: |
make V=1 ROOTFS_VERSION="$VERSION" PLATFORM=${{ inputs.platform }} \
make V=1 ROOTFS_VERSION="$VERSION" $COVER_FLAG PLATFORM=${{ inputs.platform }} \
HV=${{ inputs.hv }} ZARCH=${{ inputs.arch }} eve
- name: Post build report
shell: bash
Expand All @@ -59,13 +79,13 @@ runs:
run: |
make cache-export ZARCH=${{ inputs.arch }} \
IMAGE=lfedge/eve:$VERSION-${{ inputs.hv }} \
OUTFILE=eve-${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}.tar \
OUTFILE=$ARTIFACT_BASE.tar \
IMAGE_NAME=$TAG-${{ inputs.hv }}-${{ inputs.arch }}
- name: Upload EVE image
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: eve-${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}
path: eve-${{ inputs.hv }}-${{ inputs.arch }}-${{ inputs.platform }}.tar
name: ${{ env.ARTIFACT_BASE }}
path: ${{ env.ARTIFACT_BASE }}.tar
- name: Clean
if: always()
shell: bash
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,36 @@
hv: kvm
cache-artifact: linuxkit-cache-amd64-generic

# Coverage-instrumented build. Opt-in via the `coverage` PR label so the
# extra ~1× build cost only lands on PRs that want a coverage signal from
# the Eden test matrix. The Eden trusted workflow's tests-master-cover job
# consumes the eve-cover-* artifact this produces.
eve-amd64-kvm-generic-cover:
name: "eve (amd64, kvm, generic, cover)"
needs: pkgs-amd64-generic
if: ${{ contains(github.event.pull_request.labels.*.name, 'coverage') }}
runs-on: zededa-ubuntu-2204
timeout-minutes: 1440
steps:
- name: Clear repository
shell: bash
run: |
sudo rm -fr "$GITHUB_WORKSPACE" && mkdir "$GITHUB_WORKSPACE"
rm -fr ~/.linuxkit
docker system prune --all --force --volumes
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: ./.github/actions/build-eve
with:
arch: amd64
platform: generic
hv: kvm
cache-artifact: linuxkit-cache-amd64-generic
cover: 'true'

# ── amd64 rt ──

eve-amd64-kvm-rt:
Expand Down Expand Up @@ -459,7 +489,7 @@
- name: Set environment
env:
PR_ID: ${{ github.event.pull_request.number }}
run: |

Check warning on line 492 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:3:34: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/build.yml:492:9: shellcheck reported issue in this script: SC2086:info:3:34: Double quote to prevent globbing and word splitting [shellcheck]

Check warning on line 492 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:2:45: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/build.yml:492:9: shellcheck reported issue in this script: SC2086:info:2:45: Double quote to prevent globbing and word splitting [shellcheck]
COMMIT_ID=$(git describe --abbrev=8 --always)
echo "VERSION=0.0.0-pr$PR_ID-$COMMIT_ID" >> $GITHUB_ENV
echo "TAG=evebuild/pr:$PR_ID" >> $GITHUB_ENV
Expand All @@ -471,7 +501,7 @@
df -h && free -m
docker system df -v
- name: Export docker container
run: |

Check warning on line 504 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:2:51: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/build.yml:504:9: shellcheck reported issue in this script: SC2086:info:2:51: Double quote to prevent globbing and word splitting [shellcheck]

Check warning on line 504 in .github/workflows/build.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:1:50: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/build.yml:504:9: shellcheck reported issue in this script: SC2086:info:1:50: Double quote to prevent globbing and word splitting [shellcheck]
make cache-export ZARCH=riscv64 IMAGE=lfedge/eve:$VERSION-mini \
OUTFILE=eve-mini-riscv64-generic.tar IMAGE_NAME=$TAG-mini-riscv64
- name: Upload EVE mini-riscv64-generic
Expand Down
45 changes: 43 additions & 2 deletions .github/workflows/eden-trusted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
gate_run_id: ${{ steps.extract.outputs.gate_run_id }}
gate_status_name: ${{ steps.extract.outputs.gate_status_name }}
skip_run: ${{ steps.check_gate.outputs.skip_run }}
has_coverage: ${{ steps.labels.outputs.has_coverage }}
steps:
- name: Download
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -66,7 +67,7 @@
env:
RUN_CONTEXT_FILE: ${{ env.RUN_CONTEXT_FILE }}
REQUIRED_FIELDS: pr_id, original_run_id, pr_sha, pr_base_ref, hv, arch, platform, gate_run_id, gate_status_name
run: |

Check warning on line 70 in .github/workflows/eden-trusted.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:6:14: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/eden-trusted.yml:70:9: shellcheck reported issue in this script: SC2086:info:6:14: Double quote to prevent globbing and word splitting [shellcheck]
if [[ ! -f "$RUN_CONTEXT_FILE" ]]; then
echo "$RUN_CONTEXT_FILE file not found"
exit 1
Expand Down Expand Up @@ -97,7 +98,7 @@
id: extract
env:
FIELDS: pr_id, original_run_id, pr_sha, pr_base_ref, hv, arch, platform, gate_run_id, gate_status_name
run: |

Check warning on line 101 in .github/workflows/eden-trusted.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/eden-trusted.yml:101:9: shellcheck reported issue in this script: SC2086:info:3:42: Double quote to prevent globbing and word splitting [shellcheck]
# Extract fields from the JSON file
for field in $(echo "$FIELDS" | tr ',' ' '); do
value=$(jq -r --arg f "$field" '.[$f]' $RUN_CONTEXT_FILE)
Expand All @@ -108,6 +109,22 @@
echo "$field=$value" >> "$GITHUB_OUTPUT"
done

- name: Detect coverage label
if: ${{ steps.check_gate.outputs.skip_run == 'false' }}
id: labels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_ID: ${{ steps.extract.outputs.pr_id }}
run: |
# gh api bypasses the classic-Projects GraphQL deprecation error that
# affects `gh pr view` on lf-edge repos.
has=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_ID}" --jq '.labels[].name' | grep -Fx coverage || true)
if [ -n "$has" ]; then
echo "has_coverage=true" >> "$GITHUB_OUTPUT"
else
echo "has_coverage=false" >> "$GITHUB_OUTPUT"
fi

- name: Define Titles
if: ${{ steps.check_gate.outputs.skip_run == 'false' }}
id: titles
Expand Down Expand Up @@ -227,16 +244,36 @@
artifact_run_id: ${{ needs.context.outputs.original_run_id }}
eden_version: "master"

# Coverage-instrumented run, opt-in via the `coverage` PR label. Consumes
# the eve-cover-* artifact produced by build.yml's *-cover job and emits
# the covdata-merged artifact via eden's coverage-merge job.
tests-master-cover:
name: ${{ needs.context.outputs.eden_parent_job_title }} for master (cover)
needs: context
if: >-
needs.context.outputs.skip_run == 'false'
&& needs.context.outputs.pr_base_ref == 'master'
&& needs.context.outputs.has_coverage == 'true'
uses: lf-edge/eden/.github/workflows/test.yml@master
secrets: inherit
with:
eve_image: "evebuild/pr-cover:${{ needs.context.outputs.pr_id }}"
eve_log_level: "debug"
eve_artifact_name: "eve-cover-${{ needs.context.outputs.hv }}-${{ needs.context.outputs.arch }}-${{ needs.context.outputs.platform }}"
artifact_run_id: ${{ needs.context.outputs.original_run_id }}
eden_version: "master"

finalize:
name: Eden Tests Complete
needs: [context, tests-13-4-stable, tests-14-5-stable, tests-16-0-stable, tests-master]
needs: [context, tests-13-4-stable, tests-14-5-stable, tests-16-0-stable, tests-master, tests-master-cover]
if: always() && needs.context.outputs.skip_run == 'false'
runs-on: ubuntu-latest
steps:
- name: Check test results
id: check
run: |
# Determine which job ran
# Determine which job ran. The cover variant runs alongside
# tests-master on coverage-labeled PRs; require both to succeed.
if [[ "${{ needs.tests-13-4-stable.result }}" != "skipped" ]]; then
result="${{ needs.tests-13-4-stable.result }}"
elif [[ "${{ needs.tests-14-5-stable.result }}" != "skipped" ]]; then
Expand All @@ -245,6 +282,10 @@
result="${{ needs.tests-16-0-stable.result }}"
else
result="${{ needs.tests-master.result }}"
cover_result="${{ needs.tests-master-cover.result }}"
if [[ "$cover_result" != "skipped" && "$cover_result" != "success" ]]; then
result="$cover_result"
fi
fi

echo "Eden tests result: $result"
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/pr-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |

Check failure on line 46 in .github/workflows/pr-gate.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck] Raw Output: e:.github/workflows/pr-gate.yml:46:9: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck]
pr_id=$(gh api /search/issues -X GET -f q="type:pr is:open repo:${GH_REPO} sha:${{ github.event.workflow_run.head_sha }}" -q '.items[0].number')
pr_base_ref=$(gh pr view "$pr_id" --json baseRefName -q '.baseRefName')
echo "pr_id=$pr_id" >> "$GITHUB_OUTPUT"
Expand All @@ -56,7 +56,7 @@
if: github.event_name == 'pull_request_review'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |

Check failure on line 59 in .github/workflows/pr-gate.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck] Raw Output: e:.github/workflows/pr-gate.yml:59:9: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck]
pr_sha="${{ github.event.pull_request.head.sha }}"
original_run_id=$(gh run --repo ${{ github.repository }} list -c "$pr_sha" --json name,databaseId --limit 100 | jq ".[] | select(.name == \"${{ env.BUILD_WF_NAME }}\") | .databaseId " | head -n1)
echo "pr_id=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
Expand All @@ -66,7 +66,7 @@

- name: Promote Context for Local Use
id: meta
run: |

Check failure on line 69 in .github/workflows/pr-gate.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck] Raw Output: e:.github/workflows/pr-gate.yml:69:9: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck]
echo "pr_id=${{ steps.from_run.outputs.pr_id || steps.from_review.outputs.pr_id }}" >> "$GITHUB_OUTPUT"
echo "pr_sha=${{ steps.from_run.outputs.pr_sha || steps.from_review.outputs.pr_sha }}" >> "$GITHUB_OUTPUT"
echo "original_run_id=${{ steps.from_run.outputs.original_run_id || steps.from_review.outputs.original_run_id }}" >> "$GITHUB_OUTPUT"
Expand All @@ -78,7 +78,7 @@
GH_TOKEN: ${{ github.token }}
PR: ${{ steps.meta.outputs.pr_id }}
GH_REPO: ${{ github.repository }}
run: |

Check warning on line 81 in .github/workflows/pr-gate.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:2:80: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/pr-gate.yml:81:9: shellcheck reported issue in this script: SC2086:info:2:80: Double quote to prevent globbing and word splitting [shellcheck]
decision=$(gh pr view "$PR" --json reviewDecision -q .reviewDecision)
echo "approved=$([[ $decision == 'APPROVED' ]] && echo true || echo false)" >> $GITHUB_OUTPUT

Expand All @@ -89,19 +89,35 @@
RUN_ID: ${{ steps.meta.outputs.original_run_id }}
GH_REPO: ${{ github.repository }}
BUILD_JOB_NAME: "eve (${{ matrix.arch }}, ${{ matrix.hv }}, ${{ matrix.platform }})"
COVER_BUILD_JOB_NAME: "eve (${{ matrix.arch }}, ${{ matrix.hv }}, ${{ matrix.platform }}, cover)"
run: |
build_conclusion=$(gh api \
/repos/$GH_REPO/actions/runs/$RUN_ID/jobs \
-X GET \
-q ".jobs[] | select(.name == \"$BUILD_JOB_NAME\") | .conclusion" ) || api_status=$?
jobs_json=$(gh api "/repos/$GH_REPO/actions/runs/$RUN_ID/jobs") || api_status=$?

if [[ "${api_status:-0}" -ne 0 ]]; then
echo "::error::Failed to fetch build job status for run $RUN_ID"
echo "build_ok=false" >>"$GITHUB_OUTPUT"
else
echo "build_ok=$([[ "$build_conclusion" == 'success' ]] && echo true || echo false)" >>"$GITHUB_OUTPUT"
exit 0
fi

# On the pull_request_review trigger this step may run while the
# coverage-instrumented build is still in flight. If the cover job
# exists (label present) and is not yet in a terminal state, hold
# the gate -- otherwise eden-trusted's tests-master-cover would
# start before the eve-cover-* artifact is ready. When the label
# is absent the cover job is marked "skipped" at workflow start,
# which is already a terminal state.
cover_status=$(echo "$jobs_json" | \
jq -r ".jobs[] | select(.name == \"$COVER_BUILD_JOB_NAME\") | .status")
if [[ -n "$cover_status" && "$cover_status" != "completed" ]]; then
echo "Cover build status=$cover_status; gate waits for completion"
echo "build_ok=false" >>"$GITHUB_OUTPUT"
exit 0
fi

build_conclusion=$(echo "$jobs_json" | \
jq -r ".jobs[] | select(.name == \"$BUILD_JOB_NAME\") | .conclusion")
echo "build_ok=$([[ "$build_conclusion" == 'success' ]] && echo true || echo false)" >>"$GITHUB_OUTPUT"

- name: Check Gate Condition
id: check
run: |
Expand Down
Loading