-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'codeforboston:main' into main
- Loading branch information
Showing
25 changed files
with
639 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
name: whole heat-stack | ||
on: | ||
push: | ||
branches: | ||
- main | ||
# - dev | ||
pull_request: {} | ||
|
||
env: | ||
working-directory: heat-stack | ||
|
||
defaults: | ||
run: | ||
working-directory: heat-stack | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
name: ⬣ ESLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
working-directory: ${{ env.working-directory }} | ||
|
||
- name: 🖼 Build icons | ||
working-directory: ${{ env.working-directory }} | ||
run: npm run build:icons | ||
|
||
- name: 🔬 Lint | ||
working-directory: ${{ env.working-directory }} | ||
run: npm run lint | ||
|
||
|
||
typecheck: | ||
name: ʦ TypeScript | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
working-directory: ${{ env.working-directory }} | ||
|
||
- name: 🖼 Build icons | ||
run: npm run build:icons | ||
|
||
- name: 🔎 Type check | ||
run: npm run typecheck --if-present | ||
|
||
vitest: | ||
name: ⚡ Vitest pyodide.test.ts | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: 📥 Download deps | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
working-directory: ${{ env.working-directory }} | ||
|
||
- name: 🏄 Copy test env vars | ||
run: cp .env.example .env | ||
|
||
- name: 🖼 Build icons | ||
run: npm run build:icons | ||
|
||
- name: ⚡ Run vitest | ||
run: npm run test app/utils/pyodide.test.ts -- --coverage | ||
|
||
# playwright tests work great but slight jank/inconsistency passing, and not used yet, so disabling for now | ||
# playwright: | ||
# name: 🎭 Playwright | ||
# runs-on: ubuntu-latest | ||
# timeout-minutes: 60 | ||
# steps: | ||
# - name: ⬇️ Checkout repo | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: 🏄 Copy test env vars | ||
# run: cp .env.example .env | ||
|
||
# - name: ⎔ Setup node | ||
# uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: 18 | ||
|
||
# - name: 📥 Download deps | ||
# uses: bahmutov/npm-install@v1 | ||
# with: | ||
# working-directory: ${{ env.working-directory }} | ||
|
||
# - name: 📥 Install Playwright Browsers | ||
# run: npm run test:e2e:install | ||
|
||
# - name: 🛠 Setup Database | ||
# run: npx prisma migrate deploy | ||
|
||
# - name: 🏦 Cache Database | ||
# id: db-cache | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: prisma/data.db | ||
# key: | ||
# db-cache-schema_${{ hashFiles('./prisma/schema.prisma') | ||
# }}-migrations_${{ hashFiles('./prisma/migrations/*/migration.sql') | ||
# }} | ||
|
||
# - name: 🌱 Seed Database | ||
# if: steps.db-cache.outputs.cache-hit != 'true' | ||
# run: npx prisma db seed | ||
# env: | ||
# MINIMAL_SEED: true | ||
|
||
# - name: 🏗 Build | ||
# run: npm run build | ||
|
||
# - name: 🎭 Playwright tests | ||
# run: npx playwright test | ||
|
||
# - name: 📊 Upload report | ||
# uses: actions/upload-artifact@v3 | ||
# if: always() | ||
# with: | ||
# name: playwright-report | ||
# path: playwright-report/ | ||
# retention-days: 30 | ||
|
||
# deploy: | ||
# name: 🚀 Deploy | ||
# runs-on: ubuntu-latest | ||
# needs: [lint, typecheck, vitest, playwright] | ||
# # only build/deploy main branch on pushes | ||
# if: | ||
# ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && | ||
# github.event_name == 'push' }} | ||
|
||
# steps: | ||
# - name: ⬇️ Checkout repo | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: 👀 Read app name | ||
# uses: SebRollen/[email protected] | ||
# id: app_name | ||
# with: | ||
# file: 'fly.toml' | ||
# field: 'app' | ||
|
||
# # move Dockerfile to root | ||
# - name: 🚚 Move Dockerfile | ||
# run: | | ||
# mv ./other/Dockerfile ./Dockerfile | ||
# mv ./other/.dockerignore ./.dockerignore | ||
|
||
# - name: 🎈 Setup Fly | ||
# uses: superfly/flyctl-actions/[email protected] | ||
|
||
# - name: 🚀 Deploy Staging | ||
# if: ${{ github.ref == 'refs/heads/dev' }} | ||
# run: | ||
# flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} | ||
# --app ${{ steps.app_name.outputs.value }}-staging | ||
# env: | ||
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
|
||
# - name: 🚀 Deploy Production | ||
# if: ${{ github.ref == 'refs/heads/main' }} | ||
# run: | ||
# flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} | ||
# env: | ||
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public/pyodide-env/ | ||
public/build | ||
build/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as pyodideModule from 'pyodide' | ||
import { expect, test } from 'vitest' | ||
|
||
/* For this to pass, you must run | ||
`pushd ../rules-engine && python3 -m venv venv && source venv/bin/activate && pip install -q build && python3 -m build && popd` */ | ||
|
||
/* Referenced https://github.com/epicweb-dev/full-stack-testing/blob/main/exercises/04.unit-test/02.solution.spies/app/utils/misc.error-message.test.ts of https://www.epicweb.dev/workshops/web-application-testing*/ | ||
test('pyodide loads', async () => { | ||
const getPyodide = async () => { | ||
// public folder: | ||
return await pyodideModule.loadPyodide({ | ||
indexURL: 'public/pyodide-env/', | ||
}) | ||
} | ||
const runPythonScript = async () => { | ||
const pyodide: any = await getPyodide() | ||
// console.log(engine); | ||
await pyodide.loadPackage('numpy') | ||
|
||
/* NOTES for pyodide-core: | ||
need to be a special version from the release page, no pure whl: https://github.com/pydantic/pydantic-core/pull/128 | ||
get it from https://github.com/pydantic/pydantic-core/releases e.g. https://github.com/pydantic/pydantic-core/releases/download/v2.14.5/pydantic_core-2.14.5-cp311-cp311-emscripten_3_1_32_wasm32.whl | ||
*/ | ||
await pyodide.loadPackage( | ||
'public/pyodide-env/pydantic_core-2.14.5-cp311-cp311-emscripten_3_1_32_wasm32.whl', | ||
) | ||
|
||
/* NOTES for pydantic, typing-extensions, annotated_types: | ||
pyodide should match pyodide-core somewhat. | ||
typing-extensions needs specific version per https://github.com/pyodide/pyodide/issues/4234#issuecomment-1771735148 | ||
try getting it from | ||
- https://pypi.org/project/pydantic/#files | ||
- https://pypi.org/project/typing-extensions/ | ||
- https://pypi.org/project/annotated-types/#files | ||
*/ | ||
await pyodide.loadPackage( | ||
'public/pyodide-env/pydantic-2.5.2-py3-none-any.whl', | ||
) | ||
await pyodide.loadPackage( | ||
'public/pyodide-env/typing_extensions-4.8.0-py3-none-any.whl', | ||
) | ||
await pyodide.loadPackage( | ||
'public/pyodide-env/annotated_types-0.5.0-py3-none-any.whl', | ||
) | ||
|
||
/* NOTES FOR DEBUGGING new requirements.txt | ||
and getting specific versions of pure whl */ | ||
// the below works but uses the internet/pypi content delivery network rather than localhost. | ||
// await pyodide.loadPackage('micropip') | ||
// const micropip = await pyodide.pyimport('micropip') | ||
// await micropip.install([ | ||
// 'typing-extensions==4.8.0', | ||
// 'pydantic_core==2.14.5', | ||
// 'pydantic==2.5.2', | ||
// ]) | ||
// await micropip.install(['annotated-types']) | ||
|
||
await pyodide.loadPackage( | ||
'../rules-engine/dist/rules_engine-0.0.1-py3-none-any.whl', | ||
) | ||
return pyodide | ||
} | ||
// consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/tests/test_rules_engine/test_engine.py | ||
const pyodide: any = await runPythonScript() | ||
const result = await pyodide.runPythonAsync(` | ||
from rules_engine import engine | ||
out = engine.hdd(57, 60) | ||
out`) | ||
expect(result).toBe(3) | ||
}, 6000) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.