1
- name : Build
1
+ name : CI
2
2
3
3
on :
4
4
push :
5
- branches : [ master ]
5
+ branches : [main ]
6
6
paths-ignore :
7
7
- ' **.md'
8
8
pull_request :
9
- branches : [ master ]
9
+ branches : [main ]
10
10
paths-ignore :
11
11
- ' **.md'
12
12
@@ -15,117 +15,24 @@ jobs:
15
15
runs-on : ubuntu-latest
16
16
strategy :
17
17
matrix :
18
- os : [ubuntu-latest, macos-latest, windows-latest]
19
- python-version : [3.6, 3.7, 3.8]
18
+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
20
19
steps :
21
20
- name : Checkout
22
- uses : actions/checkout@v2
21
+ uses : actions/checkout@v4
22
+
23
23
- name : Set up Python ${{ matrix.python-version }}
24
- uses : actions/setup-python@v2
24
+ uses : actions/setup-python@v5
25
25
with :
26
26
python-version : ${{ matrix.python-version }}
27
- - name : Install dependencies
28
- run : |
29
- python -m pip install --upgrade pip
30
- pip install black flake8 pytest
31
- pip install -r requirements.txt
32
- - name : Format with black
33
- run : |
34
- black . --check
35
- - name : Lint with flake8
36
- run : |
37
- flake8 . --ignore=E203 --count --show-source --statistics --max-line-length=90
38
- - name : Test with pytest
39
- run : |
40
- pytest
41
- release :
42
- runs-on : ubuntu-latest
43
- steps :
44
- - name : Checkout
45
- uses : actions/checkout@v2
46
- with :
47
- fetch-depth : 0
48
- - name : Check version bump and set versions as envvar
49
- if : github.ref != 'refs/heads/master'
50
- run : |
51
- FILES_CHANGED=$(echo -n $(git diff origin/${{ github.base_ref }} --name-only))
52
- if [[ $FILES_CHANGED != *.py ]]; then
53
- echo "No Python scripts are modified"
54
- echo "::set-env name=FILES_CHANGED::false"
55
- exit 0
56
- fi
57
-
58
- SEMVER_PATTERN="([0-9]+)\.([0-9]+)\.([0-9]+)"
59
- VERSION=$(echo -n $(git diff origin/${{ github.base_ref }} -G '__version__' app_store_scraper/__version__.py))
60
-
61
- if [ "$VERSION" = "" ]; then
62
- echo "Version must be bumped for every PR"
63
- exit 1
64
- fi
65
-
66
- VERSION_OLD=$(echo "$VERSION" | sed -E "s/.*\-__version__ = \"($SEMVER_PATTERN).+/\1/")
67
- VERSION_OLD_MAJOR=$(echo "$VERSION_OLD" | sed -E "s/$SEMVER_PATTERN/\1/")
68
- VERSION_OLD_MINOR=$(echo "$VERSION_OLD" | sed -E "s/$SEMVER_PATTERN/\2/")
69
- VERSION_OLD_PATCH=$(echo "$VERSION_OLD" | sed -E "s/$SEMVER_PATTERN/\3/")
70
-
71
- VERSION_NEW=$(echo "$VERSION" | sed -E "s/.*\+__version__ = \"($SEMVER_PATTERN).+/\1/")
72
- VERSION_NEW_MAJOR=$(echo "$VERSION_NEW" | sed -E "s/$SEMVER_PATTERN/\1/")
73
- VERSION_NEW_MINOR=$(echo "$VERSION_NEW" | sed -E "s/$SEMVER_PATTERN/\2/")
74
- VERSION_NEW_PATCH=$(echo "$VERSION_NEW" | sed -E "s/$SEMVER_PATTERN/\3/")
75
27
76
- echo "::set-env name=VERSION_OLD::$VERSION_OLD"
77
- echo "::set-env name=VERSION_OLD_MAJOR::$VERSION_OLD_MAJOR"
78
- echo "::set-env name=VERSION_OLD_MINOR::$VERSION_OLD_MINOR"
79
- echo "::set-env name=VERSION_OLD_PATCH::$VERSION_OLD_PATCH"
28
+ - name : Install Hatch
29
+ uses : pypa/hatch@install
80
30
81
- echo "::set-env name=VERSION_NEW::$VERSION_NEW"
82
- echo "::set-env name=VERSION_NEW_MAJOR::$VERSION_NEW_MAJOR"
83
- echo "::set-env name=VERSION_NEW_MINOR::$VERSION_NEW_MINOR"
84
- echo "::set-env name=VERSION_NEW_PATCH::$VERSION_NEW_PATCH"
31
+ - name : Set up Python environment
32
+ run : hatch env create
85
33
86
- echo "Old version: $VERSION_OLD"
87
- echo "New version: $VERSION_NEW"
88
- - name : Check for patch version bump
89
- if : ${{ !startsWith(github.head_ref, 'release') && github.ref != 'refs/heads/master' }}
90
- run : |
91
- if [ "$FILES_CHANGED" = false ]; then
92
- echo "No Python scripts are modified"
93
- exit 0
94
- fi
34
+ - name : Check code and formatting
35
+ run : hatch fmt --check
95
36
96
- if [ "$VERSION_OLD_MAJOR" = "$VERSION_NEW_MAJOR" ] &&
97
- [ "$VERSION_OLD_MINOR" = "$VERSION_NEW_MINOR" ]; then
98
- if (($VERSION_OLD_PATCH < $VERSION_NEW_PATCH)); then
99
- echo "Bumped patch version $VERSION_OLD -> $VERSION_NEW"
100
- exit 0
101
- else
102
- echo "Bump patch version in __version__"
103
- exit 1
104
- fi
105
- else
106
- echo "Major / minor version must be bumped in a release branch"
107
- exit 1
108
- fi
109
- - name : Check for major / minor version bump
110
- if : ${{ startsWith(github.head_ref, 'release') && github.ref != 'refs/heads/master' }}
111
- run : |
112
- if (($VERSION_OLD_MAJOR < $VERSION_NEW_MAJOR)); then
113
- echo "Bumped major version $VERSION_OLD -> $VERSION_NEW"
114
- exit 0
115
- elif (($VERSION_OLD_MINOR < $VERSION_NEW_MINOR)); then
116
- echo "Bumped minor version $VERSION_OLD -> $VERSION_NEW"
117
- exit 0
118
- else
119
- echo "Major / minor version must be bumped for release"
120
- exit 1
121
- fi
122
- - name : Create and push tag
123
- if : github.ref == 'refs/heads/master'
124
- run : |
125
- version=$(echo -n $(git diff HEAD^1 -G '__version__' app_store_scraper/__version__.py))
126
- version=$(echo "$version" | sed -E "s/.*\+__version__.*([0-9]+\.[0-9]+\.[0-9]+).+/\1/")
127
- if [ "$version" != "" ]; then
128
- echo "Create and push v$version tag"
129
- git tag -f v"$version"
130
- git push origin v"$version"
131
- fi
37
+ - name : Run unit tests
38
+ run : hatch test
0 commit comments