Add utilities for benchmarking different code versions #52
Workflow file for this run
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
name: Compare the package version of the PR with the main branch | |
# The workflow gets triggered by pushes and pull requests | |
on: | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
compare-versions: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
# Checks out the code in the repository | |
- uses: actions/checkout@v3 | |
- name: Compile CLUEstering modules | |
working-directory: ${{github.workspace}} | |
run: | | |
git fetch | |
RED="\033[0;31m" | |
pr_version=$(cat setup.py | grep "__version__ " | awk -F '"' '{print $2}') | |
pr_major=$(echo "$pr_version" | awk -F '.' '{print $1}') | |
pr_minor=$(echo "$pr_version" | awk -F '.' '{print $2}') | |
pr_patch=$(echo "$pr_version" | awk -F '.' '{print $3}') | |
echo "Switching to 'main' branch" | |
git switch main | |
main_version=$(cat setup.py | grep "__version__ " | awk -F '"' '{print $2}') | |
main_major=$(echo "$main_version" | awk -F '.' '{print $1}') | |
main_minor=$(echo "$main_version" | awk -F '.' '{print $2}') | |
main_patch=$(echo "$main_version" | awk -F '.' '{print $3}') | |
if [ "$main_major" -le "$pr_major" ]; then | |
if [ "$main_minor" -le "$pr_minor" ]; then | |
if [ "$main_patch" -lt "$pr_patch" ] || | |
[ "$main_major" -lt "$pr_major" ] || | |
[ "$main_minor" -lt "$pr_minor" ]; then | |
exit 0 # at least one version counters has been updated | |
else | |
echo -e "${RED}ERROR: Patch version is behind main. Update the version in setup.py" | |
echo -e "${RED}main -> $main_version" | |
echo -e "${RED}pr -> $pr_version" | |
exit 1 | |
fi | |
else | |
echo -e "${RED}ERROR: Minor version is behind main. Update the version in setup.py" | |
echo -e "${RED}main -> $main_version" | |
echo -e "${RED}pr -> $pr_version" | |
exit 1 | |
fi | |
else | |
echo -e "${RED}ERROR: Major version is behind main. Update the version in setup.py" | |
echo -e "${RED}main -> $main_version" | |
echo -e "${RED}pr -> $pr_version" | |
exit 1 | |
fi | |