diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..563c6a3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,27 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" # pyproject.toml + schedule: + interval: "daily" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "dependencies" + - package-ecosystem: "github-actions" + # Workflow files stored in the + # default location of `.github/workflows` + directory: "/" + schedule: + interval: "daily" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "dependencies" diff --git a/.github/workflows/.python-version b/.github/workflows/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.github/workflows/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..e6b6ff4 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,64 @@ +# https://codeql.github.com/ +name: CodeQL + +on: + push: + paths: + - "**.py" + pull_request: + branches: [main] + paths: + - "**.py" + schedule: + - cron: "24 9 * * 6" + +jobs: + setup: + name: Set up CodeQL analysis + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + outputs: + # changes is a JSON array with names of all filters matching any of the changed files + languages: ${{ steps.filter.outputs.changes }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + python: "**.py" + + codeql: + name: CodeQL Analyze + runs-on: ubuntu-latest + needs: setup + if: ${{ needs.setup.outputs.languages != '[]' }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + # Parse JSON array containing names of all filters matching any of changed files + # e.g. ['javascript', 'python'] if both file types had changes + language: ${{ fromJSON(needs.setup.outputs.languages) }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#specifying-configuration-details-using-the-config-input + config: | + paths-ignore: + - tests + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dependency-triage.yml b/.github/workflows/dependency-triage.yml new file mode 100644 index 0000000..36cc487 --- /dev/null +++ b/.github/workflows/dependency-triage.yml @@ -0,0 +1,18 @@ +name: "Dependency PR triage" + +on: + pull_request: + types: [opened] + +jobs: + dependency-triage: + runs-on: ubuntu-latest + permissions: + pull-requests: write + # see https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events + if: github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]' + steps: + - name: add-label + uses: andymckay/labeler@master + with: + add-labels: "dependencies" diff --git a/.github/workflows/tests-pytest.yml b/.github/workflows/tests-pytest.yml new file mode 100644 index 0000000..68c49fa --- /dev/null +++ b/.github/workflows/tests-pytest.yml @@ -0,0 +1,43 @@ +name: Pytest + +on: [push, pull_request, workflow_call] + +jobs: + pytest: + runs-on: ubuntu-latest + permissions: + # Gives the action the necessary permissions for publishing new + # comments in pull requests. + pull-requests: write + # Gives the action the necessary permissions for pushing data to the + # python-coverage-comment-action branch, and for editing existing + # comments (to avoid publishing multiple comments in the same PR) + contents: write + steps: + - name: Check out code + uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version-file: .github/workflows/.python-version + cache: pip + cache-dependency-path: "**/pyproject.toml" + + - name: Install Python dependencies + run: pip install -e .[test] + + - name: Run tests + run: ./tests/run.sh + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: tests/coverage + + - name: Coverage comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} + MINIMUM_GREEN: 90 + MINIMUM_ORANGE: 80