-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (83 loc) · 2.98 KB
/
pull-request-check.yml
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
name: Pull Request Checks
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
black-format-check: # Check that the codebase is formatted with black
name: Black format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies and check black format
run: |
python -m pip install --upgrade pip
pip install black
black --check --diff .
flake8-check: # Check that the codebase does not contain linting errors
name: Flake8 check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies and check flake8 format
run: |
python -m pip install --upgrade pip
pip install flake8
flake8 .
cspell-check: # Check that the project does not contain spelling errors
name: CSpell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 18
- name: Install dependencies and check prettier format
run: npm install -g cspell && cspell --no-summary --no-progress --no-color .
version-upgrade-check: # Check that the version is greater than the previous commit version
name: Version upgrade check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check branch setup.py version
id: version-check
run: |
VERSION=$(cat setup.py | grep -m1 version | cut -d '"' -f 2)
echo "BRANCH_VERSION=$VERSION" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
ref: main
- name: Check main setup.py version
run: |
BRANCH_VERSION=${{ steps.version-check.outputs.BRANCH_VERSION }}
PREVIOUS_VERSION=$(cat setup.py | grep -m1 version | cut -d '"' -f 2)
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION"
echo "BRANCH_VERSION=$BRANCH_VERSION"
if [ "$BRANCH_VERSION" == "" ]; then
echo "No version found in current branch."
exit 1
fi
if [ "$PREVIOUS_VERSION" == "" ]; then
echo "No version found in main branch."
exit 1
fi
if [[ $PREVIOUS_VERSION == $BRANCH_VERSION ]]; then
echo "Version not upgraded: setup.py version '$PREVIOUS_VERSION' == branch version '$BRANCH_VERSION'."
exit 1
fi
if [[ $PREVIOUS_VERSION > $BRANCH_VERSION ]]; then
echo "Version not upgraded: setup.py version '$PREVIOUS_VERSION' > branch version '$BRANCH_VERSION'."
exit 1
fi
echo "Version upgraded: setup.py version '$PREVIOUS_VERSION' < branch version '$BRANCH_VERSION'."