Skip to content

Commit

Permalink
conflict
Browse files Browse the repository at this point in the history
Signed-off-by: S-mishina <[email protected]>
  • Loading branch information
S-mishina committed Jun 8, 2024
2 parents 72c9d3b + e8c465f commit 429df5f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]

jobs:
test_ci:
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.10.0
architecture: "x64"
- uses: actions/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Python unit tests
run: |
python -m unittest discover -s test -p "*.py"
deploy:
runs-on: ubuntu-20.04
needs: test_ci
if: github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.10.0
architecture: "x64"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Install pip requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/s-mishina/flexiblemockserver:${{ github.sha }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/__pycache__
*/__init__.py
3 changes: 3 additions & 0 deletions project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def only_status_code_query(status_code, sleep_time=0):
else:
return make_response(jsonify(err="Not status code"), 400)

@app.errorhandler(404)
def page_not_found(e):
return make_response(jsonify(err="Nonexistent Path"), 404)

if __name__ == '__main__':
app.run(host=host, port=port)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
click==8.1.3
Flask==2.3.3
itsdangerous==2.1.2
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==2.1.2
MarkupSafe==2.1.5
Werkzeug==3.0.3
10 changes: 7 additions & 3 deletions test/unit_test.py → test/app_unittest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest
from main import app

from project.main import app


class TestApp(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -47,5 +49,7 @@ def test_only_status_code_query_route(self):
self.assertEqual(response.json['status_code'], 500)
self.assertEqual(response.json['output'], "{'param1': 'value1', 'param2': 'value2'}")

if __name__ == '__main__':
unittest.main()
def test_new_route(self):
response = self.app.get('/new')
self.assertEqual(response.status_code, 404)
self.assertEqual(response.json['err'], 'Nonexistent Path')

0 comments on commit 429df5f

Please sign in to comment.