Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigating infra pipeline logic #285

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM eligibility_server:latest

# install python tooling
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt
# install devcontainer requirements
RUN pip install -e .[dev,test]

# install docs tooling
# docs requirements are in a separate file for the GitHub Action
COPY docs/requirements.txt docs/requirements.txt
RUN pip install --no-cache-dir -r docs/requirements.txt

# install test tooling
COPY tests/requirements.txt tests/requirements.txt
RUN pip install -r tests/requirements.txt
# install pre-commit environments in throwaway Git repository
# https://stackoverflow.com/a/68758943
COPY .pre-commit-config.yaml .
RUN git init . && \
pre-commit install-hooks && \
rm -rf .git
41 changes: 22 additions & 19 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@
"postStartCommand": ["/bin/bash", "bin/init.sh"],
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
"customizations": {
// Set *default* container specific settings.json values on container create.
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
}
3 changes: 0 additions & 3 deletions .devcontainer/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # requirements.txt
directory: "/" # pyproject.toml
schedule:
interval: "daily"
commit-message:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
- name: Install package and dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
pip install -r requirements.txt
pip install -e .[test]

- name: Load environment variables
uses: cardinalby/export-env-action@v2
Expand Down
8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"[terraform-vars]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"workbench.editorAssociations": {
"*.db": "sqlite-viewer.option"
}
}
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ FROM ghcr.io/cal-itp/docker-python-web:main

ENV FLASK_APP=eligibility_server/app.py

# install python app dependencies
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# upgrade pip
RUN python -m pip install --upgrade pip

# copy source files
COPY bin/ bin/
COPY bin bin
COPY eligibility_server/ eligibility_server/
COPY *.py .
COPY README.md .
COPY pyproject.toml pyproject.toml

# install source as a package
RUN pip install -e .
Expand Down
1 change: 1 addition & 0 deletions data/server.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sub,name,type
71162,Box,courtesy_card
32587,Gonzales,courtesy_card
03552,McCulley,courtesy_card
Expand Down
3 changes: 3 additions & 0 deletions eligibility_server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__ = "2023.06.1"

VERSION = __version__
11 changes: 6 additions & 5 deletions eligibility_server/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ def import_csv_users(csv_path, remote):
# open in read mode explicitly since the file may still be open if we downloaded from remote
# newline="" is important here, see https://docs.python.org/3/library/csv.html#id3
with open(csv_path, mode="r", encoding="utf-8", newline="") as file:
data = csv.reader(
data = csv.DictReader(
file,
delimiter=config.csv_delimiter,
quoting=config.csv_quoting,
quotechar=config.csv_quotechar,
)
# unpack each record in data to the 3 columns
for sub, name, types in data:

for row in data:
# type lists are expected to be a comma-separated value and quoted if the CSV delimiter is a comma
types = [type.replace(config.csv_quotechar, "") for type in types.split(",") if type]
save_user(sub, name, types)
types = row["type"]
types = [types.replace(config.csv_quotechar, "") for type in types.split(",") if type]
save_user(row["sub"], row["name"], types)

# close and remove the temp file if needed
if temp_csv:
Expand Down
45 changes: 40 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
# Configuration for Black.
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.
[project]
classifiers = ["Programming Language :: Python :: 3 :: Only"]
description = "Server implementation of the Eligibility Verification API"
dependencies = [
"eligibility-api==2023.6.1",
"Flask==2.3.2",
"Flask-RESTful==0.3.10",
"Flask-SQLAlchemy==3.0.5",
"requests==2.31.0"
]
dynamic = ["version"]
keywords = ["flask"]
license = { file = "LICENSE" }
name = "eligibility-server"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
"black",
"flake8",
"pre-commit",
]
test = [
"coverage",
"pytest",
"pytest-mock",
]

[project.urls]
Code = "https://github.com/cal-itp/eligibility-server"
Documentation = "https://docs.calitp.org/eligibility-server"
Issues = "https://github.com/cal-itp/eligibility-server/issues"

# Configuration for black
[tool.black]
line-length = 127
target-version = ['py310']
include = '\.pyi?$'

[tool.setuptools]
packages = ["eligibility_server"]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion terraform/uptime.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module "healthcheck" {
application_insights = azurerm_application_insights.main
# not strictly necessary to include the environment name, but helps to make the alerts more clear
name = "mst-courtesy-cards-eligibility-server-${local.env_name}-healthcheck"
url = "https://${azurerm_linux_web_app.main.default_hostname}/healthcheck"
url = "https://${azurerm_cdn_frontdoor_endpoint.main.host_name}/healthcheck"
}

# ignore when app restarts as data is being reloaded
Expand Down
3 changes: 0 additions & 3 deletions tests/requirements.txt

This file was deleted.