mirror of
https://github.com/containers/podman.git
synced 2026-07-09 06:44:58 -04:00
Migrate validate-source from Cirrus to GitHub Actions
Move the Cirrus validate-source_task to a GitHub Actions workflow (.github/workflows/ci.yml) running as a single job on the CNCF-hosted runner. The job runs the same stages: make validate-source, tests-included, and the conditional renovate config check. golangci-lint for FreeBSD and macOS now runs cross-compiled (GOOS) on the native Linux runner instead of on dedicated Cirrus VMs/workers, so the lint steps are dropped from osx_alt_build and freebsd_alt_build. The PR helper scripts are de-Cirrus'd: they read CI-neutral env vars (PR_HEAD, PR_NUMBER, PR_BODY) and the "No New Tests" label override is now handled natively in the workflow instead of via a GraphQL query. The shared clone/setup/main YAML anchors are relocated into build_task, and the dead _run_validate-source runner.sh function is removed. The tests-of-tests (.t files) are fixed for new setup (mostly removing test cases which are now obsoleted, like [CI:DOCS] and [NO NEW TESTS] markers. NOTE we still don't run tests in CI (although we could), but I ran them locally and fixed all the issues. Finally, test-jira-links-included is removed as it is RHEL-branch specific and have no place in the new repo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
committed by
Paul Holzinger
parent
f6575bd17f
commit
6e597af6dc
85
.cirrus.yml
85
.cirrus.yml
@@ -79,60 +79,6 @@ aws_credentials:
|
||||
region: us-east-1
|
||||
|
||||
|
||||
validate-source_task:
|
||||
name: "Validate source code changes"
|
||||
alias: validate-source
|
||||
# This task is primarily intended to catch human-errors early on, in a
|
||||
# PR context. Skip running it everywhere else.
|
||||
only_if: &is_pr "$CIRRUS_PR != ''"
|
||||
gce_instance:
|
||||
image_project: libpod-218412
|
||||
zone: "us-central1-a"
|
||||
# golangci-lint is a very, very hungry beast.
|
||||
cpu: 8
|
||||
memory: "16Gb"
|
||||
# Required to be 200gig, do not modify - has i/o performance impact
|
||||
# according to gcloud CLI tool warning messages.
|
||||
disk: 200
|
||||
image_name: "${FEDORA_CACHE_IMAGE_NAME}" # from stdenvars
|
||||
env:
|
||||
TEST_FLAVOR: validate-source
|
||||
TEST_BUILD_TAGS: ""
|
||||
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
|
||||
# environment expectations in hack/ci/lib.sh. Specifically
|
||||
# the 'origin' remote must be defined, and all remote branches/tags
|
||||
# must be available for reference from CI scripts.
|
||||
clone_script: &full_clone |
|
||||
set -exo pipefail
|
||||
cd /
|
||||
rm -rf $CIRRUS_WORKING_DIR
|
||||
mkdir -p $CIRRUS_WORKING_DIR
|
||||
if [[ -z "$CIRRUS_PR" ]]; then
|
||||
DEST_BRANCH="$CIRRUS_BRANCH"
|
||||
else
|
||||
DEST_BRANCH="$CIRRUS_BASE_BRANCH"
|
||||
fi
|
||||
git clone --recursive --branch=$DEST_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
|
||||
cd $CIRRUS_WORKING_DIR
|
||||
git remote update origin
|
||||
if [[ -n "$CIRRUS_PR" ]]; then # running for a PR
|
||||
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
|
||||
git checkout pull/$CIRRUS_PR
|
||||
else
|
||||
git reset --hard $CIRRUS_CHANGE_IN_REPO
|
||||
fi
|
||||
# Standard setup stage call, used by nearly every task in CI.
|
||||
setup_script: &setup '$GOSRC/$SCRIPT_BASE/setup_environment.sh'
|
||||
golangci-lint_cache:
|
||||
folder: /root/.cache/golangci-lint
|
||||
fingerprint_script: &golangci_cache_fingerprint
|
||||
- go version
|
||||
- grep GOLANGCI_LINT_VERSION Makefile | head -1
|
||||
- date +%U
|
||||
# Standard main execution stage call, used by nearly every task in CI.
|
||||
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
|
||||
|
||||
|
||||
# N/B: This matrix of build tasks are critical to CI, along with the following
|
||||
# aarch64 task. They build binaries for all CI platforms, and versions. On
|
||||
# success, the contents of the repository are preserved as an artifact for
|
||||
@@ -177,15 +123,39 @@ build_task:
|
||||
VM_IMAGE_NAME: ${DEBIAN_CACHE_IMAGE_NAME}
|
||||
env:
|
||||
TEST_FLAVOR: build
|
||||
clone_script: *full_clone
|
||||
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
|
||||
# environment expectations in contrib/cirrus/lib.sh. Specifically
|
||||
# the 'origin' remote must be defined, and all remote branches/tags
|
||||
# must be available for reference from CI scripts.
|
||||
clone_script: &full_clone |
|
||||
set -exo pipefail
|
||||
cd /
|
||||
rm -rf $CIRRUS_WORKING_DIR
|
||||
mkdir -p $CIRRUS_WORKING_DIR
|
||||
if [[ -z "$CIRRUS_PR" ]]; then
|
||||
DEST_BRANCH="$CIRRUS_BRANCH"
|
||||
else
|
||||
DEST_BRANCH="$CIRRUS_BASE_BRANCH"
|
||||
fi
|
||||
git clone --recursive --branch=$DEST_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
|
||||
cd $CIRRUS_WORKING_DIR
|
||||
git remote update origin
|
||||
if [[ -n "$CIRRUS_PR" ]]; then # running for a PR
|
||||
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
|
||||
git checkout pull/$CIRRUS_PR
|
||||
else
|
||||
git reset --hard $CIRRUS_CHANGE_IN_REPO
|
||||
fi
|
||||
# Attempt to prevent flakes by confirming basic environment expectations,
|
||||
# network service connectivity and essential container image availability.
|
||||
# TODO: Rename to "ci-sanity" and move into task that runs in parallel to build
|
||||
prebuild_script: &prebuild $SCRIPT_BASE/prebuild.sh
|
||||
setup_script: *setup
|
||||
# Standard setup stage call, used by nearly every task in CI.
|
||||
setup_script: &setup '$GOSRC/$SCRIPT_BASE/setup_environment.sh'
|
||||
# Attempt to prevent flakes by confirming automation environment and
|
||||
# all required external/3rd-party services are available and functional.
|
||||
main_script: *main
|
||||
# Standard main execution stage call, used by nearly every task in CI.
|
||||
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
|
||||
# Attempt to catch code-quality and vendoring problems early.
|
||||
postbuild_script: &postbuild $SCRIPT_BASE/postbuild.sh
|
||||
# Cirrus-CI is very slow uploading one file at time, and the repo contains
|
||||
@@ -356,7 +326,6 @@ build_success_task:
|
||||
name: "Total Build Success"
|
||||
alias: build_success
|
||||
depends_on:
|
||||
- validate-source
|
||||
- build
|
||||
- build_aarch64
|
||||
- alt_build
|
||||
|
||||
94
.github/workflows/ci.yml
vendored
Normal file
94
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
validate-source:
|
||||
name: Validate source code changes
|
||||
runs-on: cncf-ubuntu-8-32-x86
|
||||
env:
|
||||
# Base commit of this PR; used by the Makefile and the helper scripts to
|
||||
# compute the commit range (git merge-base $DEST_BRANCH HEAD..HEAD).
|
||||
DEST_BRANCH: ${{ github.event.pull_request.base.sha }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
PR_HEAD: ${{ github.event.pull_request.head.sha }}
|
||||
PR_BODY: ${{ github.event.pull_request.body }}
|
||||
steps:
|
||||
- name: Checkout PR head
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
# Check out the actual PR head (not the synthetic merge commit) so
|
||||
# the commit-range checks validate the contributor's commits.
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/head
|
||||
# Full history (all branches) is required for git merge-base to find
|
||||
# the fork point against the base branch.
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
gawk \
|
||||
libassuan-dev \
|
||||
libbtrfs-dev \
|
||||
libgpgme-dev \
|
||||
libseccomp-dev \
|
||||
libsystemd-dev \
|
||||
libclone-perl \
|
||||
man-db \
|
||||
podman \
|
||||
python3-pip
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
|
||||
- name: Read golangci-lint version from Makefile
|
||||
id: gv
|
||||
run: |
|
||||
v=$(awk -F':=' '/^GOLANGCI_LINT_VERSION/ {gsub(/ /,"",$2); print $2; exit}' Makefile)
|
||||
echo "version=v${v}" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1
|
||||
with:
|
||||
version: ${{ steps.gv.outputs.version }}
|
||||
install-only: true
|
||||
|
||||
- name: Install pre-commit
|
||||
run: pipx install pre-commit
|
||||
|
||||
- name: Validate source
|
||||
run: make validate-source
|
||||
|
||||
- name: Check that the PR includes tests
|
||||
# The 'No New Tests' label lets maintainers override this check.
|
||||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'No New Tests') }}
|
||||
run: make tests-included
|
||||
|
||||
- name: Validate renovate config
|
||||
run: |
|
||||
diffs=$(git diff --name-only "$DEST_BRANCH" "${PR_HEAD:-HEAD}")
|
||||
# The renovate validator image is large, only pull it when needed.
|
||||
if ! grep -E -q '^\.github/renovate\.json5' <<<"$diffs"; then
|
||||
echo "renovate config unchanged, skipping."
|
||||
exit 0
|
||||
fi
|
||||
echo "Checking renovate config."
|
||||
podman run --rm \
|
||||
-v ./.github/renovate.json5:/usr/src/app/renovate.json5:z \
|
||||
ghcr.io/renovatebot/renovate:latest \
|
||||
renovate-config-validator
|
||||
4
Makefile
4
Makefile
@@ -765,10 +765,6 @@ test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho test/version/ve
|
||||
tests-included:
|
||||
hack/ci/pr-should-include-tests
|
||||
|
||||
.PHONY: test-jira-links-included
|
||||
test-jira-links-included:
|
||||
hack/ci/pr-should-link-jira
|
||||
|
||||
.PHONY: tests-expect-exit
|
||||
tests-expect-exit:
|
||||
@if grep -E --line-number 'Expect.*ExitCode' test/e2e/*.go | grep -E -v ', ".*"\)'; then \
|
||||
|
||||
@@ -30,7 +30,7 @@ containing 'Skip' instructions or FIXME comments referencing
|
||||
those IDs. If we find any, we abort with a loud and hopefully
|
||||
useful message.
|
||||
|
||||
$ME is intended to run from Cirrus CI.
|
||||
$ME is intended to run from CI.
|
||||
|
||||
OPTIONS:
|
||||
|
||||
@@ -71,7 +71,7 @@ sub main {
|
||||
die "$ME: This script takes no arguments; try $ME --help\n" if @ARGV;
|
||||
|
||||
# Check commit messages from both github and git; they often differ
|
||||
my @issues = fixed_issues(cirrus_change_message(), git_commit_messages())
|
||||
my @issues = fixed_issues(pr_change_message(), git_commit_messages())
|
||||
or exit 0;
|
||||
|
||||
my @found = unremoved_skips(@issues)
|
||||
@@ -161,16 +161,16 @@ sub fixed_issues {
|
||||
return @issues;
|
||||
}
|
||||
|
||||
###########################
|
||||
# cirrus_change_message # this is the one from *GitHub*, not *git*
|
||||
###########################
|
||||
sub cirrus_change_message {
|
||||
my $change_message = $ENV{CIRRUS_CHANGE_MESSAGE}
|
||||
#######################
|
||||
# pr_change_message # the PR description (from *GitHub*, not *git*)
|
||||
#######################
|
||||
sub pr_change_message {
|
||||
my $change_message = $ENV{PR_BODY}
|
||||
or do {
|
||||
# OK for it to be unset if we're not running CI on a PR
|
||||
return if ! $ENV{CIRRUS_PR};
|
||||
return if ! $ENV{PR_NUMBER};
|
||||
# But if we _are_ running on a PR, something went badly wrong.
|
||||
die "$ME: \$CIRRUS_CHANGE_MESSAGE is undefined\n";
|
||||
die "$ME: \$PR_BODY is undefined\n";
|
||||
};
|
||||
|
||||
return $change_message;
|
||||
@@ -180,10 +180,10 @@ sub cirrus_change_message {
|
||||
# git_commit_messages # the ones from the *git history*
|
||||
#########################
|
||||
sub git_commit_messages {
|
||||
# Probably the same as HEAD, but use Cirrus-defined value if available
|
||||
my $head = $ENV{CIRRUS_CHANGE_IN_REPO} || 'HEAD';
|
||||
# Probably the same as HEAD, but use the CI-defined value if available
|
||||
my $head = $ENV{PR_HEAD} || 'HEAD';
|
||||
|
||||
# Base of this PR. Here we absolutely rely on cirrus.
|
||||
# Base of this PR.
|
||||
return if ! $ENV{DEST_BRANCH};
|
||||
chomp(my $base = qx{git merge-base $ENV{DEST_BRANCH} $head});
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ ME=$(basename $0)
|
||||
# Github label which allows overriding this check
|
||||
OVERRIDE_LABEL="No New Tests"
|
||||
|
||||
# HEAD should be good enough, but the CIRRUS envariable allows us to test
|
||||
head=${CIRRUS_CHANGE_IN_REPO:-HEAD}
|
||||
# Base of this PR. Here we absolutely rely on cirrus.
|
||||
# PR head commit; defaults to HEAD when not running in CI.
|
||||
head=${PR_HEAD:-HEAD}
|
||||
# Base of this PR.
|
||||
base=$(git merge-base ${DEST_BRANCH:-main} $head)
|
||||
|
||||
# This gives us a list of files touched in all commits, e.g.
|
||||
@@ -46,39 +46,9 @@ if [[ -z "$filtered_changes" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Nope. Only allow if the github 'no-tests-needed' label is set
|
||||
if [[ -z "$CIRRUS_PR" ]]; then
|
||||
echo "$ME: cannot query github: \$CIRRUS_PR is undefined" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$CIRRUS_REPO_CLONE_TOKEN" ]]; then
|
||||
echo "$ME: cannot query github: \$CIRRUS_REPO_CLONE_TOKEN is undefined" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
query="{
|
||||
\"query\": \"query {
|
||||
repository(owner: \\\"containers\\\", name: \\\"podman\\\") {
|
||||
pullRequest(number: $CIRRUS_PR) {
|
||||
labels(first: 100) {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}\"
|
||||
}"
|
||||
|
||||
result=$(curl --fail -s -H "Authorization: bearer $CIRRUS_REPO_CLONE_TOKEN" -H "Accept: application/vnd.github.antiope-preview+json" -H "Content-Type: application/json" -X POST --data @- https://api.github.com/graphql <<<"$query")
|
||||
|
||||
labels=$(jq -r '.data.repository.pullRequest.labels.nodes[].name' <<<"$result")
|
||||
|
||||
if grep -F -x -q "$OVERRIDE_LABEL" <<<"$labels"; then
|
||||
# PR has the label set
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# This PR touches non-test files but adds no tests. Fail loudly.
|
||||
# The '$OVERRIDE_LABEL' label can be used to override this check; that is
|
||||
# handled by the CI workflow, not here.
|
||||
cat <<EOF
|
||||
$ME: PR does not include changes in the 'tests' directory
|
||||
|
||||
|
||||
@@ -7,13 +7,6 @@
|
||||
#
|
||||
ME=$(basename $0)
|
||||
|
||||
# As of 2024-02 our test script queries github, for which we need token
|
||||
if [[ -z "$GITHUB_TOKEN" ]]; then
|
||||
echo "$ME: Please set \$GITHUB_TOKEN" >&2
|
||||
exit 1
|
||||
fi
|
||||
export CIRRUS_REPO_CLONE_TOKEN="$GITHUB_TOKEN"
|
||||
|
||||
###############################################################################
|
||||
# BEGIN test cases
|
||||
#
|
||||
@@ -36,16 +29,14 @@ tests="
|
||||
0 68c9e02df db71759b1 8821 multiple commits, includes tests
|
||||
0 bb82c37b7 eeb4c129b 8832 single commit, w/tests, merge-base test
|
||||
1 1f5927699 864592c74 8685 multiple commits, no tests
|
||||
0 7592f8fbb 6bbe54f2b 8766 no tests, but CI:DOCS in commit message
|
||||
0 355e38769 bfbd915d6 8884 a vendor bump
|
||||
0 ffe2b1e95 e467400eb 8899 only .cirrus.yml
|
||||
0 06a6fd9f2 3cc080151 8695 docs-only, without CI:DOCS
|
||||
0 06a6fd9f2 3cc080151 8695 docs-only
|
||||
0 a47515008 ecedda63a 8816 unit tests only
|
||||
0 caa84cd35 e55320efd 8565 hack/podman-socat only
|
||||
0 c342583da 12f835d12 8523 version.go + podman.spec.in
|
||||
0 8f75ed958 7b3ad6d89 8835 only a README.md change
|
||||
0 b6db60e58 f06dd45e0 9420 a test rename
|
||||
0 c6a896b0c 4ea5d6971 11833 includes magic string
|
||||
"
|
||||
|
||||
# The script we're testing
|
||||
@@ -89,24 +80,6 @@ function run_test_script() {
|
||||
echo "ok $testnum $testname - rc=$expected_rc"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we expect an error, confirm that we can override it. We only need
|
||||
# to do this once.
|
||||
if [[ $expected_rc == 1 ]]; then
|
||||
if [[ -z "$tested_override" ]]; then
|
||||
testnum=$(( testnum + 1 ))
|
||||
|
||||
CIRRUS_CHANGE_TITLE="[CI:DOCS] hi there" $test_script &>/dev/null
|
||||
if [[ $? -ne 1 ]]; then
|
||||
echo "not ok $testnum $rest (override with CI:DOCS)"
|
||||
rc=1
|
||||
else
|
||||
echo "ok $testnum $rest (override with CI:DOCS)"
|
||||
fi
|
||||
|
||||
tested_override=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# END test-script runner and status checker
|
||||
@@ -115,17 +88,13 @@ function run_test_script() {
|
||||
|
||||
rc=0
|
||||
testnum=0
|
||||
tested_override=
|
||||
|
||||
while read expected_rc parent_sha commit_sha pr rest; do
|
||||
# Skip blank lines
|
||||
test -z "$expected_rc" && continue
|
||||
|
||||
export DEST_BRANCH=$parent_sha
|
||||
export CIRRUS_CHANGE_IN_REPO=$commit_sha
|
||||
export CIRRUS_CHANGE_TITLE=$(git log -1 --format=%s $commit_sha)
|
||||
export CIRRUS_CHANGE_MESSAGE=
|
||||
export CIRRUS_PR=$pr
|
||||
export PR_HEAD=$commit_sha
|
||||
|
||||
run_test_script $expected_rc "PR $pr - $rest"
|
||||
done <<<"$tests"
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Intended for use in CI, for -rhel branches: check git PR, barf if no jira links
|
||||
#
|
||||
|
||||
ME=$(basename $0)
|
||||
|
||||
set -e
|
||||
|
||||
# Github label which allows overriding this check
|
||||
OVERRIDE_LABEL="No Jira Link"
|
||||
|
||||
# Only -rhel branches need jira links
|
||||
BRANCH_REGEX="v.*-rhel"
|
||||
|
||||
LINK_REGEX="Fixes:?[[:space:]]+https://issues.redhat.com/[[:alnum:]/-]*"
|
||||
|
||||
if [[ ! "${DEST_BRANCH}" =~ $BRANCH_REGEX ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "${CIRRUS_CHANGE_MESSAGE}" =~ $LINK_REGEX ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Nope. Only allow if the github 'No Jira Link' label is set
|
||||
if [[ -z "$CIRRUS_PR" ]]; then
|
||||
if [[ ! "$CIRRUS_BRANCH" =~ pull ]] || [[ -n "$CIRRUS_TAG" ]]; then
|
||||
echo "Warning: $ME only intended for use on PRs in CI"
|
||||
exit 0
|
||||
fi
|
||||
echo "$ME: cannot query github: \$CIRRUS_PR is undefined" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$CIRRUS_REPO_CLONE_TOKEN" ]]; then
|
||||
echo "$ME: cannot query github: \$CIRRUS_REPO_CLONE_TOKEN is undefined" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
query="{
|
||||
\"query\": \"query {
|
||||
repository(owner: \\\"containers\\\", name: \\\"podman\\\") {
|
||||
pullRequest(number: $CIRRUS_PR) {
|
||||
labels(first: 100) {
|
||||
nodes {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}\"
|
||||
}"
|
||||
|
||||
result=$(curl --fail -s -H "Authorization: bearer $CIRRUS_REPO_CLONE_TOKEN" -H "Accept: application/vnd.github.antiope-preview+json" -H "Content-Type: application/json" -X POST --data @- https://api.github.com/graphql <<<"$query")
|
||||
|
||||
labels=$(jq -r '.data.repository.pullRequest.labels.nodes[]?.name' <<<"$result")
|
||||
|
||||
if grep -F -x -q "$OVERRIDE_LABEL" <<<"$labels"; then
|
||||
# PR has the label set
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
$ME: PR does not include required references to Jira issues
|
||||
|
||||
Please add a reference to the related Jira ticket(s) by adding to the
|
||||
description of the PR something like:
|
||||
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-50507
|
||||
|
||||
You can use multiple lines like this, but only one issue per line.
|
||||
|
||||
If your commit really, truly does not need a jira link, you can proceed
|
||||
by asking a repo maintainer to set the '$OVERRIDE_LABEL' github label.
|
||||
This will only be done when there's no reasonable alternative.
|
||||
EOF
|
||||
|
||||
exit 1
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# tests for pr-should-link-jira.t
|
||||
#
|
||||
|
||||
ME=$(basename $0)
|
||||
|
||||
# Our test script queries github, for which we need token
|
||||
if [[ -z "$CIRRUS_REPO_CLONE_TOKEN" ]]; then
|
||||
if [[ -n "$GITHUB_TOKEN" ]]; then
|
||||
export CIRRUS_REPO_CLONE_TOKEN="$GITHUB_TOKEN"
|
||||
else
|
||||
echo "$ME: Please set \$CIRRUS_REPO_CLONE_TOKEN" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# BEGIN test cases
|
||||
#
|
||||
|
||||
read -d '\n' msg_no_jira << EndOfText
|
||||
This is some text
|
||||
without a jira
|
||||
EndOfText
|
||||
|
||||
read -d '\n' msg_invalid << EndOfText
|
||||
This is some text
|
||||
without a jira
|
||||
Fixes #42
|
||||
More text...
|
||||
EndOfText
|
||||
|
||||
read -d '\n' msg_jira << EndOfText
|
||||
This is some text
|
||||
with a jira
|
||||
Fixes https://issues.redhat.com/browse/RHEL-50507
|
||||
More text...
|
||||
EndOfText
|
||||
|
||||
read -d '\n' msg_jira2 << EndOfText
|
||||
This is some text
|
||||
with a jira
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-50507
|
||||
More text...
|
||||
EndOfText
|
||||
|
||||
read -d '\n' msg_multiple << EndOfText
|
||||
This is some text
|
||||
with multiple jira lines
|
||||
Fixes https://issues.redhat.com/browse/RHEL-50507
|
||||
More text...
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-50506
|
||||
More text...
|
||||
EndOfText
|
||||
|
||||
# Feel free to add as needed. Syntax is:
|
||||
# <exit status> <pr> <commit message> <dest branch> # comments
|
||||
#
|
||||
# Where:
|
||||
# exit status is the expected exit status of the script
|
||||
# pr pr number (only used to get tag, 0000 if doesn't matter)
|
||||
# commit message commit message
|
||||
# dest branch name of branch
|
||||
#
|
||||
|
||||
tests="
|
||||
0 0000 msg_no_jira main not rhel branch, no link, should pass
|
||||
0 0000 msg_jira main not rhel branch, link, should pass
|
||||
0 0000 msg_invalid main not rhel branch, invalid link, should pass
|
||||
0 0000 msg_no_jira v4.9 not rhel branch, no link, should pass
|
||||
1 23514 msg_no_jira v4.9-rhel no link, no tag, should fail
|
||||
0 8890 msg_no_jira v4.9-rhel no link, tag, should work
|
||||
1 23514 msg_invalid v4.9-rhel invalid link, no tag, should fail
|
||||
0 0000 msg_jira v4.9-rhel link, should work
|
||||
0 0000 msg_jira2 v4.9-rhel link with colon, should work
|
||||
0 0000 msg_multiple v4.9-rhel multiple links, should work
|
||||
"
|
||||
|
||||
# The script we're testing
|
||||
test_script=$(dirname $0)/$(basename $0 .t)
|
||||
|
||||
# END test cases
|
||||
###############################################################################
|
||||
# BEGIN test-script runner and status checker
|
||||
|
||||
function run_test_script() {
|
||||
local expected_rc=$1
|
||||
local testname=$2
|
||||
|
||||
testnum=$(( testnum + 1 ))
|
||||
|
||||
# DO NOT COMBINE 'local output=...' INTO ONE LINE. If you do, you lose $?
|
||||
local output
|
||||
output=$( $test_script )
|
||||
local actual_rc=$?
|
||||
|
||||
if [[ $actual_rc != $expected_rc ]]; then
|
||||
echo "not ok $testnum $testname"
|
||||
echo "# expected rc $expected_rc"
|
||||
echo "# actual rc $actual_rc"
|
||||
if [[ -n "$output" ]]; then
|
||||
echo "# script output: $output"
|
||||
fi
|
||||
rc=1
|
||||
else
|
||||
if [[ $expected_rc == 1 ]]; then
|
||||
# Confirm we get an error message
|
||||
if [[ ! "$output" =~ "Please add a reference" ]]; then
|
||||
echo "not ok $testnum $testname"
|
||||
echo "# Expected: ~ 'Please add a reference'"
|
||||
echo "# Actual: $output"
|
||||
rc=1
|
||||
else
|
||||
echo "ok $testnum $testname - rc=$expected_rc"
|
||||
fi
|
||||
else
|
||||
echo "ok $testnum $testname - rc=$expected_rc"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# END test-script runner and status checker
|
||||
###############################################################################
|
||||
# BEGIN test-case parsing
|
||||
|
||||
rc=0
|
||||
testnum=0
|
||||
tested_override=
|
||||
|
||||
while read expected_rc pr msg branch rest; do
|
||||
# Skip blank lines
|
||||
test -z "$expected_rc" && continue
|
||||
|
||||
export DEST_BRANCH=$branch
|
||||
export CIRRUS_CHANGE_MESSAGE="${!msg}"
|
||||
export CIRRUS_PR=$pr
|
||||
|
||||
run_test_script $expected_rc "PR $pr $msg $branch - $rest"
|
||||
done <<<"$tests"
|
||||
|
||||
echo "1..$testnum"
|
||||
exit $rc
|
||||
|
||||
# END Test-case parsing
|
||||
###############################################################################
|
||||
@@ -55,8 +55,6 @@ if [[ "${DISTRO_NV}" == "$FEDORA_NAME" ]]; then
|
||||
# Tests for lib.sh
|
||||
showrun ${SCRIPT_BASE}/lib.sh.t
|
||||
|
||||
# Tests for pr-should-link-jira
|
||||
showrun ${SCRIPT_BASE}/pr-should-link-jira.t
|
||||
|
||||
# Run this during daily cron job to prevent a GraphQL API change/breakage
|
||||
# from impacting every PR. Down-side being if it does fail, a maintainer
|
||||
|
||||
@@ -21,36 +21,6 @@ source $(dirname $0)/lib.sh
|
||||
|
||||
showrun echo "starting"
|
||||
|
||||
function _run_validate-source() {
|
||||
# This target is only meant to be run on PRs.
|
||||
# We need the following env vars set for the git diff check below.
|
||||
req_env_vars CIRRUS_CHANGE_IN_REPO PR_BASE_SHA
|
||||
|
||||
showrun make validate-source
|
||||
|
||||
# make sure PRs have tests
|
||||
showrun make tests-included
|
||||
|
||||
# make sure PRs have jira links (if needed for branch)
|
||||
showrun make test-jira-links-included
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
head=$CIRRUS_CHANGE_IN_REPO
|
||||
# shellcheck disable=SC2154
|
||||
base=$PR_BASE_SHA
|
||||
echo "_run_validate-source: head=$head base=$base"
|
||||
diffs=$(git diff --name-only $base $head)
|
||||
|
||||
# If PR touches renovate config validate it, as the image is very big only do so when needed
|
||||
if grep -E -q "^.github/renovate.json5" <<<"$diffs"; then
|
||||
msg "Checking renovate config."
|
||||
showrun podman run \
|
||||
-v ./.github/renovate.json5:/usr/src/app/renovate.json5:z \
|
||||
ghcr.io/renovatebot/renovate:latest \
|
||||
renovate-config-validator
|
||||
fi
|
||||
}
|
||||
|
||||
function _run_unit() {
|
||||
# shellcheck disable=SC2154
|
||||
if [[ "$PODBIN_NAME" != "podman" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user