Skip to content

Commit

Permalink
ci: sync with python-skytools
Browse files Browse the repository at this point in the history
  • Loading branch information
markokr committed Aug 27, 2023
1 parent 3100a03 commit 7937a34
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 52 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# https://docs.github.com/en/actions/reference
# https://github.com/actions
#
# uses: https://github.com/actions/checkout @v3
# uses: https://github.com/actions/setup-python @v4
# uses: https://github.com/actions/download-artifact @v3
# uses: https://github.com/actions/upload-artifact @v3
#

name: CI

Expand All @@ -11,8 +16,8 @@ on:

jobs:

pylint:
name: "PyLint"
check:
name: "Check"
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -27,20 +32,22 @@ jobs:
with:
python-version: ${{matrix.test.PY}}

- name: "Install tox"
run: python -m pip -q install tox
- run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check

- name: "Run checker"
- name: "Test"
env:
TOXENV: ${{matrix.test.TOXENV}}
run: python -m tox -r
run: python3 -m tox -r

database:
name: "Python ${{matrix.test.PY}} + PostgreSQL ${{matrix.test.PG}}"
runs-on: ubuntu-latest
strategy:
matrix:
test:
- {PY: "3.7", PG: "11", TOXENV: "py37"}
- {PY: "3.8", PG: "12", TOXENV: "py38"}
- {PY: "3.9", PG: "13", TOXENV: "py39"}
- {PY: "3.10", PG: "14", TOXENV: "py310"}
- {PY: "3.11", PG: "15", TOXENV: "py311"}
steps:
Expand All @@ -52,15 +59,13 @@ jobs:
with:
python-version: ${{matrix.test.PY}}

- name: "Install tox"
run: |
python -m pip -q install tox
- run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check

- name: "InstallDB"
run: |
echo "::group::apt-get-update"
sudo -nH apt-get -q update
sudo -nH apt install curl ca-certificates gnupg
sudo -nH apt-get -q install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor \
| sudo -nH tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg
Expand Down Expand Up @@ -103,7 +108,7 @@ jobs:
TEST_Q_NAME: testq
PGDATABASE: testdb
run: |
python -m tox -r -- --color=yes
python3 -m tox -r -- --color=yes
- name: "StopDB"
run: |
Expand Down
71 changes: 33 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#
# https://docs.github.com/en/actions/reference
# https://github.com/actions
# This runs when version tag is pushed
#

name: REL
Expand All @@ -24,66 +23,62 @@ jobs:
with:
python-version: "3.11"

- name: Build tarball
id: build
- run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check

- name: "Get files"
run: |
python -m pip install --disable-pip-version-check -U setuptools wheel
PACKAGE=$(python setup.py --name)
VERSION=$(python setup.py --version)
python3 setup.py sdist
python3 -m pip wheel --disable-pip-version-check --no-deps -w dist dist/*
ls -l dist
- name: "Install pandoc"
run: |
sudo -nH apt-get -u -y install pandoc
pandoc --version
- name: "Prepare"
run: |
PACKAGE=$(python3 setup.py --name)
VERSION=$(python3 setup.py --version)
TGZ="${PACKAGE}-${VERSION}.tar.gz"
# default - gh:release, pypi
# PRERELEASE - gh:prerelease, pypi
# DRAFT - gh:draft,prerelease, testpypi
PRERELEASE="false"
DRAFT="false"
if echo "${VERSION}" | grep -qE '(a|b|rc)'; then PRERELEASE="true"; fi
if echo "${VERSION}" | grep -qE '(dev)'; then DRAFT="true"; PRERELEASE="true"; fi
PRERELEASE="false"; DRAFT="false"
case "${VERSION}" in
*[ab]*|*rc*) PRERELEASE="true";;
*dev*) PRERELEASE="true"; DRAFT="true";;
esac
test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; }
python setup.py sdist
test -f "dist/${TGZ}" || { echo "ERR: sdist failed"; exit 1; }
python -m pip wheel --disable-pip-version-check -w dist dist/${TGZ}
rm -f dist/skytools*
echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "TGZ=${TGZ}" >> $GITHUB_ENV
echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
echo "DRAFT=${DRAFT}" >> $GITHUB_ENV
sudo -nH apt-get -u -y install pandoc
pandoc --version
mkdir -p tmp
make -s shownote > tmp/note.md
cat tmp/note.md
ls -l dist
- name: "Create release"
id: github_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: ${{env.PACKAGE}} v${{env.VERSION}}
body_path: tmp/note.md
prerelease: ${{env.PRERELEASE}}
draft: ${{env.DRAFT}}

- name: "Upload to Github"
id: github_upload
uses: actions/upload-release-asset@v1
- name: "Create Github release"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.github_release.outputs.upload_url}}
asset_path: dist/${{env.TGZ}}
asset_name: ${{env.TGZ}}
asset_content_type: application/x-gzip
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
title="${PACKAGE} v${VERSION}"
ghf="--notes-file=./tmp/note.md"
if test "${DRAFT}" = "true"; then ghf="${ghf} --draft"; fi
if test "${PRERELEASE}" = "true"; then ghf="${ghf} --prerelease"; fi
gh release create "v${VERSION}" "dist/${TGZ}" --title="${title}" ${ghf}
- name: "Upload to PYPI"
id: pypi_upload
env:
PYPI_TOKEN: ${{secrets.PYPI_TOKEN}}
PYPI_TEST_TOKEN: ${{secrets.PYPI_TEST_TOKEN}}
run: |
pip install --disable-pip-version-check -U twine
ls -l dist
if test "${DRAFT}" = "false"; then
python -m twine upload -u __token__ -p ${PYPI_TOKEN} \
Expand Down
4 changes: 4 additions & 0 deletions etc/requirements.build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
setuptools>=67
wheel>=0.41
twine==4.0.2
tox==4.8.0
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ test_deps =
pytest-cov==4.1.0
lint_deps =
mypy==1.5.1
pylint==2.17.5
pyflakes==3.1.0
pytype==2023.8.14
typing-extensions==4.7.1
types-setuptools==68.1.0.0
types-psycopg2==2.9.21.11
xlint_deps =
pylint==2.17.5
pytype==2023.8.22

[testenv]
changedir = {envsitepackagesdir}
Expand Down Expand Up @@ -51,11 +52,12 @@ commands =
mypy {[package]name}

[testenv:xlint]
basepython = python3
basepython = python3.10
changedir = {toxinidir}
deps =
{[package]deps}
{[package]lint_deps}
{[package]xlint_deps}
commands =
pylint {[package]name}
pytype {[package]name}
Expand Down

0 comments on commit 7937a34

Please sign in to comment.