Skip to content

Commit

Permalink
Merge branch 'main' into code-cleanup-db
Browse files Browse the repository at this point in the history
  • Loading branch information
devenderbutani21 authored May 5, 2024
2 parents 8d23ed2 + b85a392 commit f7ab138
Show file tree
Hide file tree
Showing 64 changed files with 946 additions and 573 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/push_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ on:
# release:
push:
tags:
- '*'
workflow_dispatch: # Allow manual invocation of the workflow

- 'v*'
workflow_dispatch: # Allows me to manually call
inputs:
version:
type: string
description: Version
required: true
jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -20,9 +24,14 @@ jobs:
with:
persist-credentials: false

- name: Get the tag version
id: get_version
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
- name: Set version
id: set_version
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "::set-output name=version::${{ github.event.inputs.version }}"
fi
#----------------------------------------------
# build Frontend files
Expand All @@ -39,10 +48,16 @@ jobs:
echo "output.css is not created"
exit 1
fi
if [ -f frontend/static/js/bundle.js ] && [ -f frontend/static/js/bundle.js.map ]; then
echo "bundle.js and bundle.js.map are created"
if [ -d frontend/static/js/c/ ]; then
echo "webpack has been built"
else
echo "frontend/static/js/c/ was not created from webpack build"
exit 1
fi
if [ -f webpack-stats.json ]; then
echo "webpack has built webpack-stats to work with chunks"
else
echo "bundle.js and/or bundle.js.map are not created"
echo "webpack-stats was not built so cannot work with chunks"
exit 1
fi
Expand All @@ -66,9 +81,10 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ steps.get_version.outputs.TAG_NAME }} #${{ github.sha }}
IMAGE_TAG: ${{ steps.set_version.outputs.version }} #${{ github.sha }}
run: |
cp infrastructure/backend/Dockerfile ./Dockerfile
echo "VERSION IS: ${{ steps.set_version.outputs.version }} or $IMAGE_TAG"
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Expand Down
86 changes: 0 additions & 86 deletions .github/workflows/run_tests.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/stale_prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

permissions:
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
days-before-pr-stale: 10
days-before-pr-close: 5
days-before-issue-close: -1
days-before-issue-stale: -1
exempt-assignees: treyww
82 changes: 82 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Backend Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
django-version: ["4", "5"]
steps:
- name: Clone repo
uses: actions/[email protected]
- name: Set up python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.0
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install django ${{ matrix.django-version }}
run: |
source .venv/bin/activate
pip install "Django==${{ matrix.django-version }}"
- name: Install dependencies and build frontend
run: |
npm ci
npm run tailwind-build
npm run webpack-build
if [ -f frontend/static/src/output.css ]; then
echo "output.css is created"
else
echo "output.css is not created"
exit 1
fi
if [ -d frontend/static/js/c/ ]; then
echo "webpack has been built"
else
echo "frontend/static/js/c/ was not created from webpack build"
exit 1
fi
if [ -f webpack-stats.json ]; then
echo "webpack has built webpack-stats to work with chunks"
else
echo "webpack-stats was not built so cannot work with chunks"
exit 1
fi
- name: Run tests
env:
SECRET_KEY: "some!random!secret!key!use!online!generator!to!get"
URL: "127.0.0.1"
PROXY_IP: "localhost"
BRANCH: "debug"
DEBUG: "true"
DATABASE_TYPE: "sqlite3"
SITE_URL: "http://myfinances.example.com"
SITE_NAME: "myfinances"
run: |
source .venv/bin/activate
python3 manage.py collectstatic --no-input
python3 manage.py test --parallel
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Writerside/**
frontend/static/src/output.css
frontend/static/js/bundle.js
frontend/static/js/bundle.js.map
frontend/static/js/c/*

# Webpack
webpack-stats.json

# Pulumi
infrastructure/aws/pulumi/Pulumi.dev.yaml
Expand Down
4 changes: 4 additions & 0 deletions assets/scripts/font_awesome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import '@fortawesome/fontawesome-free/js/fontawesome'
import '@fortawesome/fontawesome-free/js/solid'
import '@fortawesome/fontawesome-free/js/regular'
import '@fortawesome/fontawesome-free/js/brands'
50 changes: 50 additions & 0 deletions assets/scripts/htmx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'htmx.org';
import 'hyperscript.org';

window.htmx = require('htmx.org');
window._hyperscript = require('hyperscript.org');
window._hyperscript.browserInit();

function htmx_resend(event) {
let eventType;

if (event.detail.statusCode === 403) {
return // forbidden
}

if (event.detail.requestConfig.triggeringEvent) {
eventType = event.detail.requestConfig.triggeringEvent.type
} else {
eventType = "retry"
}

let timeout;

if (event.detail.error.includes("429")) {
timeout = 4000;
} else {
timeout = 2000;
}

setTimeout(function () {
console.log("Sending HTMX retry event")
htmx.trigger(event.detail.elt, eventType);
}, timeout);
}

// https://htmx.org/docs/#config
htmx.config.globalViewTransitions = true
htmx.config.useTemplateFragments = true // for swapping of table items


window.addEventListener("DOMContentLoaded", (event) => {
document.body.addEventListener("htmx:sendError", htmx_resend);
document.body.addEventListener("htmx:responseError", htmx_resend);
document.body.addEventListener("htmx:loadError", htmx_resend);
document.body.addEventListener("htmx:afterRequest", (event) => {
const drawer = document.getElementById("service_list_drawer");
if (drawer) {
toggleDrawer(false, true);
}
});
});
43 changes: 32 additions & 11 deletions assets/scripts/init.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import 'htmx.org';
import 'hyperscript.org';

import '@fortawesome/fontawesome-free/js/fontawesome'
import '@fortawesome/fontawesome-free/js/solid'
import '@fortawesome/fontawesome-free/js/regular'
import '@fortawesome/fontawesome-free/js/brands'
import Alpine from 'alpinejs'
import $ from 'jquery'


window.htmx = require('htmx.org')
window._hyperscript = require('hyperscript.org');
window._hyperscript.browserInit();
window.Alpine = Alpine

Alpine.start()

window.jQuery = $;
window.$ = $;
window.$ = $;

document.addEventListener("DOMContentLoaded", function () {
const drawer = document.getElementById("service_list_drawer");
const service_list_toggler = document.getElementById("service_list_toggler");
const logo_single_service_list_toggler = document.getElementById("logo_single_service_list_toggler");
var togglers = document.querySelectorAll("#service_list_togglers");

window.toggleDrawer = function toggleDrawer(value, with_drawer = false) {
toggleDrawerSurrounds(value)

if (with_drawer) {
drawer.checked = value
}
}

window.toggleDrawerSurrounds = function toggleDrawerSurrounds(state) {
service_list_toggler.checked = state;
logo_single_service_list_toggler.checked = state;

for (let i = 0; i < togglers.length; i++) {
togglers[i].checked = state
}
}


drawer.addEventListener("change", function () {
toggleDrawerSurrounds(drawer.checked)
});
});
Loading

0 comments on commit f7ab138

Please sign in to comment.