Skip to content

Commit

Permalink
Refactor app to use Poetry and FastAPI (#227)
Browse files Browse the repository at this point in the history
* add assorted github actions (most currently disabled)

Signed-off-by: Grant Ramsay <[email protected]>

* convert to poetry app

Signed-off-by: Grant Ramsay <[email protected]>

* refactor the layout

Signed-off-by: Grant Ramsay <[email protected]>

* add auto-generated requirements files

Signed-off-by: Grant Ramsay <[email protected]>

* remove a lot of the django stuff

Signed-off-by: Grant Ramsay <[email protected]>

* refactor constants.py to use pathlib

Signed-off-by: Grant Ramsay <[email protected]>

* allow dependency review to comment on PR

Signed-off-by: Grant Ramsay <[email protected]>

* update support files

Signed-off-by: Grant Ramsay <[email protected]>

* update some action versions

Signed-off-by: Grant Ramsay <[email protected]>

* rewrite and optimize phase 1

Signed-off-by: Grant Ramsay <[email protected]>

* fix typing for phase 1

Signed-off-by: Grant Ramsay <[email protected]>

* fix phase 2 and most linting and type issues

Signed-off-by: Grant Ramsay <[email protected]>

* target develop branch with some actions

---------

Signed-off-by: Grant Ramsay <[email protected]>
  • Loading branch information
seapagan authored May 16, 2024
1 parent 86ef5c2 commit 2c07478
Show file tree
Hide file tree
Showing 97 changed files with 5,052 additions and 1,021 deletions.
File renamed without changes.
25 changes: 18 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/frontend" # Location of package manifests
# - package-ecosystem: "npm"
# directory: "/uprn-mangle/frontend"
# schedule:
# interval: "weekly"
# open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/uprn-mangle/frontend"
target-branch: "develop"
schedule:
interval: "daily"
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "pip" # See documentation for possible values
directory: "/backend" # Location of package manifests
# - package-ecosystem: "pip"
# directory: "/uprn-mangle/backend"
# schedule:
# interval: "weekly"
- package-ecosystem: "pip"
directory: "/uprn-mangle/backend"
target-branch: "develop"
schedule:
interval: "daily"
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

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

jobs:
analyze:
Expand All @@ -32,40 +32,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
language: ["javascript", "python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

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

# 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.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# 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.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# 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
# 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.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
19 changes: 13 additions & 6 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]
name: "Dependency Review"
on:
pull_request:
branches: ["main", "develop"]

permissions:
contents: read
pull-requests: write

jobs:
dependency-review:
# uncomment the line before to disable this job if needed.
if: false
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Dependency Review"
uses: actions/dependency-review-action@v4
with:
comment-summary-in-pr: true
10 changes: 10 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Linting
on: [push, pull_request]
jobs:
ruff:
# uncomment the line before to disable this job if needed.
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
20 changes: 20 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Type Checking

on: [push, pull_request, workflow_dispatch]

jobs:
mypy:
# uncomment the line before to disable this job if needed.
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Mypy
uses: jpetrucciani/mypy-check@master
with:
path: "."
mypy_flags:
"--install-types --non-interactive --config-file pyproject.toml
--ignore-missing-imports --strict"
requirements_file: "requirements-dev.txt"
python_version: "3.11"
73 changes: 73 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Tests

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]
workflow_dispatch:

jobs:
test:
# This job is currently disabled. Uncomment the line below to enable it.
if: false
runs-on: ubuntu-latest
env:
SKIP_COVERAGE_UPLOAD: false
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
# ---------------------------------------------------------------------- #
# checkout repo and setup Python #
# ---------------------------------------------------------------------- #
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# ---------------------------------------------------------------------- #
# install and configure poetry #
# ---------------------------------------------------------------------- #
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# ---------------------------------------------------------------------- #
# load cached venv if cache exists #
# ---------------------------------------------------------------------- #
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key:
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version
}}-${{ hashFiles('**/poetry.lock') }}
# ---------------------------------------------------------------------- #
# install dependencies if cache does not exist #
# ---------------------------------------------------------------------- #
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

# ---------------------------------------------------------------------- #
# run Pytest #
# ---------------------------------------------------------------------- #
- name: Test with pytest
run: |
poetry run pytest --cov-report=xml
- name: Run codacy-coverage-reporter
env:
CODACY_CONFIGURED: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: ${{ env.CODACY_CONFIGURED != ''}}
uses: codacy/codacy-coverage-reporter-action@v1
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage.xml
Loading

0 comments on commit 2c07478

Please sign in to comment.