Skip to content

Commit

Permalink
ci: sync, cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
markokr committed Aug 27, 2023
1 parent bef9c90 commit 01d14cf
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 60 deletions.
43 changes: 26 additions & 17 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,57 +16,61 @@ on:

jobs:

pylint:
name: "PyLint"
check:
name: "Check"
runs-on: ubuntu-latest
strategy:
matrix:
test:
- {PY: "3.10", TOXENV: "lint"}
steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Setup Python ${{matrix.test.PY}}"
uses: actions/setup-python@v2
uses: actions/setup-python@v4
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:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Setup Python ${{matrix.test.PY}}"
uses: actions/setup-python@v2
uses: actions/setup-python@v4
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-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
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main ${{matrix.test.PG}}" \
| sudo tee /etc/apt/sources.list.d/pgdg.list
| sudo -nH tee /etc/apt/sources.list.d/pgdg.list
sudo -nH apt-get -q update
echo "::endgroup::"
Expand All @@ -81,8 +90,8 @@ jobs:
- name: "Install extensions"
run: |
echo "::group::install-pgq"
git clone -q https://github.com/pgq/pgq; make -C pgq
sudo -nH bash -c "PATH='${PATH}' make install -C pgq"
git clone -q https://github.com/pgq/pgq pgq-sql; make -C pgq-sql
sudo -nH bash -c "PATH='${PATH}' make install -C pgq-sql"
echo "::endgroup::"
echo "::group::install-pgq-node"
Expand Down Expand Up @@ -116,7 +125,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
83 changes: 40 additions & 43 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 @@ -15,12 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with: {python-version: "3.10"}
- run: pip install --disable-pip-version-check -U wheel
- run: python setup.py sdist
- run: python setup.py bdist_wheel
- uses: actions/upload-artifact@v2
- uses: actions/setup-python@v4
with: {python-version: "3.11"}
- run: python3 -m pip install -r etc/requirements.build.txt --disable-pip-version-check
- run: python3 setup.py sdist
- run: python3 setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with: {name: "dist", path: "dist"}

publish:
Expand All @@ -29,71 +28,69 @@ jobs:
needs: [sdist]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with: {python-version: "3.10"}
- uses: actions/download-artifact@v2
- uses: actions/setup-python@v4
with: {python-version: "3.11"}

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

- name: "Get files"
uses: actions/download-artifact@v3
with: {name: "dist", path: "dist"}

- name: "Install pandoc"
run: |
sudo -nH apt-get -u -y install pandoc
pandoc --version
- name: "Prepare"
run: |
PACKAGE=$(python setup.py --name)
VERSION=$(python setup.py --version)
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; }
test -f "dist/${TGZ}" || { echo "ERR: sdist failed"; exit 1; }
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}" \
python -m twine upload -u __token__ -p ${PYPI_TOKEN} \
--repository pypi --disable-progress-bar dist/*
else
python -m twine upload -u "__token__" -p "${PYPI_TEST_TOKEN}" \
python -m twine upload -u __token__ -p ${PYPI_TEST_TOKEN} \
--repository testpypi --disable-progress-bar dist/*
fi
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

0 comments on commit 01d14cf

Please sign in to comment.