Skip to content

Commit

Permalink
test: Attempt dry-run of GitHub Actions and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
anth-volk committed Aug 15, 2024
1 parent d4a425a commit 98f6e54
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Pull request

on: pull_request
on:
pull_request:
branches:
- feat/cloud_run
- master

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/push_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Push

on:
push:
branches:
- feat/cloud_run

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.POLICYENGINE_DOCKER }}
- name: Build container
run: docker build -t ghcr.io/policyengine/policyengine docker
- name: Push container
run: docker push ghcr.io/policyengine/policyengine
deploy:
name: Deploy API to Cloud Run
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: GCP authentication
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_SA_KEY }}"
- name: Set up GCloud
uses: "google-github-actions/setup-gcloud@v1"
- name: Deploy
run: make deploy
env:
POLICYENGINE_DB_PASSWORD: ${{ secrets.POLICYENGINE_DB_PASSWORD }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN: ${{ secrets.POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ format:

deploy:
python gcp/export.py
gcloud config set app/cloud_build_timeout 1800
cp gcp/policyengine_api/* .
y | gcloud app deploy --service-account=github-deployment@policyengine-api.iam.gserviceaccount.com
rm app.yaml
rm Dockerfile
gcloud run services replace service.yaml
# gcloud config set app/cloud_build_timeout 1800
# cp gcp/policyengine_api/* .
# y | gcloud app deploy --service-account=github-deployment@policyengine-api.iam.gserviceaccount.com
# rm app.yaml
# rm Dockerfile
rm .gac.json
rm .dbpw

Expand Down
1 change: 1 addition & 0 deletions gcp/policyengine_api/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
runtime: custom
service: default
env: flex
resources:
cpu: 16
Expand Down
58 changes: 58 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ['POLICYENGINE_DB_PASSWORD'] = \"bokwen-4fedhu-disfIj\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from policyengine_us import Microsimulation\n",
"from policyengine_core.reforms import Reform\n",
"\n",
"reform = Reform.from_dict({\n",
" \"gov.irs.credits.eitc.max[0].amount\": {\n",
" \"2024-01-01.2100-12-31\": 95000\n",
" }\n",
"}, country_id=\"us\")\n",
"\n",
"\n",
"baseline = Microsimulation(dataset=\"enhanced_cps_2022\")\n",
"reformed = Microsimulation(reform=reform, dataset=\"enhanced_cps_2022\")\n",
"baseline_person = baseline.calculate(\"household_net_income\", period=2024, map_to=\"person\")\n",
"reformed_person = reformed.calculate(\"household_net_income\", period=2024, map_to=\"person\")\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "test-pkg-api",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 98f6e54

Please sign in to comment.