Skip to content

Commit

Permalink
✨ Upgrade dependencies and fix make
Browse files Browse the repository at this point in the history
  • Loading branch information
perdy committed Feb 5, 2024
1 parent 10ffd5e commit 5269e1b
Show file tree
Hide file tree
Showing 12 changed files with 755 additions and 789 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ on:

jobs:
test:
name: Test (Python ${{ matrix.python }})
name: Test (${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v1
- name: Commit Linter
uses: wagoid/commitlint-github-action@v5
- id: install
name: Install requirements
run: |
Expand All @@ -29,9 +30,9 @@ jobs:
- id: isort
name: Imports order checking
run: python make isort --check .
- id: flake8
- id: ruff
name: Code lint
run: python make flake8
run: python make ruff .
- id: tests
name: Tests
run: python make test
52 changes: 29 additions & 23 deletions .github/workflows/ci_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ on:

jobs:
test:
name: Test (Python ${{ matrix.python }})
name: Test (${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v1
- name: Commit Linter
uses: wagoid/commitlint-github-action@v5
- id: install
name: Install requirements
run: |
Expand All @@ -30,36 +31,41 @@ jobs:
- id: isort
name: Imports order checking
run: python make isort --check .
- id: flake8
- id: ruff
name: Code lint
run: python make flake8
run: python make ruff .
- id: tests
name: Tests
run: python make test
- id: codecov
name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.2
# Run on a specific python version and only master branch commits
if: matrix.python == 3.9 && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: test-results/coverage.xml
release:
needs: test
name: Release a new version
runs-on: ubuntu-latest
container:
image: perdy/github-actions-builder:latest
steps:
- uses: actions/checkout@master
- name: Check out the repo
uses: actions/checkout@master
- name: Setup node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 20
- id: install
name: Install requirements
run: |
pip install clinner pip poetry --upgrade
python make install
- id: semantic
name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
with:
node-version: 14
- id: publish
name: Publish version
run: npx semantic-release
extra_plugins: |
semantic-release-gitmoji@1.5.0
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: New release published
if: steps.semantic.outputs.new_release_published == 'true'
run: |
echo "New version: ${{ steps.semantic.outputs.new_release_version }}"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
.venv/
build/
develop-eggs/
dist/
Expand All @@ -25,7 +26,6 @@ var/
*.egg
*dist/
pip-wheel-metadata/
.python-version

# Installer logs
pip-log.txt
Expand Down Expand Up @@ -53,4 +53,5 @@ node_modules
*.vscode

## Demo & Tests
*.db
demo.db
test.db
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ repos:
stages: [commit-msg]
- repo: local
hooks:
- id: flake8
name: Flake8 - Code Linter
entry: poetry run flake8
- id: ruff
name: Code Linter
entry: poetry run ruff
language: system
types: [python]
- id: black
name: Black - Code Style
name: Code Style
entry: poetry run black
args:
- -q
Expand All @@ -38,7 +38,7 @@ repos:
language: system
types: [python]
- id: isort
name: Isort - Sort Imports
name: Sort Imports
entry: poetry run isort
args:
- -e
Expand Down
9 changes: 0 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# Semantic Versioning Changelog

# [v0.9.0](https://github.com/perdy/starlette-prometheus/compare/v0.8.0...v0.9.0) (2022-01-10)

## ✨ New Features
- [`c801022`](https://github.com/perdy/starlette-prometheus/commit/c801022) update prometheus-client to 0.12
- [`c04164f`](https://github.com/perdy/starlette-prometheus/commit/c04164f) Python 3.10 compatibility and upgrade requirements

## 🐛 Bug Fixes
- [`90837df`](https://github.com/perdy/starlette-prometheus/commit/90837df) UnboundLocalError: local variable 'status_code' referenced before assignment

# [v0.8.0](https://github.com/perdy/starlette-prometheus/compare/v0.7.0...v0.8.0) (2021-08-31)

## ✨ New Features
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Starlette Prometheus
[![Build Status](https://github.com/perdy/starlette-prometheus/workflows/Continuous%20Integration/badge.svg)](https://github.com/perdy/starlette-prometheus/actions)
[![codecov](https://codecov.io/gh/perdy/starlette-prometheus/branch/master/graph/badge.svg)](https://codecov.io/gh/perdy/starlette-prometheus)
[![Package Version](https://img.shields.io/pypi/v/starlette-prometheus?logo=PyPI&logoColor=white)](https://pypi.org/project/starlette-prometheus/)
[![PyPI Version](https://img.shields.io/pypi/pyversions/starlette-prometheus?logo=Python&logoColor=white)](https://pypi.org/project/starlette-prometheus/)

Expand All @@ -10,8 +9,8 @@ Prometheus integration for Starlette.

## Requirements

* Python 3.6+
* Starlette 0.9+
* Python 3.8+
* Starlette 0.12+

## Installation

Expand Down
19 changes: 19 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
rules: {
"type-enum": [2, "always", [':art:', ':zap:', ':fire:', ':bug:', ':ambulance:', ':sparkles:', ':memo:', ':rocket:', ':lipstick:', ':tada:', ':white_check_mark:', ':lock:', ':closed_lock_with_key:', ':bookmark:', ':rotating_light:', ':construction:', ':green_heart:', ':arrow_down:', ':arrow_up:', ':pushpin:', ':construction_worker:', ':chart_with_upwards_trend:', ':recycle:', ':heavy_plus_sign:', ':heavy_minus_sign:', ':wrench:', ':hammer:', ':globe_with_meridians:', ':pencil2:', ':poop:', ':rewind:', ':twisted_rightwards_arrows:', ':package:', ':alien:', ':truck:', ':page_facing_up:', ':boom:', ':bento:', ':wheelchair:', ':bulb:', ':beers:', ':speech_balloon:', ':card_file_box:', ':loud_sound:', ':mute:', ':busts_in_silhouette:', ':children_crossing:', ':building_construction:', ':iphone:', ':clown_face:', ':egg:', ':see_no_evil:', ':camera_flash:', ':alembic:', ':mag:', ':label:', ':seedling:', ':triangular_flag_on_post:', ':goal_net:', ':dizzy:', ':wastebasket:', ':passport_control:', ':adhesive_bandage:', ':monocle_face:', ':coffin:', ':test_tube:', ':necktie:', ':stethoscope:', ':bricks:', ':technologist:', ':money_with_wings:', ':thread:', ':safety_vest:']],
"body-leading-blank": [2, "always"],
"footer-leading-blank": [2, "always"],
"header-max-length": [2, "always", 72],
"scope-case": [2, "always", "lower-case"],
"subject-case": [2, "always", ["sentence-case"]],
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", ["."]],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"]
}, parserPreset: {
parserOpts: {
headerPattern: /^(:\w*:)(?:\((.*?)\))?\s((?:.*(?=\())|.*)(?:\(#(\d*)\))?/,
headerCorrespondence: ["type", "scope", "subject", "ticket"]
}
}
};
28 changes: 13 additions & 15 deletions make
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import typing

import logging
import os
import shlex
import shutil
import subprocess
import sys
import tempfile
import typing
import urllib.request

logger = logging.getLogger("cli")
Expand Down Expand Up @@ -53,7 +52,7 @@ def poetry(*args) -> typing.List[str]:

@command(command_type=Type.SHELL, parser_opts={"help": "Install requirements"})
def install(*args, **kwargs):
return [poetry("install", *args)]
return [poetry("install", "--with", "dev", *args)]


@command(command_type=Type.PYTHON, parser_opts={"help": "Clean directory"})
Expand All @@ -74,24 +73,24 @@ def build(*args, **kwargs):
return [poetry("build", *args)]


@command(command_type=Type.SHELL, parser_opts={"help": "Black code formatting"})
@command(command_type=Type.SHELL, parser_opts={"help": "Code formatting"})
def black(*args, **kwargs):
return [poetry("run", "black", *args)]


@command(command_type=Type.SHELL, parser_opts={"help": "Flake8 code analysis"})
def flake8(*args, **kwargs):
return [poetry("run", "flake8", *args)]
@command(command_type=Type.SHELL, parser_opts={"help": "Code analysis"})
def ruff(*args, **kwargs):
return [poetry("run", "ruff", "check", *args)]


@command(command_type=Type.SHELL, parser_opts={"help": "Isort imports formatting"})
@command(command_type=Type.SHELL, parser_opts={"help": "Imports formatting"})
def isort(*args, **kwargs):
return [poetry("run", "isort", *args)]


@command(command_type=Type.SHELL, parser_opts={"help": "Code lint using multiple tools"})
def lint(*args, **kwargs):
return black() + flake8() + isort()
return black(".") + ruff(".") + isort(".")


@command(command_type=Type.SHELL, parser_opts={"help": "Run tests"})
Expand All @@ -117,22 +116,21 @@ def version(*args, **kwargs):
def publish(*args, **kwargs):
cmds = []

username = os.environ.get("PYPI_USERNAME")
password = os.environ.get("PYPI_PASSWORD")
token = os.environ.get("PYPI_TOKEN")

if username and password:
cmds.append(poetry("config", "http-basic.pypi", username, password))
if token:
cmds.append(poetry("config", "pypi-token.pypi", token))

if kwargs["build"]:
cmds += build(clean=True)

cmds.append(poetry("publish"))
cmds.append(poetry("publish", "--skip-existing"))

return cmds


class Make(Main):
commands = ("install", "clean", "build", "publish", "black", "flake8", "isort", "lint", "test", "version", "docs")
commands = ("install", "clean", "build", "publish", "black", "ruff", "isort", "lint", "test", "version", "docs")


def main():
Expand Down

0 comments on commit 5269e1b

Please sign in to comment.