Skip to content

Commit 02b95da

Browse files
committed
setup ci
1 parent 05768af commit 02b95da

3 files changed

Lines changed: 136 additions & 0 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: publish
2+
concurrency:
3+
group: ${{ github.workflow }}
4+
cancel-in-progress: true
5+
on: # yamllint disable-line rule:truthy
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
if: ${{ github.repository == 'Dandelion-Science/python-evdev' }}
12+
name: build py${{ matrix.python-version }}
13+
runs-on: codebuild-dandelion-linux-amd64-${{ github.run_id }}-${{ github.run_attempt }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.13", "3.13t", "3.14", "3.14t"]
18+
timeout-minutes: 15
19+
permissions:
20+
id-token: write
21+
contents: read
22+
steps:
23+
- uses: aws-actions/configure-aws-credentials@v6
24+
with:
25+
aws-region: ${{ vars.AWS_REGION }}
26+
role-to-assume: ${{ vars.ARN_IAM_ROLE_GHA_CORE }}
27+
- uses: actions/checkout@v7
28+
with:
29+
fetch-depth: 0
30+
- uses: Dandelion-Science/github-actions/setup-uv@main
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- run: uv build --wheel
34+
- uses: actions/upload-artifact@v4
35+
with:
36+
name: dist-${{ matrix.python-version }}
37+
path: dist/
38+
39+
build-sdist:
40+
if: ${{ github.repository == 'Dandelion-Science/python-evdev' }}
41+
runs-on: codebuild-dandelion-linux-arm64-${{ github.run_id }}-${{ github.run_attempt }}
42+
timeout-minutes: 15
43+
permissions:
44+
id-token: write
45+
contents: read
46+
steps:
47+
- uses: aws-actions/configure-aws-credentials@v6
48+
with:
49+
aws-region: ${{ vars.AWS_REGION }}
50+
role-to-assume: ${{ vars.ARN_IAM_ROLE_GHA_CORE }}
51+
- uses: actions/checkout@v7
52+
with:
53+
fetch-depth: 0
54+
- uses: Dandelion-Science/github-actions/setup-uv@main
55+
- run: uv build --sdist
56+
- uses: actions/upload-artifact@v4
57+
with:
58+
name: dist-sdist
59+
path: dist/
60+
61+
publish:
62+
if: ${{ github.repository == 'Dandelion-Science/python-evdev' }}
63+
needs: [build, build-sdist]
64+
runs-on: codebuild-dandelion-linux-arm64-${{ github.run_id }}-${{ github.run_attempt }}
65+
timeout-minutes: 15
66+
permissions:
67+
id-token: write
68+
contents: write
69+
steps:
70+
- uses: aws-actions/configure-aws-credentials@v6
71+
with:
72+
aws-region: ${{ vars.AWS_REGION }}
73+
role-to-assume: ${{ vars.ARN_IAM_ROLE_GHA_CORE }}
74+
- uses: actions/download-artifact@v4
75+
with:
76+
path: dist
77+
merge-multiple: true
78+
- uses: softprops/action-gh-release@v3
79+
with:
80+
files: dist/*
81+
tag_name: ${{ github.event.release.tag_name }}
82+
- name: Get CodeArtifact token
83+
run: |
84+
AWS_CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token \
85+
--domain ${{ vars.CODEARTIFACT_DOMAIN }} \
86+
--domain-owner ${{ vars.CODEARTIFACT_DOMAIN_OWNER }} \
87+
--query authorizationToken \
88+
--output text)
89+
echo "AWS_CODEARTIFACT_TOKEN=$AWS_CODEARTIFACT_TOKEN" >> $GITHUB_ENV
90+
- uses: Dandelion-Science/github-actions/setup-uv@main
91+
- run: uv publish
92+
env:
93+
UV_PUBLISH_USERNAME: aws
94+
UV_PUBLISH_PASSWORD: ${{ env.AWS_CODEARTIFACT_TOKEN }}
95+
UV_PUBLISH_URL: ${{ vars.CODEARTIFACT_DANDELION_PYPI_REPOSITORY_URL }}

.github/workflows/pytest.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: pytest
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
4+
cancel-in-progress: true
5+
on: # yamllint disable-line rule:truthy
6+
pull_request:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
jobs:
12+
pytest:
13+
if: ${{ !cancelled() && github.repository == 'Dandelion-Science/python-evdev' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) }}
14+
name: py${{ matrix.python-version }}
15+
runs-on: codebuild-dandelion-linux-arm64-${{ github.run_id }}-${{ github.run_attempt }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.13", "3.13t", "3.14", "3.14t"]
20+
timeout-minutes: 30
21+
permissions:
22+
id-token: write
23+
contents: read
24+
steps:
25+
- uses: aws-actions/configure-aws-credentials@v6
26+
with:
27+
aws-region: ${{ vars.AWS_REGION }}
28+
role-to-assume: ${{ vars.ARN_IAM_ROLE_GHA_CORE }}
29+
- uses: actions/checkout@v7
30+
with:
31+
fetch-depth: 0
32+
- uses: Dandelion-Science/github-actions/setup-uv@main
33+
with:
34+
activate-environment: true
35+
python-version: ${{ matrix.python-version }}
36+
- run: uv sync -q --no-default-groups --group test
37+
- run: pytest tests/test_ecodes.py tests/test_events.py tests/test_util.py
38+
- run: sudo .venv/bin/pytest tests/test_uinput.py

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ classifiers = [
2828
[project.urls]
2929
"Homepage" = "https://github.com/gvalkov/python-evdev"
3030

31+
[dependency-groups]
32+
test = ["pytest"]
33+
3134
[tool.ruff]
3235
line-length = 120
3336

0 commit comments

Comments
 (0)