Skip to content

Commit

Permalink
Merge pull request #669 from roflcoopter/dev
Browse files Browse the repository at this point in the history
v2.3.0 - CodeProject AI and License Plate Recognition
  • Loading branch information
roflcoopter authored Sep 14, 2023
2 parents afc209c + 7df8ee5 commit fb4428f
Show file tree
Hide file tree
Showing 249 changed files with 40,122 additions and 53,655 deletions.
85 changes: 85 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"name": "Viseron Development",
"context": "..",
"dockerFile": "../docker/Dockerfile.dev",
"postCreateCommand": ".devcontainer/setup.sh",
"overrideCommand": false,
"containerEnv": {
"DEVCONTAINER": "1",
"PUID": "1000",
"PGID": "1000"
},
"containerUser": "root",
"remoteUser": "abc",
"forwardPorts": [8888],
"portsAttributes": {
"8888": {
"label": "Viseron",
"onAutoForward": "silent"
}
},
"runArgs": ["-e", "GIT_EDITOR=code --wait"],
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort",
"ms-python.flake8",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github",
"GitHub.vscode-github-actions",
"GitHub.copilot",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"ms-azuretools.vscode-docker",
"unifiedjs.vscode-mdx"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "/usr/local/bin/flake8",
"python.linting.pycodestylePath": "/usr/local/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/bin/pydocstyle",
"python.formatting.blackPath": "/usr/local/bin/black",
"python.formatting.provider": "black",
"python.testing.pytestArgs": ["--no-cov"],
"python.linting.mypyEnabled": true,
"python.linting.mypyPath": "/usr/local/bin/mypy",
"editor.rulers": [80],
"[python]": {
"editor.rulers": [88],
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"yaml.customTags": ["!secret scalar"],
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
}
},
"features": {
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}
}
47 changes: 47 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -e

# Set workspace dir
export WORKSPACE_DIR=$PWD
echo "export WORKSPACE_DIR=$PWD" >> $HOME/.bashrc

# Install python deps
pip3 install -r requirements.txt

# Install frontend dependencies
cd $WORKSPACE_DIR/frontend
npm install

# Install pre-commit hooks
cd $WORKSPACE_DIR
pre-commit install

# Set environment variables
cd /var/run/environment
for FILE in *
do
echo "export $FILE=$(cat $FILE)" >> $HOME/.bashrc
sed -i "s/$FILE=true/$FILE=false/g" $HOME/.bashrc
done

# Symlink config
cd $WORKSPACE_DIR
mkdir -p $WORKSPACE_DIR/config
FILE=$WORKSPACE_DIR/config/config.yaml
if test -f "$FILE"; then
echo "Config file already exists"
else
echo "Creating default config"
python3 -c "import viseron.config; viseron.config.create_default_config('$FILE')"
fi
ln -s $WORKSPACE_DIR/config/config.yaml /config/config.yaml

# Create .env.local
FILE=$WORKSPACE_DIR/frontend/.env.local
if test -f "$FILE"; then
echo "Frontend .env.local already exists"
else
echo "Creating frontend .env.local"
echo "VITE_PROXY_HOST=localhost:8888" > $FILE
fi
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*
!/.coveragerc
!/.devcontainer/
!/.devcontainer/*
!tests/
!tests/*
!viseron/
Expand Down
21 changes: 21 additions & 0 deletions .github/templates/run_in_venv/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: run_in_venv
description: Set Python symlink and activate venv

inputs:
command:
required: true
description: The command to run in the venv

runs:
using: "composite"
steps:
- name: Set Python symlink and activate venv
shell: bash
run: |
PYTHON_PATH=$(which python3)
source venv/bin/activate
PYTHON_BROKEN_PATH=$(dirname $(which pip))
rm $PYTHON_BROKEN_PATH/python
ln -s $PYTHON_PATH $PYTHON_BROKEN_PATH/python
export PATH=$PATH:$(dirname $PYTHON_BROKEN_PATH)
${{ inputs.command }}
72 changes: 72 additions & 0 deletions .github/workflows/ci-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI Frontend

on:
push:
branches:
- dev
- master
pull_request: ~

env:
NODE_VERSION: 16

defaults:
run:
working-directory: ./frontend

jobs:
lint:
name: Lint and check format
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run eslint
run: npm run lint:eslint
- name: Run prettier
run: npm run lint:prettier
- name: Run tsc
run: npm run lint:types

test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test

build:
name: Build frontend
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/[email protected]
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run build
run: npm run build
Loading

0 comments on commit fb4428f

Please sign in to comment.