Skip to content

Commit 7bf7056

Browse files
committed
feat(aws-ami): add test result reporting to ami-build test-ami jobs
Mirrors the per-image-test report format used by the Azure / OCI / GenericCloud / OpenNebula test workflows. - Capture the full `/etc/almalinux-release` line (including code name) and the rpm-reported system arch into `ALMA_RELEASE` / `SYSTEM_ARCH` env vars during the existing Test AMI step. The original validation greps (release prefix, AMI_ARCH match, dnf check-update) are preserved verbatim. - New `Get AMI Name` step fetches the AMI's Name tag via `aws ec2 describe-images` so the report headline shows the canonical AlmaLinux image name instead of a bare `ami-...` id. Falls back to the AMI ID if the tag is empty. - New `Job summary` step writes a Markdown block to `$GITHUB_STEP_SUMMARY`: ## AMI Image Test - **AMI Name**: `...` - **AMI ID**: `ami-...` - **Instance Type**: `t3.medium` / `t4g.medium` - **AlmaLinux release**: `AlmaLinux release X.Y (Codename)` - **System architecture**: `x86_64` / `aarch64` - **Test**: passed ✅ / failed ❌ - New `Send notification to Mattermost` step pushes the same fields through `mattermost/action-mattermost-notify@master`, gated on `inputs.notify_mattermost && env.AMI_ID != ''`. Wiring matches the existing build-ami job's Mattermost step (`secrets.MATTERMOST_WEBHOOK_URL` / `vars.MATTERMOST_CHANNEL`). All three new steps run under `if: always()`, so a failing test (release grep, arch grep, or dnf check-update) still produces a report with `failed ❌` and a Mattermost notification. The passed/failed signal comes from `${{ job.status }}`, so it accurately reflects what happened upstream in the same job.
1 parent 699be3d commit 7bf7056

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/ami-build.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,18 @@ jobs:
238238
239239
echo "[Debug] AlmaLinux release:"
240240
grep "${OS_RELEASE}" /etc/almalinux-release || exit 1
241+
# Capture the full /etc/almalinux-release line (including code name)
242+
# so the job-summary / Mattermost-notification steps below can show
243+
# the same string the user sees from `cat /etc/almalinux-release`.
244+
ALMA_RELEASE=$(head -n1 /etc/almalinux-release)
245+
echo "ALMA_RELEASE=${ALMA_RELEASE}" >> "$GITHUB_ENV"
246+
241247
echo "[Debug] System architecture:"
242-
rpm -q --qf='%{ARCH}\n' $(rpm -qf /etc/almalinux-release) | grep '${{ env.AMI_ARCH }}' || exit 1
248+
SYSTEM_ARCH=$(rpm -q --qf='%{ARCH}' $(rpm -qf /etc/almalinux-release))
249+
echo " ${SYSTEM_ARCH}"
250+
echo "${SYSTEM_ARCH}" | grep '${{ env.AMI_ARCH }}' || exit 1
251+
echo "SYSTEM_ARCH=${SYSTEM_ARCH}" >> "$GITHUB_ENV"
252+
243253
echo "[Debug] Check for updates:"
244254
dnf check-update || exit 1
245255
@@ -249,3 +259,50 @@ jobs:
249259
compression-level: 1
250260
name: ${{ env.PKGS_LIST_FILE }}
251261
path: ${{ env.PKGS_LIST_FILE }}
262+
263+
- name: Get AMI Name
264+
if: always() && env.AMI_ID != ''
265+
run: |
266+
AMI_NAME=$(aws ec2 describe-images --image-ids ${{ env.AMI_ID }} --query 'Images[0].Name' --output text)
267+
if [[ "${AMI_NAME}" == "" || "${AMI_NAME}" == "None" ]]; then
268+
AMI_NAME="${{ env.AMI_ID }}"
269+
fi
270+
echo "[Debug] AMI Name: '${AMI_NAME}'"
271+
echo "AMI_NAME=${AMI_NAME}" >> $GITHUB_ENV
272+
273+
- name: Job summary
274+
if: always() && env.AMI_ID != ''
275+
env:
276+
INSTANCE_TYPE: ${{ contains(matrix.arch, 'aarch64') && 't4g.medium' || 't3.medium' }}
277+
run: |
278+
{
279+
echo "## AMI Image Test"
280+
echo ""
281+
echo "- **AMI Name**: \`${AMI_NAME:-${AMI_ID}}\`"
282+
echo "- **AMI ID**: \`${AMI_ID}\`"
283+
echo "- **Instance Type**: \`${INSTANCE_TYPE}\`"
284+
if [ -n "${ALMA_RELEASE:-}" ]; then
285+
echo "- **AlmaLinux release**: \`${ALMA_RELEASE}\`"
286+
fi
287+
if [ -n "${SYSTEM_ARCH:-}" ]; then
288+
echo "- **System architecture**: \`${SYSTEM_ARCH}\`"
289+
fi
290+
echo "- **Test**: ${{ job.status == 'success' && 'passed ✅' || 'failed ❌' }}"
291+
} >> "$GITHUB_STEP_SUMMARY"
292+
293+
- name: Send notification to Mattermost
294+
uses: mattermost/action-mattermost-notify@master
295+
if: always() && inputs.notify_mattermost && env.AMI_ID != ''
296+
with:
297+
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
298+
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
299+
MATTERMOST_USERNAME: ${{ github.triggering_actor }}
300+
TEXT: |
301+
:almalinux: **${{ env.AMI_NAME }}**, AMI image test, by the GitHub [Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
302+
303+
**AMI Name**: `${{ env.AMI_NAME }}`
304+
**AMI ID**: `${{ env.AMI_ID }}`
305+
**Instance Type**: `${{ contains(matrix.arch, 'aarch64') && 't4g.medium' || 't3.medium' }}`
306+
${{ env.ALMA_RELEASE && format('**AlmaLinux release**: `{0}`', env.ALMA_RELEASE) || '' }}
307+
${{ env.SYSTEM_ARCH && format('**System architecture**: `{0}`', env.SYSTEM_ARCH) || '' }}
308+
**Test**: ${{ job.status == 'success' && 'passed ✅' || 'failed ❌' }}

0 commit comments

Comments
 (0)