Skip to content

Commit

Permalink
CI workflows for code quality, testing and release (#18)
Browse files Browse the repository at this point in the history
* Add workflow for code quality checks
* Add workflow for test execution
* Add workflow to test build packages
* Add workflow to publish release packages to PyPI
  • Loading branch information
cstub authored Jan 15, 2025
1 parent e5a68de commit 2bd679f
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Code Quality

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
code-quality-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}

- name: Run pre-commit
uses: pre-commit/[email protected]
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release Package

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'

jobs:
release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Verify current tag is on main branch
run: |
# Exit with error if current tag is not on main
git merge-base --is-ancestor ${{ github.sha }} origin/main || exit 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}

- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ vars.CI_POETRY_VERSION }}

- name: Install Poetry plugins
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build package
run: |
poetry build
ls -la dist/
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
retention-days: 1

pypi-publish:
runs-on: ubuntu-latest

needs:
- release-build

permissions:
id-token: write

environment:
name: pypi
url: https://pypi.org/project/freeact

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Cache conda
uses: actions/cache@v4
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
environment-file: environment.yml

- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ vars.CI_POETRY_VERSION }}

- name: Install dependencies
shell: bash -l {0}
run: |
poetry env info
poetry install
pip list
- name: Run tests
shell: bash -l {0}
run: |
poetry run pytest -s tests
101 changes: 101 additions & 0 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Package Installation Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
package-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}

- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ vars.CI_POETRY_VERSION }}

- name: Install Poetry plugins
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build package
run: |
poetry build
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1

package-test:
needs: package-build

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.12']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download package
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Test wheel installation (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$wheel = Get-ChildItem dist/*.whl | Select-Object -First 1
pip install $wheel
python -c "import freeact"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
pip uninstall -y freeact
- name: Test wheel installation (Unix)
if: runner.os != 'Windows'
run: |
pip install dist/*.whl
python -c "import freeact"
pip uninstall -y freeact
- name: Test tarball installation (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$tarball = Get-ChildItem dist/*.tar.gz | Select-Object -First 1
pip install $tarball
python -c "import freeact"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
pip uninstall -y freeact
- name: Test tarball installation (Unix)
if: runner.os != 'Windows'
run: |
pip install dist/*.tar.gz
python -c "import freeact"
pip uninstall -y freeact
6 changes: 6 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ conda env create -f environment.yml
conda activate freeact
```

Install the poetry dynamic versioning plugin:

```bash
poetry self add "poetry-dynamic-versioning[plugin]"
```

Install dependencies with Poetry:

```bash
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry]
name = "freeact"
version = "0.2.3"
version = "0.0.0"
description = "A general-purpose CodeAct Agent"
homepage = "https://github.com/gradion-ai/freeact"
readme = "README.md"
Expand Down Expand Up @@ -78,3 +78,9 @@ module = [
"yaml"
]
ignore_missing_imports = true

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
pattern = "default-unprefixed"
style = "pep440"

0 comments on commit 2bd679f

Please sign in to comment.