Skip to content

Commit

Permalink
chore: split CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dtch1997 committed May 9, 2024
1 parent 83d75ce commit fc93eb5
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 90 deletions.
89 changes: 0 additions & 89 deletions .github/workflows/build_and_release.yaml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "release"
on:
workflow_run:
workflows: ["tests"]
types:
- completed

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
environment:
# Same environment name configured in PyPI trusted publisher
name: pypi
concurrency: release

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
cache: true
python-version: "3.11"
- name: Install dependencies
run: pdm install
- name: Build
run: pdm build
- name: Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'
- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@main
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "tests"
on:
pull_request:
branches:
- main
push:
branches:
- main

# Allow this workflow to be called from other workflows
workflow_call:
inputs:
# Requires at least one input to be valid, but in practice we don't need any
dummy:
type: string
required: false

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
cache: true
python-version: ${{ matrix.python-version }}
- name: Cache Huggingface assets
uses: actions/cache@v4
with:
key: huggingface-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
path: ~/.cache/huggingface
restore-keys: |
huggingface-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
run: pdm install
- name: check formatting
run: pdm run ruff format --check
- name: check linting
run: pdm run ruff check
- name: check types
run: pdm run pyright
- name: test
run: pdm run pytest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PDM Python Project Template
![Github Actions](https://github.com/90HH/pdm-python-project-template/actions/workflows/build_and_release.yaml/badge.svg)
![Github Actions](https://github.com/90HH/pdm-python-project-template/actions/workflows/tests.yaml/badge.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm-project.org)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
Expand Down

0 comments on commit fc93eb5

Please sign in to comment.