Skip to content

Commit

Permalink
Refactor to use common CD/CI actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-f-cruz committed Dec 27, 2024
1 parent fc007f8 commit 70842db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 119 deletions.
71 changes: 13 additions & 58 deletions generic/{{cookiecutter.repository_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI
name: ci/cd

on:
workflow_dispatch:
pull_request:
branches:
- main
Expand All @@ -9,61 +10,15 @@ on:
- main

jobs:
linters:
runs-on: windows-latest
name: Lint ${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --extra dev
- name: Run ruff format
run: uv run ruff format .
- name: Run ruff check
run: uv run ruff check .
- name: Run codespell
run : uv run codespell .

tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: 8.x
- name: Restore dotnet tools
run: dotnet tool restore
- name: Setup Bonsai
working-directory: bonsai
run: .\Setup.ps1

- uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
run: uv python install


- name: Install dependencies
run: uv sync --extra dev
- name: Run tests
run: uv run -m unittest
- name: Regenerate schemas
run: uv run regenerate
- name: Check for uncommitted changes
run: |
git config --global core.safecrlf false
git diff --exit-code || (echo "Untracked changes found" && exit 1)
python-linting:
uses: AllenNeuralDynamics/Aind.Behavior.GitHubActions/.github/workflows/python-linting.yml@main
with:
runs-on: ubuntu-latest

aind-behavior-framework-testing:
uses: AllenNeuralDynamics/Aind.Behavior.GitHubActions/.github/workflows/test-aind-behavior-framework.yml@main
with:
python-version-path: .python-version
run-coverage: false
run-schema: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,7 @@ on:
workflow_dispatch: {}

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin ${{ env.DEFAULT_BRANCH }}
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python
run: uv python install

- name: Extract version from __init__.py and package name from pyproject.toml
id: get_version_and_name
run: |
package_name=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")
package_name=${package_name//-/_}
version=$(uv run python -c "import re;
with open(f'./src/${package_name}/__init__.py', 'r') as f:
content = f.read();
match = re.search(r'__version__\s*=\s*[\'\"]([^\'\"]+)[\'\"]', content);
print(match.group(1)) if match else exit(1)")
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV
shell: bash

- name: Create Git tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a v${{ env.PACKAGE_VERSION }} -m "v${{ env.PACKAGE_VERSION }}"
git push origin v${{ env.PACKAGE_VERSION }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.SERVICE_TOKEN }}
tag_name: v${{ env.PACKAGE_VERSION }}
name: Release v${{ env.PACKAGE_VERSION }}
generate_release_notes: true

# publish:
# needs: tag
# if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Pull latest changes
# run: git pull origin ${{ env.DEFAULT_BRANCH }}
# - uses: astral-sh/setup-uv@v3
# with:
# enable-cache: true

# - name: Set up Python
# run: uv python install

# - name: Build
# run: uv build

# - name: Publish
# run: uv publish --token ${{ secrets.AIND_PYPI_TOKEN }}
tag-and-publish:
uses : AllenNeuralDynamics/Aind.Behavior.GitHubActions/.github/workflows/python-package-tag-and-publish.yml@main
with:
publish: false

0 comments on commit 70842db

Please sign in to comment.