Skip to content

Commit

Permalink
feat: store history of scores for example products (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulboosz authored Jun 26, 2024
1 parent cf88121 commit 999d1e7
Show file tree
Hide file tree
Showing 5 changed files with 850 additions and 132 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/score_history.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Score History

on:
push:
branches:
- '*'
workflow_dispatch:

jobs:
score_history:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
python-version: [3.11]

# Run the job manually, on push to master or if the commit contains "[score_history]"
if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[score_history]') }}
steps:

- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('package.json', 'package-lock.json') }}

- name: Cache ~/.elm
# see https://docs.microsoft.com/en-us/answers/questions/510640/deploy-elm-app-to-azure-static-website-from-github.html
uses: actions/cache@v4
with:
path: ~/.elm
key: elm-cache-${{ hashFiles('elm.json') }}
restore-keys: elm-cache-

- name: Cache pipenv virtualenv
uses: actions/cache@v4
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pipenv-
- name: Install Node dependencies
run: npm ci --prefer-offline --no-audit

- name: Install Python dependencies
run: pip install pipenv && pipenv install


- name: Install Ubuntu dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext
- name: Install dependencies
run: pip install numpy pandas requests python-dotenv GitPython sqlalchemy psycopg2

- name: Score History
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
LAST_COMMIT_HASH: ${{ github.sha }}
SCALINGO_POSTGRESQL_SCORE_URL: ${{ secrets.SCALINGO_POSTGRESQL_SCORE_URL }}
DJANGO_BYPASS_AUTH: True
NODE_ENV: "test"
run: |
npm run server:build
npm run server:start &
npm run start:backend &
for attempt in {1..20}; do sleep 1; if curl -s http://localhost:8001/ > /dev/null; then echo "-> Node server is up and ready on port 8001"; break; fi; echo "-> Waiting for the Node server to boot..."; done
for attempt in {1..20}; do sleep 1; if curl -s http://localhost:8002/ > /dev/null; then echo "-> Python server is up and ready on port 8002"; break; fi; echo "-> Waiting for the Python server to boot..."; done
python data/common/score_history/score_history.py http://localhost:8001 $GITHUB_REF_NAME $LAST_COMMIT_HASH $SCALINGO_POSTGRESQL_SCORE_URL
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ name = "pypi"
django = ">=5,<6"
django-mail-auth = ">=3.2,<3.3"
gunicorn = ">=22,<23"
psycopg = ">=3.1,<3.2"
psycopg2 = "2.9.9"
python-decouple = ">=3,<4"
ruff = "*"
SQLAlchemy = "2.0.30"
pandas = "1.5.3"
GitPython = "3.1.43"
pre-commit = "*"

[dev-packages]
Loading

0 comments on commit 999d1e7

Please sign in to comment.