From 78db20418b9e1cfd89e12f32adb0ec3376e1d915 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:27:07 +0100 Subject: [PATCH 01/12] add test to ci --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..166ac4b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: test + +on: + push: + pull_request: + types: [opened, synchronize] + +jobs: + test: + strategy: + fail-fast: false + matrix: + python-version: [3.8, 3.9, 3.10] + poetry-version: [1.1.2] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Run image + uses: abatilo/actions-poetry@v2.0.0 + with: + poetry-version: ${{ matrix.poetry-version }} + - name: Install dependencies + run: poetry install + - name: Run tests + run: poetry run pytest \ No newline at end of file From 58f6b122126dbb3a636d3f93809243450ab994a1 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:33:49 +0100 Subject: [PATCH 02/12] add pre-commit hooks --- .github/workflows/dependabot.yml | 11 +++++++++++ .github/workflows/test.yml | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..ac6621f --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 166ac4b..70739fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,8 +17,8 @@ jobs: run: shell: bash steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - name: Run image @@ -27,5 +27,7 @@ jobs: poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies run: poetry install + - name: Run pre-commit hooks + uses: pre-commit/action@v3.0.0 - name: Run tests run: poetry run pytest \ No newline at end of file From 168e822e154369739c6caa29d235b1402465e1a5 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:35:56 +0100 Subject: [PATCH 03/12] remove os matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70739fd..7053e09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,12 @@ on: jobs: test: + runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: [3.8, 3.9, 3.10] poetry-version: [1.1.2] - runs-on: ${{ matrix.os }} defaults: run: shell: bash From 1f25f869b8beed3b462f934907f9eaa2b89c5e11 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:37:53 +0100 Subject: [PATCH 04/12] update matrix --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7053e09..d685353 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,8 +11,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, 3.10] - poetry-version: [1.1.2] + python-version: [3.7, 3.8, 3.9, 3.10, 3.11] + poetry-version: [1.4.0] defaults: run: shell: bash From acf39af0818f1a86f570a79c278c98eee23bfabc Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:39:04 +0100 Subject: [PATCH 05/12] update dependabot --- .github/workflows/dependabot.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index ac6621f..9f9a146 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -5,7 +5,14 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "pip" + directory: "/" schedule: - interval: "weekly" + interval: "monthly" + reviewers: + - "thomaswollmann" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" \ No newline at end of file From 4535df82abd4fa8e7f1298ea8e20e65c552256a9 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:42:52 +0100 Subject: [PATCH 06/12] better poetry install --- .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d685353..b6007c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,10 @@ on: pull_request: types: [opened, synchronize] +concurrency: + group: tests-${{ github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: test: runs-on: ubuntu-latest @@ -12,22 +16,55 @@ jobs: fail-fast: false matrix: python-version: [3.7, 3.8, 3.9, 3.10, 3.11] - poetry-version: [1.4.0] defaults: run: shell: bash steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + + - name: Get full Python version + id: full-python-version + run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT + + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y + - name: Run image uses: abatilo/actions-poetry@v2.0.0 with: poetry-version: ${{ matrix.poetry-version }} + + - name: Configure poetry + run: poetry config virtualenvs.in-project true + + - name: Set up cache + uses: actions/cache@v3 + id: cache + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Ensure cache is healthy + if: steps.cache.outputs.cache-hit == 'true' + run: | + # `timeout` is not available on macOS, so we define a custom function. + [ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; } + # Using `timeout` is a safeguard against the Poetry command hanging for some reason. + timeout 10s poetry run pip --version || rm -rf .venv + + - name: Check lock file + run: poetry lock --check + - name: Install dependencies - run: poetry install + run: poetry install --with github-actions + - name: Run pre-commit hooks uses: pre-commit/action@v3.0.0 + - name: Run tests - run: poetry run pytest \ No newline at end of file + run: poetry run pytest -v \ No newline at end of file From 8297e2bf6fae26a99745ed2a22c9a548a8cf4ec5 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:43:48 +0100 Subject: [PATCH 07/12] fix branch config --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6007c8..1b8d1b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,8 @@ name: test on: push: pull_request: - types: [opened, synchronize] + branches: + - '**' concurrency: group: tests-${{ github.head_ref || github.ref }} From f5515e24fde7cd4b2e091ce898565532c5dba38a Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:45:53 +0100 Subject: [PATCH 08/12] fix matrix --- .github/workflows/test.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b8d1b9..a87cab3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,11 +12,13 @@ concurrency: jobs: test: - runs-on: ubuntu-latest + name: ${{ matrix.os }} / ${{ matrix.python-version }} + runs-on: ${{ matrix.image }} strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, 3.10, 3.11] + os: [Ubuntu, macOS, Windows] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] defaults: run: shell: bash @@ -35,11 +37,14 @@ jobs: run: | curl -sSL https://install.python-poetry.org | python - -y - - name: Run image - uses: abatilo/actions-poetry@v2.0.0 - with: - poetry-version: ${{ matrix.poetry-version }} - + - name: Update PATH + if: ${{ matrix.os != 'Windows' }} + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Update Path for Windows + if: ${{ matrix.os == 'Windows' }} + run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH + - name: Configure poetry run: poetry config virtualenvs.in-project true From c44ad5b6ad21d22dda2135240d7f0077bad5de42 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:47:24 +0100 Subject: [PATCH 09/12] fix matrix --- .github/workflows/test.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a87cab3..e07f3da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,14 @@ jobs: fail-fast: false matrix: os: [Ubuntu, macOS, Windows] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + include: + - os: Ubuntu + image: ubuntu-22.04 + - os: Windows + image: windows-2022 + - os: macOS + image: macos-12 defaults: run: shell: bash From 2a4de315fac8ff3d543b04d5753f5621a994a3c7 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:49:39 +0100 Subject: [PATCH 10/12] start with python 3.9 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e07f3da..3399a20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [Ubuntu, macOS, Windows] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] include: - os: Ubuntu image: ubuntu-22.04 From 29668fbd1f82729ea14d68dc272a5c838463b91a Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:53:51 +0100 Subject: [PATCH 11/12] release workflow --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8963c67 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: release + +on: + push: + tags: + - '*.*.*' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y + - name: Update PATH + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Build project for distribution + run: poetry build + + - name: Check Version + id: check-version + run: | + [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*" + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + prerelease: steps.check-version.outputs.prerelease == 'true' + + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI }} + run: poetry publish \ No newline at end of file From c15ca29c758acc275a0a0e3eea6dbe7f2b8bf7d4 Mon Sep 17 00:00:00 2001 From: Thomas Wollmann Date: Wed, 8 Mar 2023 10:58:18 +0100 Subject: [PATCH 12/12] avoid double testing --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3399a20..618375d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,7 @@ name: test on: push: + branches: ["main"] pull_request: branches: - '**'