Skip to content

Commit e9972d5

Browse files
authored
Merge branch 'master' into fix-overriding-imports
2 parents 854107d + f78336b commit e9972d5

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

.github/workflows/auto-testing.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
jobs:
1212
build:
13-
1413
runs-on: ubuntu-latest
1514
strategy:
1615
matrix:
@@ -47,4 +46,34 @@ jobs:
4746
run: |
4847
pip install readme-renderer
4948
python -m readme_renderer README.rst >/dev/null
50-
49+
50+
check-import:
51+
runs-on: ubuntu-latest
52+
strategy:
53+
matrix:
54+
python-version:
55+
- '3.9'
56+
- '3.10'
57+
- '3.11'
58+
- '3.12'
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
submodules: true
63+
- name: Set up Python ${{ matrix.python-version }}
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
- name: Update version in linebot/__about__.py
68+
run: |
69+
VERSION="12.3.0"
70+
VERSION=${VERSION#v}
71+
sed -i "s/__version__ = '__LINE_BOT_SDK_PYTHON_VERSION__'/__version__ = '$VERSION'/g" linebot/__about__.py
72+
cat linebot/__about__.py
73+
74+
- name: Install dependencies & lib
75+
run: |
76+
python -m pip install --upgrade pip
77+
pip install -e .
78+
- name: Run import check
79+
run: python import_check.py

.github/workflows/generated-code.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Generate code and open pull request
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- master
@@ -27,7 +28,13 @@ jobs:
2728
diff=$(git --no-pager diff --name-only HEAD)
2829
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
2930
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
30-
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
31+
## Run if diff exists and pull request, and make CI status failure
32+
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
33+
run: |
34+
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2
35+
exit 1
36+
## Run if diff exists and event is not pull request, and make PR
37+
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
3138
run: |
3239
git config user.name github-actions
3340
git config user.email [email protected]

import_check.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pkgutil
2+
import importlib
3+
import linebot
4+
5+
def import_all_modules(package):
6+
for importer, modname, ispkg in pkgutil.walk_packages(package.__path__, package.__name__ + '.'):
7+
try:
8+
importlib.import_module(modname)
9+
print(f'Successfully imported {modname}')
10+
except Exception as e:
11+
print(f'Failed to import {modname}: {e}')
12+
raise
13+
14+
import_all_modules(linebot)

0 commit comments

Comments
 (0)