diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bb7c02dc05d..2d7c9919800a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,19 +14,6 @@ on: - '.gitignore' - '.github/vale-styles/**' - pull_request: - branches: - - master - # Duplicated list because github does not support YAML anchors. - # https://github.com/actions/runner/issues/1182 - paths-ignore: - - README.md - - 'docs/**' - - 'architecture/**' - - 'managed/**' - - '.gitignore' - - '.github/vale-styles/**' - # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" diff --git a/.github/workflows/managed-java-checks.yaml b/.github/workflows/managed-java-checks.yaml deleted file mode 100644 index bd9ffb6b39ac..000000000000 --- a/.github/workflows/managed-java-checks.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Lint java code under managed - -on: - push: - branches: - - master - - '2.6' - paths: - - .github/workflows/managed-java-checks.yaml - - managed/**/*.java - - pull_request: - branches: - - master - - '2.6' - paths: - - .github/workflows/managed-java-checks.yaml - - managed/**/*.java - - -jobs: - lint-checks: - name: Lint checks - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Java - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 17 - - - name: Check formatting - run: sbt javafmtCheckAll - working-directory: managed/ - diff --git a/.github/workflows/pull_check_upgrade.yml b/.github/workflows/pull_check_upgrade.yml new file mode 100644 index 000000000000..48ad183fb0d0 --- /dev/null +++ b/.github/workflows/pull_check_upgrade.yml @@ -0,0 +1,25 @@ +name: "yb-gh" + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + paths: + - 'src/**/*.proto' + +jobs: + pr-upgrade: + runs-on: ubuntu-latest + steps: + - name: Check PR upgrade info + run: | + body="${{ github.event.pull_request.body }}" + UPG_RE='upgrade.*(downgrade|rollback)\ssafety' + # downcase the body for regex matching + if [[ ! "${body,,}" =~ $UPG_RE ]]; then + echo "::error ::PR description must include upgrade/rollback safety information" + echo "::error ::for any changes to .proto files." + echo "::error ::This should include whether the change is safe for rollback" + echo "::error ::and any special procedures needed." + echo "::error ::Example: Upgrade/Downgrade Safety: ..." + exit 1 + fi diff --git a/.github/workflows/pull_checks.yml b/.github/workflows/pull_checks.yml new file mode 100644 index 000000000000..aedd599a0779 --- /dev/null +++ b/.github/workflows/pull_checks.yml @@ -0,0 +1,76 @@ +name: "yb-gh" + +# The title/description checks are only really needed on open/edit events, +# But then it won't be available from head commit if the PR is synchronized. +on: + pull_request: + types: [opened, synchronize, reopened, edited ] + paths-ignore: + - README.md + - 'docs/**' + +jobs: + pr-title: + runs-on: ubuntu-latest + steps: + - name: Check PR title + run: | + TITLE_RE='^(\[(BACKPORT )?([0-9]+(\.[0-9]+)+)\])?' + TITLE_RE+='\[((#[0-9]+(,#[0-9]+)*)|([A-Z]+-[0-9]+(,[A-Z]+-[0-9]+)*))\]' + TITLE_RE+=' [a-zA-Z0-9_-]+(,[[a-zA-Z0-9_]-]+)*:' + TITLE_RE+=' \S.{8,98}\S$' + + if [[ ! "${{ github.event.pull_request.title }}" =~ $TITLE_RE ]]; then + echo "::error ::PR title must include issue ID, code area (no extra whitespace)," + echo "::error :: and a short description." + echo "::error ::Issue referenced must be a github issue or YB-internal Jira ID" + echo "::error ::Short description must be less than 100 characters." + echo "::error ::Backport branch should be used only for non-master release branches." + echo "::error ::Examples:" + echo "::error :: [#12345,#12367] area: Cool feature xyz" + echo "::error :: [BACKPORT 2045.1][#12345] area1,area2: Must have fix" + exit 1 + fi + - name: Check Backport title + run: | + BACKPORT_RE='^\[(BACKPORT )?([0-9]+(\.[0-9]+)+)\]' + if [[ "${{ github.base_ref }}" == "master" ]]; then + if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then + echo "::error ::PR title should not specify target branch if targeting master." + exit 1 + fi + else + if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then + BACKPORT_BRANCH="${BASH_REMATCH[2]}" + if [[ "${BACKPORT_BRANCH}" != "${{ github.base_ref }}" ]]; then + echo "::error ::Backport branch in title (${BACKPORT_BRANCH}) does not match" + echo "::error :: PR base ref (${{ github.base_ref }})." + exit 1 + fi + else + echo "::error ::PR title must begin with target release branch in square brackets." + echo "::error ::Examples:" + echo "::error :: [BACKPORT 2045.1][#12345] area1,area2: Must have fix from master" + echo "::error :: [2045.2][#12345] area: release-specific change" + exit 1 + fi + fi + - name: Check Backport refernces + run: | + BACKPORT_RE='^\[BACKPORT ([0-9]+(\.[0-9]+)+)\]' + # Check for true backport, not just target branch in title. + if [[ "${{ github.event.pull_request.title }}" =~ $BACKPORT_RE ]]; then + COMMIT_RE='^Original commit: ([0-9a-f]+) / ([#D][0-9]+)' + body="${{ github.event.pull_request.body }}" + if ! echo "$body" | grep -qE "$COMMIT_RE"; then + echo "::error ::Backport PR must include original commit SHA and issue reference" + echo "::error ::in the PR description. Examples:" + echo "::error ::Original commit: 123abc / #12345" + echo "::error ::Original commits:" + echo "::error ::- 123abc / #12345" + echo "::error ::- 345def / #43555" + exit 1 + fi + # original_commit_re = Regexp.new('^Original commit(s)?:') + # commit_sha_revision_re = Regexp.new('(^- )?([0-9a-f]+) / ([#D][0-9]+)') + fi diff --git a/.github/workflows/pull_lint.yml b/.github/workflows/pull_lint.yml new file mode 100644 index 000000000000..43deed9a5b50 --- /dev/null +++ b/.github/workflows/pull_lint.yml @@ -0,0 +1,44 @@ +name: "yb-gh" + +on: + pull_request: + types: [opened, synchronize, reopened, edited ] + paths-ignore: + - README.md + - 'docs/**' + +jobs: + pr-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + fetch-tags: 'false' + + # TODO: Create GH custom image with pycodestyle & golint installed + - name: Lint + run: | + docker run \ + --user root \ + -v "$(pwd):$(pwd)" \ + -w "$(pwd)" \ + yugabyteci/yb_build_infra_ubuntu2204_x86_64:latest \ + bash -c 'chown -R yugabyteci .' + docker run \ + --user yugabyteci \ + -v "$(pwd):$(pwd)" \ + -w "$(pwd)" \ + yugabyteci/yb_build_infra_ubuntu2204_x86_64:latest \ + bash -c ' + set -euo pipefail + # Base reference should be set for PR actions. + set -x + if [[ -n "${{ github.base_ref }}" ]]; then + git fetch origin ${{ github.base_ref }} + ./build-support/lint.py --rev origin/${{ github.base_ref }} + else + echo No base reference to compare + exit 1 + fi + ' diff --git a/.github/workflows/yb-ctl-test.yml b/.github/workflows/yb-ctl-test.yml deleted file mode 100644 index ed1ff59fc614..000000000000 --- a/.github/workflows/yb-ctl-test.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: yb-ctl-test - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch -on: - push: - branches: - - master - paths: - - '**/yb-ctl*' - - '!docs/**' - - pull_request: - branches: - - master - paths: - - '**/yb-ctl*' - - '!docs/**' - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - yb-ctl-test: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ macos-latest, ubuntu-18.04 ] - python-version: [ 2.7, 3.8 ] - - steps: - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - uses: actions/checkout@v2 - - - name: Run yb-ctl-test - run: | - set -x - tmpdir=$(mktemp -d) - cp -r scripts/installation "${tmpdir}/" - cd "${tmpdir}/installation" - test/yb-ctl-test.sh diff --git a/build-support/jenkins/yb-jenkins-build.sh b/build-support/jenkins/yb-jenkins-build.sh index d137d4a3f5af..ac2dc908ba40 100755 --- a/build-support/jenkins/yb-jenkins-build.sh +++ b/build-support/jenkins/yb-jenkins-build.sh @@ -39,6 +39,9 @@ EOT echo "Jenkins Build script ${BASH_SOURCE[0]} is running" +echo "Intentional build failure" +exit 1 + while [ $# -gt 0 ]; do case "$1" in -h|--help)