forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add a workflow to check for entrypoint tags
Check check-entrypoint.sh comment for explanation of what entrypoint tag is. The workflow fails if current branch does not have a most recent entrypoint tag that it should have. NO_TEST=ci NO_CHANGELOG=ci NO_DOC=ci
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: tree | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'release/**' | ||
|
||
concurrency: | ||
# Update of a developer branch cancels the previously scheduled workflow | ||
# run for this branch. However, the 'master' branch, release branch, and | ||
# tag workflow runs are never canceled. | ||
# | ||
# We use a trick here: define the concurrency group as 'workflow run ID' + | ||
# 'workflow run attempt' because it is a unique combination for any run. | ||
# So it effectively discards grouping. | ||
# | ||
# Important: we cannot use `github.sha` as a unique identifier because | ||
# pushing a tag may cancel a run that works on a branch push event. | ||
group: ${{ ( | ||
github.ref == 'refs/heads/master' || | ||
startsWith(github.ref, 'refs/heads/release/') || | ||
startsWith(github.ref, 'refs/tags/')) && | ||
format('{0}-{1}', github.run_id, github.run_attempt) || | ||
format('{0}-{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
entrypoint-tag: | ||
if: github.repository == 'tarantool/tarantool' | ||
runs-on: ubuntu-20.04-self-hosted | ||
|
||
steps: | ||
- name: Prepare checkout | ||
uses: tarantool/actions/prepare-checkout@master | ||
- name: Sources checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- run: ./tools/check-entrypoint.sh | ||
- name: Send VK Teams message on failure | ||
if: failure() | ||
uses: ./.github/actions/report-job-status | ||
with: | ||
bot-token: ${{ secrets.VKTEAMS_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
# vim: set ts=4 sts=4 sw=4 et: | ||
# | ||
# This script checks that current branch has most recent entrypoint tag. | ||
# There are 2 cases when we require entrypoint tag. | ||
# | ||
# 1. After release tag (like 2.10.5, 2.11.0 etc). We require that the next | ||
# commit has annotated tag | ||
# | ||
# 2. After branching. For example we develop 3.0.0 in master. And decide | ||
# to release 3.0.0. We fork release/3.0 branch. The first commit after | ||
# fork in release/3.0 branch is required to has annotated tag (like 3.0.0-rc1 | ||
# or something). The first commit after fork in master branch is required | ||
# to has annotated entrypoint tag too. | ||
# | ||
# Note that in both cases we do not check that required annotated tag has | ||
# "entrypoint" or "rc" in the name. | ||
# | ||
# We check for most recent entrypoint tag only. Most recent in a sense that | ||
# for example if there are tags for releases 2.10.0 and 2.10.1 on current | ||
# branch the script only check for entrypoint tag after 2.10.1 tag. | ||
|
||
set -eo pipefail | ||
|
||
error() { | ||
echo "$@" 1>&2 | ||
exit 1 | ||
} | ||
|
||
if ! git --version >/dev/null 2>&1; then | ||
error "git must be installed." | ||
fi | ||
|
||
######### | ||
# Case 1. | ||
######### | ||
|
||
# Match digit only release tags like 2.10.0. | ||
pattern='^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$' | ||
# Show most recent tag in the HEAD ancestry | ||
tag=`git describe --abbrev=0` | ||
# If it is a release tag. | ||
if [[ "$tag" =~ $pattern ]]; then | ||
# Find the commit just after the release tag in the HEAD ancestry. | ||
# It is not tagged as entrypoint because it was not seen by the | ||
# describe command above. | ||
entrypoint=`git rev-list HEAD ^$tag | tail -n1` | ||
if [[ $entrypoint ]]; then | ||
error "Missing entrypoint tag for commit $entrypoint after release"\ | ||
"tag $tag." | ||
fi | ||
fi | ||
|
||
######### | ||
# Case 2. | ||
######### | ||
|
||
# Find current branch (report HEAD for 'detached HEAD' state). | ||
branch=`git rev-parse --abbrev-ref HEAD` | ||
if [[ "$branch" =~ ^(master|release/.*)$ ]]; then | ||
# We need to find the commit that starts this branch (i.e. that the first | ||
# commit on this branch after the commit that is common for two branches.) | ||
# | ||
# In order to archive this we find all the commits of this branch that | ||
# are not on other branches from release/* && master set. | ||
# | ||
# Unfortunately I did not find a way to set arguments for git rev-list | ||
# without this branch. | ||
if [[ "$branch" = master ]]; then | ||
not_remotes="--remotes=origin/release/*" | ||
else | ||
not_remotes="--exclude origin/$branch --remotes=origin/release/* origin/master" | ||
fi | ||
entrypoint=`git rev-list HEAD --not $not_remotes | tail -n1` | ||
if [[ $entrypoint ]]; then | ||
# Show most recent tag in the HEAD ancestry | ||
tag=`git describe --abbrev=0` | ||
tag_commit=`git rev-list -n 1 $tag` | ||
if [[ $tag_commit != $entrypoint ]]; then | ||
error "Missing tag for commit $entrypoint after branching."\ | ||
"It should be an entrypoint tag or a tag for a downstream"\ | ||
"branch." | ||
fi | ||
fi | ||
fi | ||
|
||
echo OK |