Skip to content

Commit

Permalink
Updates from cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox committed Sep 21, 2023
1 parent 036f652 commit 483e76b
Show file tree
Hide file tree
Showing 65 changed files with 624 additions and 699 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/kjaymiller/cookiecutter-relecloud/",
"commit": "ae6a9f5b19c5b3ba275246ca4c58831ee9bd8203",
"commit": "7dffff585e9f96f9f2306c2a00a50d1434985c33",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
4 changes: 0 additions & 4 deletions .devcontainer/Dockerfile_dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip

COPY demo_code/requirements.txt .

RUN python -m pip install -r requirements.txt
29 changes: 17 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Relecloud - fastapi",
"name": "azure_fastapi_cosmos_postgres_aca",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose_dev.yml" // Overwrites portions of the prod compose file
],

"dockerComposeFile": "docker-compose_dev.yml",
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",
Expand All @@ -18,7 +14,7 @@
"forwardPorts": [8000, 5432],
"portsAttributes": {
"8000": {"label": "frontend web port", "onAutoForward": "notify"},
"5432": {"label": "PostgreSQL port", "onAutoForward": "silent"}
"5432": {"label": "PostgreSQL Port", "onAutoForward": "silent"}
},
"customizations": {
"vscode": {
Expand All @@ -27,11 +23,10 @@
"charliermarsh.ruff",
"ms-python.python",
"ms-python.black-formatter",
"microsoft.bicep",
"bierner.github-markdown-preview",
"ms-azuretools.vscode-docker",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg"
"mtxr.sqltools-driver-pg",
"bierner.github-markdown-preview"
],
"settings": {
"sqltools.connections": [
Expand All @@ -44,7 +39,15 @@
"username": "postgres",
"password": "postgres"
}
]
],
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"files.exclude": {
".coverage": true,
".pytest_cache": true,
"__pycache__": true
}
}
}
},
Expand All @@ -53,4 +56,6 @@
// Required for azd to package the app to ACA
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
}
"postCreateCommand": "pip install -r requirements-dev.in && pip install -e src && python3 src/fastapi_app/seed_data.py"
}

40 changes: 27 additions & 13 deletions .devcontainer/docker-compose_dev.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
# This overwrites select settings from the main docker-compose.yml.
# WARNING: THIS SHOULD NOT BE USED DIRECTLY
version: '3'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
db:
image: postgres:14

environment:
POSTGRES_USER: postgres
POSTGRES_DB: relecloud
POSTGRES_HOST: db
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432

restart: unless-stopped

volumes:
- postgres-data:/var/lib/postgresql/data

healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d relecloud"]
interval: 5s
timeout: 5s
retries: 5

app:
build:
build:
context: .
dockerfile: .devcontainer/Dockerfile_dev
dockerfile: Dockerfile_dev
depends_on:
db:
condition: service_healthy
network_mode: service:db
environment:
DBSERVER_USER: postgres
DBSERVER_DB: relecloud
DBSERVER_HOST: db
DBSERVER_PORT: 5432
DBSERVER_PASSWORD: postgres
POSTGRES_USERNAME: postgres
POSTGRES_DATABASE: relecloud
POSTGRES_HOST: db
POSTGRES_PASSWORD: postgres

command: sleep infinity

volumes:
- .:/workspace:cached
- ..:/workspace:cached

volumes:
postgres-data:
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
74 changes: 74 additions & 0 deletions .github/workflows/cruft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Update repository with Cruft
permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 1" # Every Monday at 2am
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- add-paths: .
body: Use this to merge the changes to this repository.
branch: cruft/update
commit-message: "chore: accept new Cruft update"
title: New updates detected with Cruft
- add-paths: .cruft.json
body: Use this to reject the changes in this repository.
branch: cruft/reject
commit-message: "chore: reject new Cruft update"
title: Reject new updates detected with Cruft
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Cruft
run: pip3 install cruft

- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged .
- name: Create pull request
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR. ${{ matrix.body }}
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository.
30 changes: 30 additions & 0 deletions .github/workflows/devcontainer-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: devcontainer CI

on:
push:
branches: [ "main" ]
paths:
- ".devcontainer/**"
- ".github/workflows/devcontainer-ci.yaml"
pull_request:
branches: [ "main" ]
paths:
- ".devcontainer/**"
- ".github/workflows/devcontainer-ci.yaml"

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- run: npm install -g @devcontainers/cli
- run: devcontainer build --config ./.devcontainer/devcontainer.json --workspace-folder "$(pwd)"
6 changes: 2 additions & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Python Format Check
on:
on:
push:
branches:
- main
pull_request:
branches:
branches:
- main
paths-ignore:
- '**.md'
Expand All @@ -28,5 +28,3 @@ jobs:
run: ruff .
- name: Check formatting with black
run: black . --check --verbose


50 changes: 50 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Python check

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test_package:

name: Test ${{ matrix.os }} Python ${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
python_version: ["3.8", "3.9", "3.10", "3.11"]
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v2
with:

python-version: ${{ matrix.python_version }}
architecture: x64
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.in
playwright install --with-deps
python3 -m pip install -e src
- name: Seed data and run Pytest tests
run: |
python3 src/fastapi_app/seed_data.py
python3 -m pytest
env:
POSTGRES_HOST: localhost
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DATABASE: postgres
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
__pycache__/
media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/

### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
Expand Down
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"fastapi_app:app",
"--reload"
],
}
]
}
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@ Before you submit your Pull Request (PR) consider the following guidelines:
```

That's it! Thank you for your contribution!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 483e76b

Please sign in to comment.