mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-22 03:41:28 +08:00
Fix CI (#1108)
* Fix CI
* Fix CI
* Fix CI
* Fix CI
* APply black
* APply black
* Fix mypy
* Fix mypy errors in django-stubs
* Fix format
* Fix plugin
* Do not patch builtins by default
* Fix mypy
* Only run mypy on 3.10 for now
* Only run mypy on 3.10 for now
* WHAT THE HELL
* Enable strict mode in mypy
* Enable strict mode in mypy
* Fix tests
* Fix tests
* Debug
* Debug
* Fix tests
* Fix tests
* Add TYPE_CHECKING debug
* Caching maybe?
* Caching maybe?
* Try explicit `${{ matrix.python-version }}`
* Remove debug
* Fix typing
* Finally
This commit is contained in:
78
.github/workflows/release-django-stubs-ext.yml
vendored
78
.github/workflows/release-django-stubs-ext.yml
vendored
@@ -1,78 +0,0 @@
|
||||
# Please, keep it in sync with `release-django-stubs-ext.yml`
|
||||
name: Release django-stubs-ext
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'django-stubs-ext@*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
environment:
|
||||
name: django-stubs-ext-pypi
|
||||
url: https://pypi.org/project/django-stubs-ext
|
||||
|
||||
if: github.repository == 'typeddjango/django-stubs'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U setuptools twine wheel
|
||||
- name: Build package
|
||||
run: |
|
||||
cd ./django_stubs_ext
|
||||
python setup.py --version
|
||||
python setup.py sdist bdist_wheel
|
||||
ls dist
|
||||
|
||||
- name: Publish package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.DJANGO_STUBS_EXT_PYPI_API_TOKEN }}
|
||||
packages_dir: django_stubs_ext/dist
|
||||
print_hash: true
|
||||
|
||||
- name: Create release
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const tagName = context.ref.replace(/^refs\/tags\//, '');
|
||||
const release = await github.rest.repos.createRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
tag_name: tagName,
|
||||
name: `Release ${tagName}`,
|
||||
generate_release_notes: false,
|
||||
});
|
||||
|
||||
if (release.status < 200 || release.status >= 300) {
|
||||
core.setFailed(`Could not create release for tag '${tagName}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
# https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2
|
||||
create-issue-on-failure:
|
||||
name: Create an issue if release failed
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
if: ${{ github.repository == 'typeddjango/django-stubs' && always() && needs.build.result == 'failure' }}
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: `Release of django-stubs-ext failure on ${new Date().toDateString()}`,
|
||||
body: `Details: https://github.com/typeddjango/django-stubs/actions/workflows/release-django-stubs-ext.yml`,
|
||||
})
|
||||
76
.github/workflows/release-django-stubs.yml
vendored
76
.github/workflows/release-django-stubs.yml
vendored
@@ -1,76 +0,0 @@
|
||||
# Please, keep it in sync with `release-django-stubs-ext.yml`
|
||||
name: Release django-stubs
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'django-stubs@*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
environment:
|
||||
name: django-stubs-pypi
|
||||
url: https://pypi.org/project/django-stubs
|
||||
|
||||
if: github.repository == 'typeddjango/django-stubs'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U setuptools twine wheel
|
||||
- name: Build package
|
||||
run: |
|
||||
python setup.py --version
|
||||
python setup.py sdist bdist_wheel
|
||||
ls dist
|
||||
|
||||
- name: Publish package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.DJANGO_STUBS_PYPI_API_TOKEN }}
|
||||
print_hash: true
|
||||
|
||||
- name: Create release
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const tagName = context.ref.replace(/^refs\/tags\//, '');
|
||||
const release = await github.rest.repos.createRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
tag_name: tagName,
|
||||
name: `Release ${tagName}`,
|
||||
generate_release_notes: true,
|
||||
});
|
||||
|
||||
if (release.status < 200 || release.status >= 300) {
|
||||
core.setFailed(`Could not create release for tag '${tagName}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
# https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2
|
||||
create-issue-on-failure:
|
||||
name: Create an issue if release failed
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
if: ${{ github.repository == 'typeddjango/django-stubs' && always() && needs.build.result == 'failure' }}
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: `Release of django-stubs failure on ${new Date().toDateString()}`,
|
||||
body: `Details: https://github.com/typeddjango/django-stubs/actions/workflows/release-django-stubs.yml`,
|
||||
})
|
||||
33
.github/workflows/test.yml
vendored
33
.github/workflows/test.yml
vendored
@@ -27,11 +27,40 @@ jobs:
|
||||
- name: Run pre-commit
|
||||
run: pre-commit install && pre-commit run --all-files
|
||||
|
||||
mypy-self-check:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.7', '3.8', '3.9', '3.10']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -U pip setuptools wheel
|
||||
pip install -r ./requirements.txt
|
||||
|
||||
- name: Run mypy on plugin code
|
||||
run: mypy --strict mypy_django_plugin
|
||||
|
||||
- name: Run mypy on ext code
|
||||
run: mypy --strict django_stubs_ext
|
||||
- name: Run mypy on scripts and utils
|
||||
run: mypy --strict scripts
|
||||
# TODO: run this check on versions, not only 3.10
|
||||
- name: Run mypy on stubs
|
||||
if: ${{ matrix.python-version }} == '3.10'
|
||||
run: |
|
||||
mypy --cache-dir=/dev/null --no-incremental django-stubs
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.8']
|
||||
python-version: ['3.9']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup system dependencies
|
||||
@@ -46,7 +75,7 @@ jobs:
|
||||
pip install -r ./requirements.txt
|
||||
|
||||
- name: Run tests
|
||||
run: pytest --mypy-ini-file=mypy.ini
|
||||
run: PYTHONPATH='.' pytest
|
||||
|
||||
typecheck:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in New Issue
Block a user