Skip to content

Add a function to lock OSM chunk's dimension slice #482

Add a function to lock OSM chunk's dimension slice

Add a function to lock OSM chunk's dimension slice #482

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}" ]]