Skip to content

Commit 949aefa

Browse files
authored
Setup CI (#486)
1 parent c4a4ead commit 949aefa

File tree

6 files changed

+167
-6
lines changed

6 files changed

+167
-6
lines changed

.github/workflows/auto-merge.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Dependabot auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/[email protected]
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
- name: Enable auto-merge for Dependabot PRs
19+
run: gh pr merge --auto --squash "$PR_URL"
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/ci.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6
8+
tags: [ 'v*' ]
9+
pull_request:
10+
branches:
11+
- master
12+
- '[0-9].[0-9]+'
13+
14+
15+
jobs:
16+
lint:
17+
name: Linter
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 5
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: 3.11
27+
cache: 'pip'
28+
cache-dependency-path: '**/requirements*.txt'
29+
- name: Pre-Commit hooks
30+
uses: pre-commit/[email protected]
31+
- name: Install dependencies
32+
uses: py-actions/py-dependency-install@v4
33+
with:
34+
path: requirements-dev.txt
35+
- name: Install itself
36+
run: |
37+
pip install .
38+
- name: Run linter
39+
run: |
40+
make lint
41+
- name: Prepare twine checker
42+
run: |
43+
pip install -U build twine wheel
44+
python -m build
45+
- name: Run twine checker
46+
run: |
47+
twine check dist/*
48+
49+
test:
50+
name: Test
51+
strategy:
52+
matrix:
53+
pyver: ['3.9', '3.10', '3.11', '3.12', '3.13']
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 15
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
- name: Setup Python ${{ matrix.pyver }}
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: ${{ matrix.pyver }}
63+
cache: 'pip'
64+
cache-dependency-path: '**/requirements*.txt'
65+
- name: Install dependencies
66+
uses: py-actions/py-dependency-install@v4
67+
with:
68+
path: requirements-dev.txt
69+
- name: Run unittests
70+
run: pytest tests
71+
env:
72+
COLOR: 'yes'
73+
# - run: python -m coverage xml
74+
# - name: Upload coverage
75+
# uses: codecov/codecov-action@v5
76+
# with:
77+
# fail_ci_if_error: true
78+
# token: ${{ secrets.CODECOV_TOKEN }}
79+
80+
check: # This job does nothing and is only used for the branch protection
81+
if: always()
82+
83+
needs: [lint, test]
84+
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- name: Decide whether the needed jobs succeeded or failed
89+
uses: re-actors/alls-green@release/v1
90+
with:
91+
jobs: ${{ toJSON(needs) }}
92+
93+
deploy:
94+
name: Deploy
95+
environment: release
96+
runs-on: ubuntu-latest
97+
needs: [check]
98+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v4
102+
- name: Setup Python
103+
uses: actions/setup-python@v5
104+
with:
105+
python-version: 3.9
106+
- name: Install dependencies
107+
run:
108+
python -m pip install -U pip wheel setuptools build twine
109+
- name: Build dists
110+
run: |
111+
python -m build
112+
- name: >-
113+
Publish 🐍📦 to PyPI
114+
uses: pypa/gh-action-pypi-publish@release/v1
115+
- name: Sign the dists with Sigstore
116+
uses: sigstore/[email protected]
117+
with:
118+
inputs: >-
119+
./dist/${{ env.PROJECT_NAME }}*.tar.gz
120+
./dist/${{ env.PROJECT_NAME }}*.whl
121+
- name: Upload artifact signatures to GitHub Release
122+
# Confusingly, this action also supports updating releases, not
123+
# just creating them. This is what we want here, since we've manually
124+
# created the release above.
125+
uses: softprops/action-gh-release@v2
126+
with:
127+
# dist/ contains the built packages, which smoketest-artifacts/
128+
# contains the signatures and certificates.
129+
files: dist/**
130+
# - name: Make Release
131+
# uses: aio-libs/[email protected]
132+
# with:
133+
# changes_file: CHANGES.rst
134+
# name: aiohttp-jinja2
135+
# version_file: aiohttp_jinja2/__init__.py
136+
# github_token: ${{ secrets.GITHUB_TOKEN }}
137+
# pypi_token: ${{ secrets.PYPI_API_TOKEN }}
138+
# dist_dir: dist
139+
# fix_issue_regex: "`#(\\d+) <https://github.com/aio-libs/aiohttp-jinja2/issues/\\1>`"
140+
# fix_issue_repl: "(#\\1)"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ pip-log.txt
4343
sdist/
4444
target/
4545
var/
46+
.python-version

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
all: test
22

33

4-
flake:
5-
flake8 aiohttp_cors tests setup.py
4+
lint:
5+
pre-commit run --all-files
66

7-
test: flake
7+
test: lint
88
pytest tests

aiohttp_cors/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
__summary__ = "CORS support for aiohttp"
2626
__uri__ = "https://github.com/aio-libs/aiohttp-cors"
2727
__license__ = "Apache License, Version 2.0"
28-
__copyright__ = f"2015 aio-libs team"
28+
__copyright__ = "2015 aio-libs team"

requirements-dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-e .
22
aiohttp==3.9.0
3-
docutils==0.19
43
flake8==4.0.1
54
packaging==24.2
6-
pygments==2.11.1
75
pytest==8.3.5
86
pytest-aiohttp==0.3.0
97
pytest-cov==3.0.0

0 commit comments

Comments
 (0)