Skip to content

Commit

Permalink
Add PR review action
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Aug 14, 2024
1 parent a122352 commit 3b1f4ab
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/review_pull_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pandas as pd
from policyengine_us_data.data_storage import STORAGE_FOLDER
from IPython.display import Markdown

def main():
df = pd.read_csv(STORAGE_FOLDER / "evaluation.csv")

most_recent_rows = df[df.Date == df.Date.max()].sort_values(["Variable", "Time period"]).set_index(["Variable", "Time period"]).Total
second_most_recent_rows = df[df.Date == df.Date.sort_values().unique()[-2]].reset_index(drop=True).sort_values(["Variable", "Time period"]).set_index(["Variable", "Time period"]).Total

diff = (most_recent_rows - second_most_recent_rows)
# Convert to df
diff = diff.reset_index()
table = diff.to_markdown(index=False)

review_text = f"""## National projection changes\n\n{table}"""

print(review_text)

if __name__ == "__main__":
main()
32 changes: 32 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pull request

on:
pull_request:
branches:
- main

jobs:
build:
name: Build and test
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Install dependencies
run: make install

- name: Run tests
run: make test

- name: Run evaluation
run: make evaluate

- name: Add review comment
run: python .github/review_pull_request.py
2 changes: 1 addition & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: make evaluate

- name: Upload evaluation
run: python .github/upload_evaluation
run: python .github/upload_evaluation.py

0 comments on commit 3b1f4ab

Please sign in to comment.