From 74bb1010dac88ad477cde07ce202203a8e7a4579 Mon Sep 17 00:00:00 2001 From: Alexandre Teles Date: Mon, 10 Apr 2023 22:08:14 -0300 Subject: [PATCH] ci: add type, linting and security checks --- .github/workflows/black.yml | 16 +++++++++++ .github/workflows/codeql.yml | 55 ++++++++++++++++++++++++++++++++++++ .github/workflows/mypy.yml | 26 +++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 .github/workflows/black.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/mypy.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..4f3a934 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,16 @@ +name: Black formatter + +on: + pull_request: + branches: [ "dev" ] + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: psf/black@stable + with: + options: "--check --verbose" + src: "./src" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..2cebbb0 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,55 @@ +name: "CodeQL" + +on: + pull_request: + branches: [ "dev" ] + workflow_dispatch: + +env: + default_branch: dev + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ env.default_branch }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11.3' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; + then pip install -r requirements.txt; + fi + echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + setup-python-dependencies: false + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 0000000..b70c77e --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,26 @@ +name: MyPy + +on: + pull_request: + branches: [ "dev" ] + workflow_dispatch: + +jobs: + mypy: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.11.3 + architecture: x64 + - name: Checkout + uses: actions/checkout@v3 + - name: Install mypy + run: pip install mypy + - name: Run mypy + uses: sasanquaneuf/mypy-github-action@main + with: + checkName: 'mypy' + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}