-
Notifications
You must be signed in to change notification settings - Fork 1.1k
175 lines (144 loc) · 5.86 KB
/
Copy pathprerelease-sanity.yaml
File metadata and controls
175 lines (144 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Prerelease Sanity
"on":
push:
branches:
- prerelease_test
- trigger/prerelease-sanity
- "?.*.x"
pull_request:
workflow_dispatch:
jobs:
# We need two disjoint conditions for pull requests that are combined with OR,
# and it is impossible to set up through the "on" key, so check that in a
# separate step below.
config:
name: Check the configuration
runs-on: timescaledb-runner-arm64
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Checkout TimescaleDB
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Check the configuration
id: check
run: |
set -xeu
if [[ "${{ github.event_name }}" == "pull_request" ]]
then
# For pull request event, the default checkout HEAD is the GitHub
# "merge" reference for the pull request (pull/.../merge).
base=$(git rev-parse @^1)
head=$(git rev-parse @^2)
git fetch origin "${base}"
# PR that modifies the workflow.
if ! git diff "${base}" --name-only --exit-code -- .github/workflows/prerelease-sanity.yaml
then
echo "should_run=true" >> "${GITHUB_OUTPUT}"
exit 0
fi
# PR into a release branch that modifies the version.
base_ref="${{ github.event.pull_request.base.ref }}"
if [[ "$base_ref" == ?.*.x ]] \
&& ! git diff "${base}" --name-only --exit-code -- version.config
then
echo "should_run=true" >> "${GITHUB_OUTPUT}"
exit 0
fi
# Don't run on other PRs.
echo "should_run=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
# No additional filtering for other event types.
echo "should_run=true" >> "${GITHUB_OUTPUT}"
check_release_commit:
name: Check Release Commit
needs: config
if: needs.config.outputs.should_run == 'true'
runs-on: timescaledb-runner-arm64
steps:
- name: Checkout TimescaleDB
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# GitHub creates an empty merge commit even for fast-forward merges, which
# makes it needlessly difficult to inspect the actual commit title. Since
# we require the PRs to release branches to be up to date before merging,
# we can just work with the PR head here.
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
# The combined changelog must reference all changes, and the respective
# change files in the .unreleased folder must be deleted.
- name: No .unreleased files are left behind
run: |
! compgen -G '.unreleased/*'
# The messages of the release commit and tag must start with Release <version>.
# If this is the release tag, it must point to the release commit
# and not something else.
- name: The release commit message references the respective version
run: |
required_title=$(sed -n "s/^version = /Release /p" version.config)
echo "Required title: $required_title"
tag_title=$(git log --oneline -1 --pretty=format:%s)
echo "Tag title: $tag_title"
grep "$required_title" <<<"$tag_title"
# Our reference might be a tag, so check the pointed-to commit as well,
# using the ^0 git path specification to find it.
commit_title=$(git log --oneline -1 --pretty=format:%s @^0)
echo "Commit title: $commit_title"
grep "$required_title" <<<"$commit_title"
# The release commit must modify the version.config
- name: The release commit must modify the version.config
run: |
set -xeu
if [[ "${{ github.event_name }}" == "pull_request" ]]
then
git remote set-branches origin '*'
git fetch origin "${{ github.event.pull_request.base.ref }}"
# We're working with pull request head here, see the comment
# at checkout step.
base="$(git merge-base "${{ github.event.pull_request.base.sha }}" @)"
else
base="${{ github.sha }}~"
fi
git log --oneline -1 @^0
git log --oneline -1 "${base}"
! git diff --exit-code "${base}" @^0 -- version.config
# The SQL upgrade scripts must be moved from the development files to
# the respective versioned files.
- name: The latest-dev.sql and the reverse-dev.sql must be empty
run: |
if [ -s sql/updates/latest-dev.sql ]
then
echo "latest-dev.sql is not empty"
exit 1
fi
if [ -s sql/updates/reverse-dev.sql ]
then
echo "reverse-dev.sql is not empty"
exit 1
fi
- name: The release commit must not use the -dev versions
run: |
! grep 'version = .*-dev$' version.config
- name: The tagged release commit must belong to the corresponding release branch
if: github.event_name == 'push'
run: |
set -xeu
version=$(sed -n "s/^version = //p" version.config)
echo "Version ${version}"
branch=$(echo "${version}" | sed 's/\([0-9]\+\.[0-9]\+\.\).*/\1x/')
echo "Expected branch ${branch}"
git remote set-branches origin '*'
git fetch origin "${branch}"
git branch --contains @ | grep -Fx "${branch}"
- name: The release PR must target the corresponding release branch
if: github.event_name == 'pull_request'
run: |
set -xeu
version=$(sed -n "s/^version = //p" version.config)
echo "Version ${version}"
branch=$(echo "${version}" | sed 's/\([0-9]\+\.[0-9]\+\.\).*/\1x/')
echo "Expected branch ${branch}"
echo "PR base: ${{ github.event.pull_request.base.ref }}"
[[ "${{ github.event.pull_request.base.ref }}" == "${branch}" ]]