mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Compare commits
18 Commits
tapanito/l
...
bthomee/me
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b251d73f87 | ||
|
|
be55d27fff | ||
|
|
cd2b194b0a | ||
|
|
99397dfb2e | ||
|
|
15e2150cdf | ||
|
|
1e41b68d71 | ||
|
|
a3fa2bd1c5 | ||
|
|
7d9b2dbd10 | ||
|
|
b4dbe8d7e7 | ||
|
|
f71d058c29 | ||
|
|
3ca5a958d7 | ||
|
|
a84c1f69d5 | ||
|
|
38999b2ff8 | ||
|
|
f611938a7b | ||
|
|
78f390714d | ||
|
|
72f91e289b | ||
|
|
24f5c2f08b | ||
|
|
779094f6aa |
39
.github/workflows/on-pr.yml
vendored
39
.github/workflows/on-pr.yml
vendored
@@ -1,13 +1,8 @@
|
|||||||
# This workflow runs all workflows to check, build and test the project on
|
# This workflow runs all workflows to check, build and test the project on
|
||||||
# various Linux flavors, as well as on MacOS and Windows, on every push to a
|
# various Linux flavors, as well as on MacOS and Windows, for various PR events.
|
||||||
# user branch. However, it will not run if the pull request is a draft unless it
|
|
||||||
# has the 'DraftRunCI' label.
|
|
||||||
name: PR
|
name: PR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
merge_group:
|
|
||||||
types:
|
|
||||||
- checks_requested
|
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -25,10 +20,18 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# This job determines whether the rest of the workflow should run. It runs
|
# This job determines whether the rest of the workflow should run. It runs
|
||||||
# when the PR is not a draft (which should also cover merge-group) or
|
# when the PR is not a draft or has the 'DraftRunCI' label and does NOT have
|
||||||
# has the 'DraftRunCI' label.
|
# the 'SkipRunCI' and 'MergeQueueCI' labels. The former two labels will result
|
||||||
|
# in the PR not being allowed to be merged, whereas the latter label will
|
||||||
|
# allow it to be merged without running the full CI suite, because the merge
|
||||||
|
# queue will verify that the code builds and passes tests before the PR is
|
||||||
|
# actually merged.
|
||||||
should-run:
|
should-run:
|
||||||
if: ${{ !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'DraftRunCI') }}
|
if: ${{
|
||||||
|
(!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'DraftRunCI')) &&
|
||||||
|
!contains(github.event.pull_request.labels.*.name, 'SkipRunCI') &&
|
||||||
|
!contains(github.event.pull_request.labels.*.name, 'MergeQueueCI')
|
||||||
|
}}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -75,20 +78,20 @@ jobs:
|
|||||||
conanfile.py
|
conanfile.py
|
||||||
conan.lock
|
conan.lock
|
||||||
- name: Check whether to run
|
- name: Check whether to run
|
||||||
# This step determines whether the rest of the workflow should
|
# This step determines whether the rest of the workflow should run. If
|
||||||
# run. The rest of the workflow will run if this job runs AND at
|
# it runs and all jobs complete successfully, then the 'passed' job is
|
||||||
# least one of:
|
# marked as 'skipped' and, because its direct dependencies ran, the PR
|
||||||
# * Any of the files checked in the `changes` step were modified
|
# is allowed to be merged. This workflow will run when at least one of
|
||||||
# * The PR is NOT a draft and is labeled "Ready to merge"
|
# the following is true:
|
||||||
# * The workflow is running from the merge queue
|
# * Any of the files checked in the `changes` step were modified.
|
||||||
|
# * The PR is NOT a draft and is labeled 'Ready to merge'.
|
||||||
id: go
|
id: go
|
||||||
env:
|
env:
|
||||||
FILES: ${{ steps.changes.outputs.any_changed }}
|
FILES: ${{ steps.changes.outputs.any_changed }}
|
||||||
DRAFT: ${{ github.event.pull_request.draft }}
|
DRAFT: ${{ github.event.pull_request.draft }}
|
||||||
READY: ${{ contains(github.event.pull_request.labels.*.name, 'Ready to merge') }}
|
READY: ${{ contains(github.event.pull_request.labels.*.name, 'Ready to merge') }}
|
||||||
MERGE: ${{ github.event_name == 'merge_group' }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "go=${{ (env.DRAFT != 'true' && env.READY == 'true') || env.FILES == 'true' || env.MERGE == 'true' }}" >> "${GITHUB_OUTPUT}"
|
echo "go=${{ (env.DRAFT != 'true' && env.READY == 'true') || env.FILES == 'true' }}" >> "${GITHUB_OUTPUT}"
|
||||||
cat "${GITHUB_OUTPUT}"
|
cat "${GITHUB_OUTPUT}"
|
||||||
outputs:
|
outputs:
|
||||||
go: ${{ steps.go.outputs.go == 'true' }}
|
go: ${{ steps.go.outputs.go == 'true' }}
|
||||||
@@ -123,7 +126,7 @@ jobs:
|
|||||||
conan_remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }}
|
conan_remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }}
|
||||||
|
|
||||||
passed:
|
passed:
|
||||||
if: failure() || cancelled()
|
if: ${{ failure() || cancelled() }}
|
||||||
needs:
|
needs:
|
||||||
- build-test
|
- build-test
|
||||||
- check-levelization
|
- check-levelization
|
||||||
|
|||||||
35
.github/workflows/on-queue.yml
vendored
Normal file
35
.github/workflows/on-queue.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# This workflow runs all workflows to check, build and test the project on
|
||||||
|
# various Linux flavors, as well as on MacOS and Windows, when a PR is added to
|
||||||
|
# the merge queue.
|
||||||
|
name: Merge Queue
|
||||||
|
|
||||||
|
on:
|
||||||
|
merge_group:
|
||||||
|
types:
|
||||||
|
- checks_requested
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-commit-message:
|
||||||
|
uses: ./.github/workflows/reusable-check-commit-message.yml
|
||||||
|
|
||||||
|
check-levelization:
|
||||||
|
uses: ./.github/workflows/reusable-check-levelization.yml
|
||||||
|
|
||||||
|
build-test:
|
||||||
|
uses: ./.github/workflows/reusable-build-test.yml
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [linux, macos, windows]
|
||||||
|
with:
|
||||||
|
os: ${{ matrix.os }}
|
||||||
|
secrets:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
72
.github/workflows/reusable-check-commit-message.yml
vendored
Normal file
72
.github/workflows/reusable-check-commit-message.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# This workflow checks that the commit message follows our expected format.
|
||||||
|
name: Check commit message
|
||||||
|
|
||||||
|
# This workflow can only be triggered by other workflows.
|
||||||
|
on: workflow_call
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}-single-commit
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Check commit message
|
||||||
|
env:
|
||||||
|
MESSAGE: |
|
||||||
|
|
||||||
|
If you are reading this, then the commit message does not match our
|
||||||
|
expected format. See CONTRIBUTING.md for instructions.
|
||||||
|
|
||||||
|
It is further possible that you did not run the script in
|
||||||
|
`bin/git/squash-commits.sh` before clicking the 'Merge when ready'
|
||||||
|
button in GitHub's UI.
|
||||||
|
run: |
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
COMMIT_MSG='${{ github.event.head_commit.message }}'
|
||||||
|
echo "Commit message: ${COMMIT_MSG}"
|
||||||
|
|
||||||
|
# If the commit title contains a prefix then it must be one we permit.
|
||||||
|
COMMIT_TITLE=$(echo "${COMMIT_MSG}" | head -n1)
|
||||||
|
echo "Commit title: '${COMMIT_TITLE}'"
|
||||||
|
|
||||||
|
if [[ "${COMMIT_TITLE}" =~ ^[^:]+:[^:]+ ]]; then
|
||||||
|
if ! [[ "${COMMIT_TITLE}" =~ ^(build|chore|docs|fix|perf|refactor|test):[^:]+ ]]; then
|
||||||
|
echo "Commit title prefix is not permitted."
|
||||||
|
echo "${MESSAGE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The commit description may not only contain a list of commits, which
|
||||||
|
# is what happens if a PR containing multiple commits is squashed and
|
||||||
|
# merged by GitHub.
|
||||||
|
COMMIT_DESC=$(echo "${COMMIT_MSG}" | tail -n+3)
|
||||||
|
echo "Commit description: '${COMMIT_DESC}'"
|
||||||
|
|
||||||
|
while IFS=$'\n' read -r LINE; do
|
||||||
|
echo "Processing: ${LINE}"
|
||||||
|
# Check for lines starting with '-' or '*' followed by a space.
|
||||||
|
if ! [[ "${LINE}" =~ ^[[:space:]]*[-*][[:space:]]+.* ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# Check if the next line is empty.
|
||||||
|
IFS=$'\n' read -r LINE
|
||||||
|
if [ -n "${LINE}" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done <<< "${COMMIT_DESC}"
|
||||||
|
|
||||||
|
echo "Commit description is not permitted."
|
||||||
|
echo "${MESSAGE}"
|
||||||
|
exit 1
|
||||||
130
bin/git/squash-commits.sh
Normal file
130
bin/git/squash-commits.sh
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ $# -ne 3 || "$1" == "--help" || "$1" = "-h" ]]
|
||||||
|
then
|
||||||
|
name=$( basename $0 )
|
||||||
|
cat <<- USAGE
|
||||||
|
Usage: $name pr "title" "description"
|
||||||
|
|
||||||
|
* All commits in the specified PR will be squashed and a new commit prepared
|
||||||
|
with the provided title and description as commit message.
|
||||||
|
* This script will not push the new commit. You will need to do so yourself
|
||||||
|
by force-pushing, since you will be rewriting history. You must be the
|
||||||
|
author of the PR or a maintainer of the repository in order to perform this
|
||||||
|
operation.
|
||||||
|
* The 'gh' CLI tool must be installed and authenticated.
|
||||||
|
* To write a multiline description, you can use "\$(cat <<EOF
|
||||||
|
line 1
|
||||||
|
line 2
|
||||||
|
EOF
|
||||||
|
)" to pass it as a single argument.
|
||||||
|
* If you get a '[rejected]' error when updating the target branch and then
|
||||||
|
locally merging the changes into the source branch, it is likely because the
|
||||||
|
source branch already exists on your machine (e.g. you ran this script
|
||||||
|
multiple times). In that case, you can delete the local source branch
|
||||||
|
(e.g. 'git branch -D [source]') and try again.
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pr="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
title=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
description=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Checking workspace."
|
||||||
|
diff=$(git status --porcelain)
|
||||||
|
if [ -n "${diff}" ]; then
|
||||||
|
echo "Error: Workspace is not clean. Please commit or stash your changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking out PR ${pr}."
|
||||||
|
gh pr checkout "${pr}"
|
||||||
|
|
||||||
|
echo "Getting the target branch of the PR."
|
||||||
|
target=$(gh pr view --json "baseRefName" --jq '.baseRefName')
|
||||||
|
if [ -z "${target}" ]; then
|
||||||
|
echo "Error: Could not determine target branch of PR ${pr}."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Getting the source branch of the PR."
|
||||||
|
source=$(git branch --show-current)
|
||||||
|
|
||||||
|
echo "Ensuring the PR source branch '${source}' is up to date with the target branch '${target}'."
|
||||||
|
git checkout ${target}
|
||||||
|
git pull --rebase
|
||||||
|
gh pr checkout "${pr}"
|
||||||
|
git merge ${target} --no-edit
|
||||||
|
|
||||||
|
# TODO: check for conflicts and abort if there are any.
|
||||||
|
|
||||||
|
echo "Squashing commits in the PR."
|
||||||
|
git reset --soft $(git merge-base ${target} HEAD)
|
||||||
|
git commit -S -m "${title}" -m "${description}"
|
||||||
|
|
||||||
|
# We assume that external contributors will create a fork in their personal
|
||||||
|
# repository, i.e. the repo owner matches the currently logged in user. In that
|
||||||
|
# case they can push directly to their branch. If the owner is 'XRPLF', we also
|
||||||
|
# push directly to the branch, as we assume that the user running this script
|
||||||
|
# will be a maintainer.
|
||||||
|
echo "Gathering user details."
|
||||||
|
owner=$(gh pr view --json "headRepositoryOwner" --jq '.headRepositoryOwner.login')
|
||||||
|
user=$(gh api user --jq '.login')
|
||||||
|
echo "The PR is owned by '${owner}'. The current user is '${user}'."
|
||||||
|
if [ "${owner}" = 'XRPLF' ] || [ "${owner}" = "${user}" ]; then
|
||||||
|
remote="$(git remote -v | grep ":${owner}/rippled.git (push)" | head -1 | cut -f1)"
|
||||||
|
else
|
||||||
|
remote="${owner}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${remote}" = "origin" ]; then
|
||||||
|
cat << EOF
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
This script will not push. Verify everything is correct, then force
|
||||||
|
push to the source branch using the following commands:
|
||||||
|
|
||||||
|
gh pr edit ${pr} --add-label 'MergeQueueCI'
|
||||||
|
git push --force-with-lease origin ${source}
|
||||||
|
|
||||||
|
The first command adds a label to the PR to skip running CI on the new
|
||||||
|
commit. As we are using a merge queue, CI will be run when the PR is added to
|
||||||
|
the queue, which is required to pass before the changes are merged.
|
||||||
|
|
||||||
|
Remember to navigate back to your previous branch after pushing. You
|
||||||
|
may also want to delete the branch after the commit has been pushed.
|
||||||
|
|
||||||
|
git branch -D ${source}
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat << EOF
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
This script will not push. Verify everything is correct, then force
|
||||||
|
push to the fork using the following commands:
|
||||||
|
|
||||||
|
gh pr edit ${pr} --add-label 'MergeQueueCI'
|
||||||
|
git remote add ${remote} git@github.com:${remote}/rippled.git
|
||||||
|
git fetch ${remote}
|
||||||
|
git push --force-with-lease ${remote} ${source}
|
||||||
|
git remote remove ${remote}
|
||||||
|
|
||||||
|
The first command adds a label to the PR to skip running CI on the new
|
||||||
|
commit. As we are using a merge queue, CI will be run when the PR is added to
|
||||||
|
the queue, which is required to pass before the changes are merged.
|
||||||
|
|
||||||
|
Remember to navigate back to your previous branch after pushing. You
|
||||||
|
may also want to delete the branch after the commit has been pushed.
|
||||||
|
|
||||||
|
git branch -D ${source}
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user