From be1e2c0e7a37f00599aa8624d2fb3892da624e62 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Mon, 26 Feb 2024 15:54:05 -0800 Subject: [PATCH] ci(lambda): add lint and license check for video conversion lambda --- .github/workflows/lambda-lint.yaml | 24 +++++++++++++++++-- .github/workflows/license-check.yaml | 13 +++++++++- app/video-conversion/lambda/lambda.py | 14 +++++++++++ .../lambda/requirements_dev.txt | 1 + app/video-conversion/lambda/setup.cfg | 5 ++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 app/video-conversion/lambda/requirements_dev.txt create mode 100644 app/video-conversion/lambda/setup.cfg diff --git a/.github/workflows/lambda-lint.yaml b/.github/workflows/lambda-lint.yaml index 9c621f66..c621040d 100644 --- a/.github/workflows/lambda-lint.yaml +++ b/.github/workflows/lambda-lint.yaml @@ -1,4 +1,4 @@ -name: Video Processing Lambda Format Check +name: Lambda Format Check concurrency: group: ${{ github.run_id }} @@ -17,7 +17,7 @@ on: - synchronize jobs: - flake8-check: + video-processing-flake8: runs-on: ubuntu-latest steps: - name: Check out the repository @@ -36,3 +36,23 @@ jobs: - name: Run flake8 check working-directory: app/video-processing run: make lint + + video-conversion-flake8: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + with: + token: ${{ github.token }} + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: "**/requirements*.txt" + - name: Install dependencies + working-directory: app/video-conversion/lambda + run: pip install -r requirements_dev.txt + - name: Run flake8 check + working-directory: app/video-conversion + run: make lint diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml index 3809b9ff..73ca81e7 100644 --- a/.github/workflows/license-check.yaml +++ b/.github/workflows/license-check.yaml @@ -38,7 +38,7 @@ jobs: working-directory: app/web run: npm run license:check - lambda-license: + video-processing-lambda-license: runs-on: ubuntu-latest steps: - name: Check out the repository @@ -48,3 +48,14 @@ jobs: - name: Check license headers working-directory: app/video-processing run: make check-license + + video-conversion-lambda-license: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + with: + token: ${{ github.token }} + - name: Check license headers + working-directory: app/video-conversion + run: make check-license diff --git a/app/video-conversion/lambda/lambda.py b/app/video-conversion/lambda/lambda.py index 1f3207f6..3b317b36 100644 --- a/app/video-conversion/lambda/lambda.py +++ b/app/video-conversion/lambda/lambda.py @@ -1,3 +1,17 @@ +# Copyright [2023] [Privacypal Authors] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import urllib import boto3 import subprocess as sp diff --git a/app/video-conversion/lambda/requirements_dev.txt b/app/video-conversion/lambda/requirements_dev.txt new file mode 100644 index 00000000..a1f9c377 --- /dev/null +++ b/app/video-conversion/lambda/requirements_dev.txt @@ -0,0 +1 @@ +flake8==7.0.0 diff --git a/app/video-conversion/lambda/setup.cfg b/app/video-conversion/lambda/setup.cfg new file mode 100644 index 00000000..1342141d --- /dev/null +++ b/app/video-conversion/lambda/setup.cfg @@ -0,0 +1,5 @@ +[flake8] +ignore = D203 +max-line-length = 200 +exclude = + __pycache__