diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf360a5..0ddbe65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -11,8 +16,8 @@ on: jobs: - pylint: - name: "PyLint" + check: + name: "Check" runs-on: ubuntu-latest strategy: matrix: @@ -20,20 +25,19 @@ jobs: - {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}}" @@ -41,27 +45,32 @@ jobs: 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::" @@ -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" @@ -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: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1ec264..c05f7fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,5 @@ # -# https://docs.github.com/en/actions/reference -# https://github.com/actions +# This runs when version tag is pushed # name: REL @@ -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: @@ -29,22 +28,35 @@ 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 @@ -52,34 +64,20 @@ jobs: 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 @@ -87,13 +85,12 @@ jobs: 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 diff --git a/etc/requirements.build.txt b/etc/requirements.build.txt new file mode 100644 index 0000000..ff9e40b --- /dev/null +++ b/etc/requirements.build.txt @@ -0,0 +1,4 @@ +setuptools>=67 +wheel>=0.41 +twine==4.0.2 +tox==4.8.0