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

Meeting2 notes #36

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .github/actions/cc-title/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Pull request title check
description: Check if PR title matches conventional commit specification
runs:
using: "composite"
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Match title to regex
shell: bash
run: python3 ./.github/actions/cc-title/check_title.py "${{ github.event.pull_request.title }}"
17 changes: 17 additions & 0 deletions .github/actions/cc-title/check_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import re as re
from sys import argv

pattern = re.compile(
"^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)"
"{1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)"
)

if len(argv) != 2:
print("Wrong number of arguments!")
exit(1)
if re.search(pattern, argv[1]) is not None:
print("Title matched!")
exit(0)
else:
print("Title does not match!")
exit(1)
13 changes: 13 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Setup environment
description: Setup the environment used for testing and building flutter apps
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install --upgrade pip
shell: bash
- run: pip install -r api/requirements.txt
shell: bash
52 changes: 52 additions & 0 deletions .github/workflows/analyze-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Code Maintenance

on:
pull_request:
branches: [main]

workflow_dispatch:

jobs:
detect-secrets:
name: No committed secrets
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install detect-secrets
run: pip install detect-secrets
- name: Scan for secrets
run: detect-secrets scan --baseline .secrets.baseline
prettier-check:
name: Prettier formatted files
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install prettier
run: npm install -g prettier
- name: Run prettier against files
run: prettier -c .
analyze-code:
name: No code smells
runs-on: [ubuntu-latest]
defaults:
run:
working-directory: ./api
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Lint code
uses: chartboost/ruff-action@v1
- name: Check code formatting
uses: psf/black@stable
with:
options: "--check"
17 changes: 17 additions & 0 deletions .github/workflows/check-pull-request-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Conventional Commits

on:
pull_request:
types: [edited, opened]
branches: [main]

workflow_dispatch:

jobs:
check-title-format:
name: PR title matches spec
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Check if PR title matches regex
uses: ./.github/actions/cc-title
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
env
venv
.vscode
*.db
*.env
__pycache__
*.sqlite
.ruff_cache
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
# Prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8" # Use the sha or tag you want to point at
hooks:
- id: prettier
types_or: ["markdown", "python", "yaml"]
args: ["--no-cache"]
# Black formatter
- repo: https://github.com/psf/black
rev: 24.1.0
hooks:
- id: black
# Ruff linter
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.1.14"
hooks:
- id: ruff
# Detect secrets
- repo: https://github.com/Yelp/detect-secrets
rev: "v1.4.0"
hooks:
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]
exclude: package.lock.json

# Check newlines, yaml is valid
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: ".hbs$"
112 changes: 112 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"version": "1.4.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2024-01-26T10:53:20Z"
}
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
# PWP SPRING 2024

# PROJECT NAME

# Group information
* Student 1. Name and email
* Student 2. Name and email
* Student 3. Name and email
* Student 4. Name and email

__Remember to include all required documentation and HOWTOs, including how to create and populate the database, how to run and test the API, the url to the entrypoint and instructions on how to setup and run the client__
- Student 1. Janne Kerola janne.kerola@oulu.fi
- Student 2. Emilia Pyyny epyyny20@student.oulu.fi
- Student 3. Errafay Amine aerrafay19@student.oulu.fi

**Remember to include all required documentation and HOWTOs, including how to create and populate the database, how to run and test the API, the url to the entrypoint and instructions on how to setup and run the client**

# Pre-commit

We use [pre-commit](https://pre-commit.com) to ensure code quality.

```shell
# Install pre-commit with pip
pip3 install pre-commit
# Run this to initialize pre-commit in the repo
cd /path/to/repo
pre-commit install
```

# Development

This repository is a monorepo, containing all needed components for the course.

API directory contains the flask backend.

# Usage

Easiest way to get this up and running is to use podman/docker:

```shell
# create .env file in the root directory
touch .env
# fill in the details as such
DB_PASSWORD=<username>
DB_USER=<password>

podman-compose up -d
# Or docker
docker compose up -d

# then make requests to localhost:3000
curl -X GET localhost:3000
```

# Examine database contents with adminer

Navigate to [http://localhost:8080](http://localhost:8080) and login with the above details. Server should be _'db'_ and database should be _'postgres'_.
4 changes: 4 additions & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
env
__pycache__
README.md
venv
Loading