Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mshim03 committed Sep 29, 2023
0 parents commit 9f53264
Show file tree
Hide file tree
Showing 255 changed files with 67,208 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
WEBUI_URL=http://localhost
DB_USER=postgres
DB_PASSWORD=your_secret_password
DB_HOST=db
DB_PORT=5432
DB_SCHEMA=postgres
FIREBASE_API_KEY=
FIREBASE_CRED=/key/firebase_credentials.json
TESTDB_HOST=testdb
FLASHSENSE_API_URL=http://flashsense.api.url.example/api
SYSTEM_EMAIL=
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## PR の目的

- 機能追加の場合
- #xxx yyy を可能にする(xxx は issue 番号)
- バグ改修の場合
- #xxx yyy のため、zzz を修正(xxx は issue 番号)

## 経緯・意図・意思決定

このプルリクエストに至った経緯や背景情報や事情、
また実装の際に考慮したこと、意思決定があれば記述する。

このプルリクエストの対象外とした内容があるならば、その理由も含めて記述する。

## 参考文献
27 changes: 27 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint GitHub Actions workflows
"on":
pull_request:
branches:
- main
paths:
- .github/workflows/**
push:
branches:
- main
paths:
- .github/workflows/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color -verbose
shell: bash
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '42 22 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
51 changes: 51 additions & 0 deletions .github/workflows/e2etest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: e2etest

on:
schedule:
- cron: "30 14 * * 1-5" # weekday
workflow_dispatch:

env:
DB_USER: postgres
DB_PASSWORD: postgres
DB_HOST: db
TESTDB_HOST: testdb
DB_PORT: 5432
DB_SCHEMA: postgres
FLASHSENSE_API_URL: http://flashsense.api.url.example/api
FIREBASE_CRED: /key/firebase_credentials.json
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
jobs:
e2etest:
name: Run e2etests
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v3
- name: Extract service account credentials
run: |
envsubst < ./key/.subst > ./key/firebase_credentials.json
env:
FIREBASE_CREDENTIALS_JSON: ${{ secrets.FIREBASE_CREDENTIALS_JSON }}
- name: react build
run: npm ci && npm run build
working-directory: ./web
env:
REACT_APP_API_BASE_URL: "http://traefik/api"
REACT_APP_FIREBASE_API_KEY: ${{ secrets.REACT_APP_FIREBASE_API_KEY }}
REACT_APP_FIREBASE_APP_ID: ${{ secrets.REACT_APP_FIREBASE_APP_ID }}
REACT_APP_FIREBASE_AUTH_DOMAIN: ${{ secrets.REACT_APP_FIREBASE_AUTH_DOMAIN }}
REACT_APP_FIREBASE_MEASUREMENT_ID: ${{ secrets.REACT_APP_FIREBASE_MEASUREMENT_ID }}
REACT_APP_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_MESSAGING_SENDER_ID }}
REACT_APP_FIREBASE_PROJECT_ID: ${{ secrets.REACT_APP_FIREBASE_PROJECT_ID }}
REACT_APP_FIREBASE_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_STORAGE_BUCKET }}
REACT_APP_FIREBASE_AUTH_EMULATOR_URL: "http://testfirebase:9099"
REACT_APP_METEMCYBER_AUTH_URL: "http://testfirebase:9099"
- name: docker compose build
run: docker compose -f docker-compose-e2e.yml build
- name: migrate db
run: docker compose -f docker-compose-e2e.yml run api sh -c "cd app && alembic upgrade head"
- name: e2etest
run: docker compose -f docker-compose-e2e.yml run --rm e2eclient pytest -s e2etests/test_e2e.py
- name: docker compose down
run: docker compose -f docker-compose-e2e.yml down -v
56 changes: 56 additions & 0 deletions .github/workflows/lint_e2etest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: lint e2etest directory

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches:
- main
paths:
- e2etests/**
push:
branches:
- main
paths:
- e2etests/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


env:
DEFAULT_PYTHON: "3.10"
PYTHON_ROOT_DIRS: ./
E2ETEST_DIRS: ./e2etests


jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.E2ETEST_DIRS }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Setup pipenv
run: |
pip install --user pipenv
- name: Create Python virtual environment
run: |
pipenv --python ${{ env.DEFAULT_PYTHON }}
sudo apt update
sudo apt install -y build-essential python3-dev libpq-dev
pipenv run python -m pip install -U pip
pipenv sync --dev
# Runs a linter for python
- name: Run formatting check
run: |
pipenv run black --check --diff ${{ env.PYTHON_ROOT_DIRS }}
pipenv run ruff check ${{ env.PYTHON_ROOT_DIRS }}
pipenv run mypy ${{ env.PYTHON_ROOT_DIRS }} --show-error-codes --no-error-summary
61 changes: 61 additions & 0 deletions .github/workflows/lint_scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: lint scripts directory

on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches:
- main
paths:
- scripts/**
push:
branches:
- main
paths:
- scripts/**
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


env:
DEFAULT_PYTHON: "3.10"
PYTHON_ROOT_DIRS: ./
SCRIPTS_DIRS: ./scripts


jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.SCRIPTS_DIRS }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Setup pipenv
run: |
pip install --user pipenv
- name: Create Python virtual environment
run: |
pipenv --python ${{ env.DEFAULT_PYTHON }}
sudo apt update
sudo apt install -y build-essential python3-dev libpq-dev
pipenv run python -m pip install -U pip
pipenv sync --dev
# Runs a linter for python
- name: Run formatting check
run: |
pipenv run black --check --diff ${{ env.PYTHON_ROOT_DIRS }}
pipenv run ruff check ${{ env.PYTHON_ROOT_DIRS }}
pipenv run mypy ${{ env.PYTHON_ROOT_DIRS }} --show-error-codes --no-error-summary
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: ${{ env.SCRIPTS_DIRS }}
trivy-config: trivy.yaml

Loading

0 comments on commit 9f53264

Please sign in to comment.