Skip to content

Commit

Permalink
Add PDM and Dependencies actions
Browse files Browse the repository at this point in the history
Update build-docs workflow

Add cache-dependencies workflow

Update cleanup-firebase workflow

Update ci workflow

Update analyze workflow

Update analyze workflow
  • Loading branch information
mogres committed Oct 17, 2024
1 parent a886834 commit e5e4ee0
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 65 deletions.
11 changes: 11 additions & 0 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: PDM & Dependencies
description: Install PDM and dependencies
runs:
using: composite
steps:
- uses: ./.github/actions/pdm

- name: Install dependencies
shell: bash
# --only-keep flag in case the environment is restored from a stale cache.
run: pdm sync -d --only-keep
11 changes: 11 additions & 0 deletions .github/actions/pdm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: PDM
description: Install PDM
runs:
using: composite
steps:
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.9"
# Cache all dependencies installed from pdm.lock
cache: true
16 changes: 4 additions & 12 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: setup.py
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[all]
- uses: ./.github/actions/dependencies
- name: Pack test recipe
shell: bash
run: |
pack -r cellpack/tests/recipes/v2/test_spheres.json -c cellpack/tests/packing-configs/test_config.json
- name: Modify JSON with PR sub_directory path
Expand All @@ -36,7 +28,7 @@ jobs:
- name: Run analysis code
run: analyze -r cellpack/tests/recipes/v2/test_spheres.json -a cellpack/tests/analysis-configs/PR_analysis_config.json -p cellpack/tests/outputs/test_spheres/spheresSST
- name: Upload results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: results
path: cellpack/tests/outputs/test_spheres/
Expand All @@ -59,7 +51,7 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
- name: Copy files to results bucket
run: aws s3 cp ./results s3://cellpack-results/${{ github.ref_name }}/ --recursive --acl public-read
- uses: iterative/setup-cml@v1
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@ jobs:
if: ${{ !contains(github.event.head_commit.message, 'Bump version') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.1
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: setup.py
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install .[dev]
- uses: ./.github/actions/dependencies
- name: Generate Docs
run: |
make gen-docs
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/cache-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The purpose of this workflow is to get more cache hits when other workflows build dependencies.
# Github actions do not share caches between branches, except that all branches can pull results
# from the default (main) branch. Therefore, this workflow runs on the main branch to keep the
# latest dependencies cached for other branches to use.
# Branches that change the dependencies will still get cache misses.
name: Build and cache dependencies on main

on:
push:
branches:
- main

jobs:
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/dependencies
38 changes: 4 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: setup.py
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[all]
- uses: ./.github/actions/dependencies
- name: Test with pytest
run: |
pytest --cov cellpack/tests/
Expand All @@ -52,16 +43,7 @@ jobs:
if: ${{ !contains(github.event.head_commit.message, 'Bump version') }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: setup.py
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- uses: ./.github/actions/dependencies
- name: Lint with flake8
run: |
flake8 cellpack --count --verbose --show-source --statistics --ignore=E501,E277,W503,E203
Expand All @@ -81,19 +63,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: setup.py
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build Package
run: |
python setup.py sdist bdist_wheel
- uses: ./.github/actions/dependencies
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
run: pdm publish

9 changes: 1 addition & 8 deletions .github/workflows/cleanup-firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[all]
- uses: ./.github/actions/dependencies
- name: Cleanup Firebase Metadata
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/make-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Make requirements files

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "pdm.lock"

jobs:
make-requirements:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/pdm

- name: Generate requirements.txt
shell: bash
run: |
case "${{ matrix.os }}" in
"ubuntu-latest")
export PLATFORM="linux"
;;
"macOS-latest")
export PLATFORM="macos"
;;
"windows-latest")
export PLATFORM="windows"
;;
esac
rm -rf requirements/*
mkdir -p requirements/$PLATFORM
pdm requirements requirements/$PLATFORM/requirements.txt
- name: Get platform variable
id: platform
shell: bash
run: |
case "${{ matrix.os }}" in
"ubuntu-latest")
echo "::set-output name=platform::linux"
;;
"macOS-latest")
echo "::set-output name=platform::macos"
;;
"windows-latest")
echo "::set-output name=platform::windows"
;;
esac
- name: Upload requirements files
uses: actions/upload-artifact@v4
with:
name: ${{ steps.platform.outputs.platform }}-requirements
path: requirements/${{ steps.platform.outputs.platform }}

open-PR:
needs: [make-requirements]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download linux requirements files
uses: actions/download-artifact@v4
with:
name: linux-requirements
path: requirements/linux

- name: Download windows requirements files
uses: actions/download-artifact@v4
with:
name: windows-requirements
path: requirements/windows

- name: Download macOS requirements files
uses: actions/download-artifact@v4
with:
name: macos-requirements
path: requirements/macos

- name: Clean-up CRLF
shell: bash
run: find requirements -type f -exec sed -i 's/\r//g' {} \;

- name: Get timestamp
id: timestamp
run: echo "::set-output name=timestamp::$(date +'%Y-%m-%d_%H-%M')"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
base: main
title: admin/requirements-update_${{ steps.timestamp.outputs.timestamp }}
body: Updating requirements.txt.

Due to some [challenges](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs),
with getting this PR to trigger the tests, please manually close and re-open this PR.
branch: admin/requirements-update_${{ steps.timestamp.outputs.timestamp }}
commit-message: Updating requirements.txt after change to `pdm.lock` was pushed to `main`
delete-branch: true

0 comments on commit e5e4ee0

Please sign in to comment.