From 8f3eb8f5ceec423d52b9a000944f8626c2d7be2d Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Thu, 17 Jun 2021 15:27:48 +0300 Subject: [PATCH 1/6] Create python-app.yml --- .github/workflows/python-app.yml | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..8d22b55 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,37 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + flask init-db + pytest From 6c5469da0b1790fa3504b1ebe24257d9b5c55536 Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Fri, 18 Jun 2021 11:41:16 +0300 Subject: [PATCH 2/6] fixing --- handlers/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/routes.py b/handlers/routes.py index d9d3b6e..06d5684 100644 --- a/handlers/routes.py +++ b/handlers/routes.py @@ -35,7 +35,7 @@ def remove_value(): db = get_db() db.execute( "DELETE FROM shoppinglist WHERE item = ?", - (item) # change this to (item,) <- the comma is what matters - don't ask me why... + (item,) # change this to (item,) <- the comma is what matters - don't ask me why... ) db.commit() return redirect("/", code=302) From 420663aef5f283f66daba9fb9b47675edb50fc16 Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Fri, 18 Jun 2021 12:23:25 +0300 Subject: [PATCH 3/6] Create main.yml --- .github/workflows/main.yml | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c7b2eb5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,52 @@ +# This is a basic workflow to help you get started with Actions + +name: CD to GitHub Container Registry + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Log in to GitHub Container Registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_TOKEN }} + + # Set up Docker Buildx + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + # Build and push the image + - name: Build and push the image + id: docker_build + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/flask-pytest-example:latest + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 4212bd715b6114cbdda17757cc3b1ec32b254c42 Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Fri, 18 Jun 2021 13:08:24 +0300 Subject: [PATCH 4/6] Fix dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4cebcda..c8ed21e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN pip3 install -r requirements.txt COPY database /app/database COPY handlers /app/handlers COPY templates /app/templates -COPY instance /app/instance + COPY app.py /app/app.py COPY schema.sql /app/schema.sql From 6a28d4234d349d5cddad1083ea343517e5712f94 Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Fri, 18 Jun 2021 13:24:13 +0300 Subject: [PATCH 5/6] token updated --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7b2eb5..2774dbc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.GHCR_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} # Set up Docker Buildx - name: Set up Docker Buildx From 83f4292586683a0e1af569e5a1f14eea5de61db1 Mon Sep 17 00:00:00 2001 From: Alexander Nikandrov Date: Fri, 18 Jun 2021 13:28:26 +0300 Subject: [PATCH 6/6] user updated --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2774dbc..3704465 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ github.repository_owner }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # Set up Docker Buildx