Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Setup CI #1

Merged
merged 4 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2
updates:
- directory: /
package-ecosystem: pip
schedule:
interval: weekly
timezone: America/Mexico_City
assignees:
- "edgarrmondragon"
reviewers:
- "edgarrmondragon"
commit-message:
prefix: "chore(deps): "
prefix-development: "chore(deps-dev): "
- package-ecosystem: pip
directory: /.github/workflows
schedule:
interval: monthly
timezone: America/Mexico_City
assignees:
- "edgarrmondragon"
reviewers:
- "edgarrmondragon"
commit-message:
prefix: "ci: "
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: monthly
timezone: America/Mexico_City
assignees:
- "edgarrmondragon"
reviewers:
- "edgarrmondragon"
commit-message:
prefix: "ci: "
2 changes: 2 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enabled: true
titleOnly: true
1 change: 1 addition & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hatch==1.7.0
51 changes: 51 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish to PyPI

on:
release:
types: [published]

permissions:
contents: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Build
run: |
hatch build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist

upload:
runs-on: ubuntu-latest
needs: build
environment: publish
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Upload wheel to release
uses: svenstaro/upload-release-action@v2
with:
file: dist/*.whl
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.10
135 changes: 135 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Test

on:
push:
branches: [ main ]
paths:
- src/**
- tests/**
- pyproject.toml
- .github/workflows/test.yml
- .github/workflows/constraints.txt
pull_request:
branches: [ main ]
paths:
- src/**
- tests/**
- pyproject.toml
- .github/workflows/test.yml
- .github/workflows/constraints.txt
workflow_dispatch: {}
schedule:
# Run every 27 hours to avoid running at the same time every day
- cron: "40 12 * * 1-5"

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run lint
env:
HATCH_ENV: lint
run: |
hatch run style

typing:
name: Typing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run typing
env:
HATCH_ENV: lint
run: |
hatch run typing

test:
name: Pytest (Python ${{ matrix.python-version }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- python-version: "3.11"
os: "windows-latest"

- python-version: "3.11"
os: "macos-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run tests
env:
HATCH_ENV: "test.py${{ matrix.python-version }}"
run: |
hatch run cov
- uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage.*"

coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
env:
PYTHON: "3.11"
HATCH_ENV: coverage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON }}
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Combine coverage data
run: |
hatch run report
- name: Create coverage XML report
run: |
hatch run xml
- uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,27 @@ source = "vcs"

[tool.hatch.envs.test]
dependencies = [
"coverage[toml]>=6.5",
"hypothesis",
"hypothesis-jsonschema",
"pytest",
]
[tool.hatch.envs.test.scripts]
run = "pytest {args:tests}"
test = "pytest {args:tests}"
cov = "coverage run -m pytest {args:tests}"

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

[tool.hatch.envs.coverage]
dependencies = [
"coverage[toml]>=6.5",
]
[tool.hatch.envs.coverage.scripts]
json = "coverage json"
xml = "coverage xml"
report = ["coverage combine", "coverage report --show-missing"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
Expand All @@ -63,7 +74,7 @@ dependencies = [
"hypothesis",
"hypothesis-jsonschema",
"pytest",
"ruff>=0.0.243",
"ruff>=0.0.287",
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/pep610 tests}"
Expand Down
2 changes: 1 addition & 1 deletion src/pep610/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from __future__ import annotations

import json
import sys
import typing as t
from dataclasses import dataclass
from importlib.metadata import version
from pathlib import Path

if t.TYPE_CHECKING:
import sys
from importlib.metadata import Distribution
from os import PathLike

Expand Down
Loading