-
Notifications
You must be signed in to change notification settings - Fork 6
71 lines (60 loc) · 2.27 KB
/
validate.yaml
File metadata and controls
71 lines (60 loc) · 2.27 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
name: validate
on: [pull_request]
env:
PYTHON_VERSION: 3.10.10
POETRY_VERSION: 1.6.1
jobs:
check_version:
if: github.base_ref == 'master'
runs-on: [self-hosted]
container:
image: python:3.10
steps:
- uses: actions/checkout@v4
- name: Install packaging to compare versions
run: pip install packaging
- name: Fetch source ref
run: git fetch origin $GITHUB_HEAD_REF
- name: Fetch target ref
run: git fetch origin $GITHUB_BASE_REF
- name: Check version
run: |
lib_ver=$(git diff origin/$GITHUB_HEAD_REF origin/$GITHUB_BASE_REF -- .bumpversion.cfg | grep "current_version" | cut -d = -f 2 | xargs)
ver_new=$(echo $lib_ver | cut -f1 -d' ')
ver_old=$(echo $lib_ver | cut -f2 -d' ')
echo "new version: $ver_new (vs) old version: $ver_old"
python -c "import sys; from packaging import version; exit(not version.parse(sys.argv[1]) > version.parse(sys.argv[2]))" $ver_new $ver_old
exit_status=$?
if [ $exit_status -eq 1 ]; then echo "Error comparing versions"; fi;
exit $exit_status
check_changelog:
if: github.base_ref == 'master'
runs-on: [self-hosted]
container:
image: python:3.10
steps:
- uses: actions/checkout@v4
- name: Fetch source ref
run: git fetch origin $GITHUB_HEAD_REF
- name: Fetch target ref
run: git fetch origin $GITHUB_BASE_REF
- name: Check changed lines
run: |
added_lines=$(git diff --numstat origin/$GITHUB_BASE_REF origin/$GITHUB_HEAD_REF -- CHANGELOG.md | awk '{print $1}')
if [ -z $added_lines ] || [ $added_lines -eq 0 ]; then echo "Changelog has NOT been modified" && exit 1; else echo "Changelog has been modified" && exit 0; fi;
build:
name: Validate building package 📦
if: ${{ github.base_ref == 'master' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Install dependencies
run: poetry install
- name: Build package
run: poetry build