Skip to content

Commit c06d0d1

Browse files
nshylocker
authored andcommitted
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. Part of tarantool#8319 NO_TEST=ci NO_CHANGELOG=ci NO_DOC=ci
1 parent 9d3859b commit c06d0d1

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

.github/workflows/tree.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: tree
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release/**'
8+
9+
concurrency:
10+
# Update of a developer branch cancels the previously scheduled workflow
11+
# run for this branch. However, the 'master' branch, release branch, and
12+
# tag workflow runs are never canceled.
13+
#
14+
# We use a trick here: define the concurrency group as 'workflow run ID' +
15+
# 'workflow run attempt' because it is a unique combination for any run.
16+
# So it effectively discards grouping.
17+
#
18+
# Important: we cannot use `github.sha` as a unique identifier because
19+
# pushing a tag may cancel a run that works on a branch push event.
20+
group: ${{ (
21+
github.ref == 'refs/heads/master' ||
22+
startsWith(github.ref, 'refs/heads/release/') ||
23+
startsWith(github.ref, 'refs/tags/')) &&
24+
format('{0}-{1}', github.run_id, github.run_attempt) ||
25+
format('{0}-{1}', github.workflow, github.ref) }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
entrypoint-tag:
30+
if: github.repository == 'tarantool/tarantool'
31+
32+
runs-on: ubuntu-20.04-self-hosted
33+
34+
container:
35+
image: docker.io/tarantool/testing:ubuntu-jammy
36+
37+
steps:
38+
- name: Prepare checkout
39+
uses: tarantool/actions/prepare-checkout@master
40+
41+
- name: Sources checkout
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Check entrypoint tag
47+
run: ./tools/check-entrypoint-tag.sh
48+
49+
- name: Send VK Teams message on failure
50+
if: failure()
51+
uses: ./.github/actions/report-job-status
52+
with:
53+
bot-token: ${{ secrets.VKTEAMS_BOT_TOKEN }}

tools/check-entrypoint-tag.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
#
3+
# This script checks that current branch has most recent entrypoint tag.
4+
# Entrypoint tag is annotated tag. Release tags are also expected to
5+
# be annotated tags.
6+
#
7+
# There are 2 cases when we require entrypoint tag.
8+
#
9+
# 1. We require that after release tag (like 2.11.3) the next commit
10+
# has entrypoint tag (2.11.4-entrypoint).
11+
#
12+
# 2. After branching. For example we develop 3.0.0 in master. And decide
13+
# to create 3.0 branch. The first commint in 3.0 branch is required
14+
# to have some tag (like 3.0.0-rc1, 3.0.0 or whatever). The first commit after
15+
# fork in master branch is required to have entrypoint tag (3.1.0-entrypoint).
16+
#
17+
# Note that in both cases we do not check that entrypoint tag has proper
18+
# suffix or numbers.
19+
#
20+
# We check for most recent entrypoint tag only. For example if there
21+
# are tags 2.10.0 and 2.10.1 we only check for 2.10.2-entrypoint.
22+
#
23+
# Expected branches names:
24+
#
25+
# - master
26+
# - release/*
27+
28+
set -eo pipefail
29+
30+
error() {
31+
echo "$@" 1>&2
32+
exit 1
33+
}
34+
35+
#########
36+
# Case 1.
37+
#########
38+
39+
# Match digit only release tags like 2.10.0.
40+
pattern='^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'
41+
# Get most recent tag in the HEAD ancestry.
42+
tag=`git describe --abbrev=0`
43+
# If it is a release tag.
44+
if [[ "$tag" =~ $pattern ]]; then
45+
# Find the commit just after the release tag in the HEAD ancestry.
46+
# It is not tagged as entrypoint because it was not seen by the
47+
# describe command above.
48+
entrypoint=`git rev-list HEAD ^$tag | tail -n1`
49+
if [[ $entrypoint ]]; then
50+
error "Missing entrypoint tag for commit $entrypoint after release"\
51+
"tag $tag."
52+
fi
53+
fi
54+
55+
#########
56+
# Case 2.
57+
#########
58+
59+
# Find current branch (report HEAD for 'detached HEAD' state).
60+
branch=`git rev-parse --abbrev-ref HEAD`
61+
if [[ "$branch" =~ ^(master|release/.*)$ ]]; then
62+
# We need to find the commit that starts this branch (i.e. that the first
63+
# commit on this branch after the commit that is common for two branches.)
64+
#
65+
# In order to achieve this we find all the commits of this branch that
66+
# are not on other branches from release/* && master set.
67+
#
68+
# Unfortunately I did not find a way to set arguments for git rev-list
69+
# without this branch.
70+
if [[ "$branch" = master ]]; then
71+
not_remotes="--remotes=origin/release/*"
72+
else
73+
not_remotes="--exclude origin/$branch --remotes=origin/release/* origin/master"
74+
fi
75+
entrypoint=`git rev-list HEAD --not $not_remotes | tail -n1`
76+
if [[ $entrypoint ]]; then
77+
# Check if entrypoint has annotated tag.
78+
git describe --exact-match $entrypoint &>/dev/null || \
79+
error "Missing tag for commit $entrypoint after branching in"\
80+
"branch $branch."
81+
fi
82+
fi
83+
84+
echo OK

0 commit comments

Comments
 (0)