diff --git a/.github/codeql-config.yml b/.github/codeql-config.yml new file mode 100644 index 0000000..4b7f5da --- /dev/null +++ b/.github/codeql-config.yml @@ -0,0 +1,4 @@ +query-filters: + +paths-ignore: + - tests/**/test_*.py diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..e97beca --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,78 @@ +name: Static analysis + +on: + push: + branches: + - main + + pull_request: + branches: + - main + paths: + - .github/workflows/static-analysis.yaml + - "**/*.py" + - requirements.txt + - requirements-dev.txt + - pyproject.toml + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + pre-commit-checks: + name: Pre-commit checks + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + id: setup_python + with: + python-version: "3.12.4" + + - name: UV Cache + uses: actions/cache@v4 + id: cache-uv + with: + path: ~/.cache/uv + key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }} + + - name: Install packages + run: | + python -m pip install -U uv pre-commit + uv pip install --upgrade --system -r requirements-dev.txt + + - name: Run pre-commit + run: pre-commit run --show-diff-on-failure --color=always --all-files + + analyze: + name: Analyze + runs-on: ubuntu-latest + + permissions: + contents: read + actions: read + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: python + config-file: ./.github/codeql-config.yml + queries: security-extended + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml new file mode 100644 index 0000000..1123a80 --- /dev/null +++ b/.github/workflows/unit-tests.yaml @@ -0,0 +1,55 @@ +name: Unit tests + +on: + push: + branches: + - main + + pull_request: + branches: + - main + paths: + - .github/workflows/unit-tests.yaml + - "**/*.py" + - requirements.txt + - requirements-dev.txt + - pyproject.toml + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + id: setup_python + with: + python-version: "3.12.4" + + - name: UV Cache + uses: actions/cache@v4 + id: cache-uv + with: + path: ~/.cache/uv + key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }} + + - name: Install packages + run: | + python -m pip install -U uv pre-commit + uv pip install --upgrade --system -r requirements-dev.txt + + - name: Run pytest + run: pytest