Skip to content

Commit

Permalink
Add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ReK42 committed Aug 3, 2024
1 parent 357cc09 commit 7b43af0
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
35 changes: 35 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
all:
applies-to: version-updates
patterns:
- "*"
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
groups:
development:
applies-to: version-updates
patterns:
- "black"
- "ruff"
- "mypy"
- "pandas-stubs"
- "setuptools"
- "setuptools-scm"
- "build"
- "twine"
minor-and-patch:
applies-to: version-updates
patterns:
- "*"
update-types:
- "minor"
- "patch"
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
changelog:
categories:
- title: Changes
labels:
- "*"
exclude:
labels:
- dependencies
- title: Dependencies
labels:
- dependencies
7 changes: 7 additions & 0 deletions .github/templates/pr-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Your pull request has been merged and a preview build has been published!**

Build {{ .version }} is now available at TestPyPI: <https://test.pypi.org/project/modem-info/{{ .version }}>

To install, run: `pip install -i https://test.pypi.org/simple/ modem-info=={{ .version }}`

Note that not all dependencies can be resolved via TestPyPI.
95 changes: 95 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: Build

on:
workflow_dispatch:
pull_request_target:
branches: [main]
types: [closed]
push:

permissions:
contents: read

env:
FORCE_COLOR: 1
MYPY_FORCE_COLOR: 1
PY_COLORS: 1
TOX_TESTENV_PASSENV: >-
FORCE_COLOR
MYPY_FORCE_COLOR
NO_COLOR
PY_COLORS
PYTEST_THEME
PYTEST_THEME_MODE
TOX_PARALLEL_NO_SPINNER: 1

jobs:
test:
name: Test
uses: ./.github/workflows/test.yml

build:
name: Build
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags/release/')
needs:
- test
runs-on: ubuntu-latest
environment: build
permissions:
id-token: write
issues: write
pull-requests: write
steps:
- if: github.event.ref_type == 'tag'
uses: actions/checkout@v4
- if: github.event.ref_type != 'tag'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[build]
- name: Build
run: python -m build

- name: Get Version
id: version
shell: bash
run: |
export VERSION=$(python -c "import sys;sys.path.append('src/modem_info');from _version import version;print(version)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version=$VERSION"
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || exit 1
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
repository-url: https://test.pypi.org/legacy/

- name: Render PR Template
id: pr-template
if: github.event_name == 'pull_request_target'
uses: chuhlomin/[email protected]
with:
template: ./.github/templates/pr-build.md
vars: |
version: ${{ steps.version.outputs.version }}
- name: Update PR with Build
if: github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.pr-template.outputs.result }}
reactions: rocket
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: Release

on:
push:
tags: ["release/**"]

permissions:
contents: read

env:
FORCE_COLOR: 1
MYPY_FORCE_COLOR: 1
PY_COLORS: 1
TOX_TESTENV_PASSENV: >-
FORCE_COLOR
MYPY_FORCE_COLOR
NO_COLOR
PY_COLORS
PYTEST_THEME
PYTEST_THEME_MODE
TOX_PARALLEL_NO_SPINNER: 1

jobs:
test:
name: Test
uses: ./.github/workflows/test.yml

release:
name: Release
needs:
- test
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[build]
- name: Build
run: python -m build

- name: Get Version
id: version
shell: bash
run: |
export VERSION=$(python -c "import sys;sys.path.append('src/modem_info');from _version import version;print(version)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version=$VERSION"
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || exit 1
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true

- name: Publish to GitHub
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.version }}
generate_release_notes: true
files: "dist/*"
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: Test

on:
workflow_call:

permissions:
contents: read

env:
FORCE_COLOR: 1
MYPY_FORCE_COLOR: 1
PY_COLORS: 1
TOX_TESTENV_PASSENV: >-
FORCE_COLOR
MYPY_FORCE_COLOR
NO_COLOR
PY_COLORS
PYTEST_THEME
PYTEST_THEME_MODE
TOX_PARALLEL_NO_SPINNER: 1

jobs:
test:
name: Test
strategy:
matrix:
python:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
continue-on-error: ${{ matrix.python == '3.12' }}
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
cache: pip

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Check Types
run: mypy src

- name: Lint
run: ruff check src

- name: Format Code
run: black --check --diff --color src

- name: Test
run: modem-info --version
1 change: 1 addition & 0 deletions modem-info.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
".pytype",
"cython_debug",
"*.sublime-workspace",
".env*",
],
"file_exclude_patterns": [
"*.pyc",
Expand Down

0 comments on commit 7b43af0

Please sign in to comment.