Skip to content

test: refactor selfmonitor E2E tests to use fault-backend and fix selfmonitor Prometheus SD #26568

test: refactor selfmonitor E2E tests to use fault-backend and fix selfmonitor Prometheus SD

test: refactor selfmonitor E2E tests to use fault-backend and fix selfmonitor Prometheus SD #26568

name: PR GitHub Checks
permissions:
contents: read
on:
pull_request_target:
branches:
- "main"
- "release-*"
- "feature-new-centralized-arch" # TODO: Remove after merging feature branch
types:
- opened
- reopened
- edited
- synchronize
- labeled
- unlabeled
- milestoned
workflow_dispatch:
env:
PROJECT_NAME: "Huskies"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
TITLE: ${{ github.event.pull_request.title }}
GH_HOST: github.com
jobs:
pr-milestone-project-check:
permissions:
pull-requests: write # Required for setting the milestone
contents: read
runs-on: ubuntu-latest
steps:
- name: Set milestone to latest open milestone
if: github.event.pull_request.milestone == null
run: |
# set milestone to the latest open milestone
latest_milestone=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${GH_REPO}/milestones --hostname ${GH_HOST} | jq -r '.[]|.title' | sort -r | head -n 1)
# fail if there is no open milestone
if [ -z "$latest_milestone" ]; then
echo "No open milestone found"
exit 1
fi
gh pr edit ${{ github.event.number }} --milestone "${latest_milestone}"
pr-label-check:
permissions:
pull-requests: write # Required for setting the labels
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Add kind label based on PR title prefix
if: always()
run: |
# get title prefix
# get kind label
# check if kind label is the same as title prefix
# check if there is a kind label for the title prefix based on the mapping
# if label is missing, add the correct one
# if label is incorrect, remove it and add the correct one
#
prefix=$(echo "$TITLE" | grep -o '^[a-z]*')
kind_label=$( gh pr view "$NUMBER" --json labels -q '.labels[]|.name' | grep '^kind/' || true )
prefix_to_label_file=.github/workflows/titleprefix_to_label.json
correct_kind_label=$(cat $prefix_to_label_file | jq -r ".\"$prefix\"")
if [ -z "$kind_label" ]; then
echo "Adding $correct_kind_label label"
gh pr edit "$NUMBER" --add-label $correct_kind_label
elif [ "$kind_label" != "$correct_kind_label" ]; then
echo "Removing $kind_label label"
gh pr edit "$NUMBER" --remove-label $kind_label
echo "Adding $correct_kind_label label"
gh pr edit "$NUMBER" --add-label $correct_kind_label
fi
- name: Check for area label presence
if: always()
run: |
gh api --jq '.labels.[].name' /repos/${REPO}/pulls/${NUMBER} | \
grep -q '^area\/' || (echo "area label missing"; exit 1)
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
- name: Check for absence of do-not-merge label
if: always()
run: |
labels=$(gh api --jq '.labels.[]' /repos/${REPO}/pulls/${NUMBER} )
echo "Labels found: $( echo $labels | jq -r '.name' )"
! echo "$labels" | jq 'select(.name | startswith("do-not-merge"))' | jq -n "input.name"
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.number }}
pr-title-check:
runs-on: ubuntu-latest
steps:
- name: Validate title
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
types: |
deps
chore
docs
feat
fix
test
# ensures the subject doesn't start with an uppercase character
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
requireScope: false
pr-prevent-kustomization:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.base.ref == 'main' }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Verify kustomization.yaml has no changes
run: |
git diff origin/main --exit-code -- config/manager/kustomization.yaml || (echo "config/manager/kustomization.yaml has changes compared to main branch. Please, revert them" && exit 1)