Skip to content

Commit

Permalink
CI: 更新开发依赖和 CI 工作流,规范现有代码 (#1)
Browse files Browse the repository at this point in the history
- 更新 dev-requirements.txt 文件,增加和修改了一些依赖项
-升级 actions/checkout 到 v4 和 actions/setup-python 到 v5
- 更新 Python 版本到 3.9
-优化了依赖安装过程,使用 python -m pip 命令- 添加了检查是否为 alpha版本的步骤
- 更新了测试矩阵,增加了对 Python 3.12 的支持
- 修改了安装和检查分发包的步骤,支持 whl 和 gz两种格式
- 更新了项目状态从 Production/Stable 到 Alpha- 移除了对 Python 3.8 的支持
  • Loading branch information
dingxin-tech authored Nov 13, 2024
1 parent fd3fd0a commit 5ca7a3e
Show file tree
Hide file tree
Showing 25 changed files with 153 additions and 204 deletions.
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

79 changes: 45 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,22 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install python dependencies
run: |
pip install --user --upgrade pip
pip install pre-commit
pip install mypy==0.782
pip install -r dev-requirements.txt
pip --version
python -m pip install --user --upgrade pip
python -m pip install -r dev-requirements.txt
python -m pip --version
pre-commit --version
mypy --version
dbt --version
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure

Expand All @@ -69,22 +67,26 @@ jobs:

runs-on: ubuntu-latest

outputs:
is_alpha: ${{ steps.check-is-alpha.outputs.is_alpha }}

steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.9'

- name: Install python dependencies
run: |
pip install --user --upgrade pip
pip install --upgrade setuptools wheel twine check-wheel-contents
pip --version
python -m pip install --user --upgrade pip
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
python -m pip --version
- name: Build distributions
run: ./scripts/build-dist.sh

Expand All @@ -94,16 +96,28 @@ jobs:
- name: Check distribution descriptions
run: |
twine check dist/*
- name: Check wheel contents
run: |
check-wheel-contents dist/*.whl --ignore W007,W008
- uses: actions/upload-artifact@v3
- name: Check if this is an alpha version
id: check-is-alpha
run: |
export is_alpha=0
if [[ "$(ls -lh dist/)" == *"a1"* ]]; then export is_alpha=1; fi
echo "is_alpha=$is_alpha" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
overwrite: true

test-build:
name: verify packages / python ${{ matrix.python-version }} / ${{ matrix.os }}
name: verify packages / python ${{ matrix.python-version }} / ${{ matrix.os }} / ${{ matrix.dist-type }}

if: needs.build.outputs.is_alpha == 0

needs: build

Expand All @@ -112,37 +126,34 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-14, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
dist-type: ["whl", "gz"]

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
run: |
pip install --user --upgrade pip
pip install --upgrade wheel
pip --version
- uses: actions/download-artifact@v3
python -m pip install --user --upgrade pip
python -m pip install --upgrade wheel
python -m pip --version
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Show distributions
run: ls -lh dist/

- name: Install wheel distributions
- name: Install ${{ matrix.dist-type }} distributions
run: |
find ./dist/*.whl -maxdepth 1 -type f | xargs pip install --force-reinstall --find-links=dist/
- name: Check wheel distributions
run: |
dbt --version
- name: Install source distributions
run: |
find ./dist/*.gz -maxdepth 1 -type f | xargs pip install --force-reinstall --find-links=dist/
- name: Check source distributions
find ./dist/*.${{ matrix.dist-type }} -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
- name: Check ${{ matrix.dist-type }} distributions
run: |
dbt --version
python -c "import dbt.adapters.maxcompute"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ dmypy.json
.pyre/

# Idea
.idea
.idea
2 changes: 1 addition & 1 deletion .idea/dbt-maxcompute.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 52 additions & 49 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
# For more on configuring pre-commit hooks (see https://pre-commit.com/)
default_language_version:
python: python3

# TODO: remove global exclusion of tests when testing overhaul is complete
exclude: "^tests/.*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict

- repo: https://github.com/dbt-labs/pre-commit-hooks
rev: v0.1.0a1
hooks:
- id: dbt-core-in-adapters-check

default_language_version:
python: python3.8
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args:
- --line-length=99
- --target-version=py39
- --target-version=py310
- --target-version=py311
- --target-version=py312
additional_dependencies: [flaky]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args:
- "--line-length=99"
- "--target-version=py38"
- id: black
alias: black-check
stages: [manual]
args:
- "--line-length=99"
- "--target-version=py38"
- "--check"
- "--diff"
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
- id: flake8
alias: flake8-check
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
hooks:
- id: mypy
args: [--show-error-codes, --ignore-missing-imports]
files: ^dbt/adapters/.*
language: system
- id: mypy
alias: mypy-check
stages: [manual]
args: [--show-error-codes, --pretty, --ignore-missing-imports]
files: ^dbt/adapters
language: system
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
exclude: tests/
args:
- --max-line-length=99
- --select=E,F,W
- --ignore=E203,E501,E741,W503,W504
- --per-file-ignores=*/__init__.py:F401

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
args:
- --explicit-package-bases
- --ignore-missing-imports
- --pretty
- --show-error-codes
- --warn-unused-ignores
files: ^dbt/adapters/maxcompute
additional_dependencies:
- types-protobuf
- types-pytz
- types-requests
18 changes: 9 additions & 9 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
13 changes: 0 additions & 13 deletions License

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ Your feedback helps improve the project:
## Code of Conduct

We are committed to fostering a welcoming and inclusive environment. All community members are expected to adhere to
the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
4 changes: 2 additions & 2 deletions dbt/adapters/maxcompute/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@dataclass
class MaxComputeColumn(Column):
table_column: TableSchema.TableColumn = None
comment: str = None
comment: str = ""

TYPE_LABELS = {
"TEXT": "STRING",
Expand Down Expand Up @@ -41,7 +41,7 @@ def is_string(self) -> bool:
def string_type(cls, size: int) -> str:
return "string"

def can_expand_to(self: Self, other_column: Self) -> bool: # type: ignore
def can_expand_to(self: Self, other_column: Self) -> bool:
"""returns True if both columns are strings"""
return self.is_string() and other_column.is_string()

Expand Down
Loading

0 comments on commit 5ca7a3e

Please sign in to comment.