Skip to content

Commit

Permalink
Release 2022.11.1 (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran authored Nov 14, 2022
2 parents 3e8e396 + 28814fb commit 43c788e
Show file tree
Hide file tree
Showing 34 changed files with 753 additions and 66 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
Expand Down
29 changes: 14 additions & 15 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

# https://codeql.github.com/
name: CodeQL

on:
push:
pull_request:
branches: [ main ]
branches: [dev]
schedule:
- cron: "24 9 * * 6"

Expand All @@ -21,20 +20,20 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ "python" ]
language: ["python"]

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

- 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
- 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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
55 changes: 30 additions & 25 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
name: Build and publish Docker image
name: Deploy

on:
release:
types: [ published ]
workflow_dispatch:
push:
branches:
- main
paths:
- 'data/**'
- 'eligibility_server/**'
- 'keys/**'
- '.github/workflows/docker-publish.yml'
- 'Dockerfile'
- 'requirements.txt'
- dev
- test
- prod

defaults:
run:
shell: bash

jobs:
build_push_docker:
name: Package Docker image
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
concurrency: ${{ github.ref_name }}

steps:
- name: Login to GitHub Container Registry
- name: Checkout
uses: actions/checkout@v3

- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push release
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
with:
push: true
tags: |
ghcr.io/${{github.repository}}:${{ github.event.release.tag_name }}
ghcr.io/${{github.repository}}:latest
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Build and push main
- name: Build, tag, and push image to GitHub Container Registry
uses: docker/build-push-action@v3
if: ${{ github.event_name != 'release' }}
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: GIT-SHA=${{ github.sha }}
cache-from: type=gha,scope=cal-itp
cache-to: type=gha,scope=cal-itp,mode=max
context: .
file: Dockerfile
push: true
tags: ghcr.io/${{github.repository}}:main
tags: |
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
ghcr.io/${{ github.repository }}:${{ github.sha }}
8 changes: 4 additions & 4 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ on:
workflow_dispatch:
push:
branches:
- main
- dev
paths:
- 'docs/**'
- '.github/workflows/mkdocs.yml'
- 'mkdocs.yml'
- "docs/**"
- ".github/workflows/mkdocs.yml"
- "mkdocs.yml"
jobs:
mkdocs:
name: Publish docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Pre-commit checks

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

jobs:
pre-commit:
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ ci:
autofix_commit_msg: "chore(pre-commit): autofix run"
autoupdate_commit_msg: "chore(pre-commit): autoupdate hooks"

# by default, install these hook types
# https://pre-commit.com/#top_level-default_install_hook_types
default_install_hook_types:
- pre-commit
- commit-msg

# by default, confine hooks to these git stages (except for hooks that specify their own stages)
# https://pre-commit.com/#top_level-default_stages
default_stages:
- commit

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
"python.linting.enabled": true,
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"[terraform-vars]": {
"editor.defaultFormatter": "hashicorp.terraform"
}
}
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This website provides technical documentation for the `eligibility-server` application, a part of the [`benefits`](https://docs.calitp.org/benefits) application, from the [California Integrated Travel Project (Cal-ITP)](https://www.calitp.org).

Documentation for the `main` (default) branch is available [online](https://docs.calitp.org/eligibility-server).
Documentation for the `dev` (default) branch is available [online](https://docs.calitp.org/eligibility-server).

## Overview

Expand Down Expand Up @@ -30,5 +30,5 @@ docker compose build server
### Use the Docker container locally

```bash
docker pull ghcr.io/cal-itp/eligibility-server:main
docker pull ghcr.io/cal-itp/eligibility-server:dev
```
10 changes: 5 additions & 5 deletions docs/configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ The [Getting Started](./getting-started) section mentions [copying `.env.sample`

If you want to run with different settings, you should:

1. Create a new Python configuration file in the `config` directory
1. Provide a value for [`IMPORT_FILE_PATH`](./settings.md#import_file_path) (required) and any other settings you want to override (optional)
1. Set the `ELIGIBILITY_SERVER_SETTINGS` environment variable to the path of your new file
1. Create a new Python configuration file in the `config` directory
1. Provide a value for [`IMPORT_FILE_PATH`](./settings.md#import_file_path) (required) and any other settings you want to override (optional)
1. Set the `ELIGIBILITY_SERVER_SETTINGS` environment variable to the path of your new file

!!! note
The Eligibility server loads in settings using Flask's methods for [Configuration Handling](https://flask.palletsprojects.com/en/2.2.x/config/).
The Eligibility server loads in settings using Flask's methods for [Configuration Handling](https://flask.palletsprojects.com/en/2.2.x/config/).

!!! important
The default settings that will always be loaded are in [eligibility_server/settings.py](https://github.com/cal-itp/eligibility-server/blob/main/eligibility_server/settings.py)
The default settings that will always be loaded are in [eligibility_server/settings.py](https://github.com/cal-itp/eligibility-server/blob/dev/eligibility_server/settings.py)
8 changes: 4 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ This repository comes with a [VS Code Remote Containers](https://code.visualstud

Once you clone the repository locally, open it within VS Code, which will prompt you to re-open the repository within the Remote Container.

1. Build and Open the Dev Container
2. Start the `eligibility-server` Flask app and database with `F5`
3. Now you can run tests from the container.
1. Build and Open the Dev Container
2. Start the `eligibility-server` Flask app and database with `F5`
3. Now you can run tests from the container.

Starting the Dev Container will run `bin/init.sh`, which runs a command to initialize the database. More specifically, it creates the database and imports and saves users based on the configured settings.

## Run tests

### Run unit tests

Unit tests are implemented with [`pytest`](https://docs.pytest.org/en/6.2.x/) and can be found in the [`tests/`](https://github.com/cal-itp/eligibility-server/tree/main/tests) directory in the repository. `pytest` is installed and available to run directly in the devcontainer.
Unit tests are implemented with [`pytest`](https://docs.pytest.org/en/6.2.x/) and can be found in the [`tests/`](https://github.com/cal-itp/eligibility-server/tree/dev/tests) directory in the repository. `pytest` is installed and available to run directly in the devcontainer.

The test suite runs against every pull request via a GitHub Action.

Expand Down
4 changes: 2 additions & 2 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

The `eligibility-server` is published as a Docker image on the GitHub Container Registry. It can be accessed from the [repository package page](https://github.com/cal-itp/eligibility-server/pkgs/container/eligibility-server).

Every push to the `main` (default) branch that changes files relevant to the application builds and updates the `main` package, via the [`docker-publish`](https://github.com/cal-itp/eligibility-server/blob/main/.github/workflows/docker-publish.yml) GitHub Action.
Every push to the `dev` (default) branch that changes files relevant to the application builds and updates the `dev` package, via the [`docker-publish`](https://github.com/cal-itp/eligibility-server/blob/dev/.github/workflows/docker-publish.yml) GitHub Action.

Every release created also pushes a new package publication.

## Versions

All versions of the package may be viewed on the [package all versions page](https://github.com/cal-itp/eligibility-server/pkgs/container/eligibility-server/versions).

The `main` (default) branch is published at the `main` tag:
The `dev` (default) branch is published at the `dev` tag:

The official releases will be tagged with a version number and the `latest` tag.
4 changes: 0 additions & 4 deletions eligibility_server/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import json
import logging
import re
import time

from flask import abort
from flask_restful import Resource, reqparse
Expand Down Expand Up @@ -156,9 +155,6 @@ def _check_user(self, sub, name, types):

def get(self):
"""Respond to a verification request."""
# introduce small fake delay
time.sleep(2)

headers = {}

# verify required headers and API key check
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
site_name: "cal-itp/eligibility-server: documentation"
site_url: https://docs.calitp.org/eligibility-server
repo_url: https://github.com/cal-itp/eligibility-server
edit_uri: edit/main/docs
edit_uri: edit/dev/docs

theme:
name: material
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

setup(
name="eligibility-server",
version="2022.11.1",
description="Server implementation of the Eligibility Verification API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
36 changes: 36 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://github.com/github/gitignore/blob/e5323759e387ba347a9d50f8b0ddd16502eb71d4/Terraform.gitignore

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
23 changes: 23 additions & 0 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 43c788e

Please sign in to comment.