Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github workflow for PRs #13

Merged
merged 11 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/black-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Black Auto-Reformat

on:
pull_request:
branches:
- main
paths:
- '**.py'

jobs:
black-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install Black
run: |
pip install --upgrade pip
pip install black

- name: Format with Black
run: |
CHANGED_FILES=$(git diff --name-only HEAD^..HEAD | grep -E '\.(py)$' || true)
echo "Changed files: ${CHANGED_FILES}"
if [ ! -z "$CHANGED_FILES" ]; then
black $CHANGED_FILES
fi

- name: Commit and Push Changes
if: success() && github.ref != 'refs/heads/main'
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add .
# Check if there are any changes to commit
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Apply Black Formatting"
BRANCH_NAME=${GITHUB_HEAD_REF:-$(git rev-parse --abbrev-ref HEAD)}
git push origin HEAD:$BRANCH_NAME
fi
32 changes: 32 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python Unit Tests

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install msgpack # TODO: Update this as we update requirements.txt
python setup.py install
Comment on lines +26 to +28
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason, if I leave pip install msgpack out, it fails:
https://github.com/sangkeun00/analog/actions/runs/6919422313/job/18822772616
hence, I am installing this separately. When we give versioning to the requirements.txt we would have to change it here to. I am leaving TODO.


- name: Run All Tests
run: |
python -m unittest discover -s tests -p '*_test.py'