Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added test workflow and some linting
  • Loading branch information
andrecsilva committed Apr 25, 2024
commit 4d097a509522669c496db8b45ceb66ded91617ea
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Unit Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
merge-group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Package
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install build dependencies
run: pip install build twine
- name: Build package
run: python -m build .
- name: Twine Check
run: twine check dist/*
test:
name: Run pytest
runs-on: ubuntu-22.04
timeout-minutes: 25
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- name: install netcat
run: apt update && apt install -y netcat
- name: make bash default shell
run: ln -sf /bin/bash /bin/sh
- name: Check out code
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Codemodder Package
run: pip install .
- name: Install Dependencies
run: pip install -r dev_requirements.txt
- name: Run unit tests
run: pytest
51 changes: 49 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: |
(?x)^(
src/core_codemods/docs/.*|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you copied quite a bit of this and none of these locations exist in this repo, same for the other excludes, the mypy typing mocks that we may not be using

src/codemodder/dependency.py |
integration_tests/.*|
tests/.*
)$
- id: check-added-large-files
exclude: |
(?x)^(
tests/samples/pygoat.semgrep.sarif.json
)$
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.4.0
hooks:
- id: black
exclude: |
(?x)^(
tests/samples/.*|
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
exclude: |
(?x)^(
tests/samples/.*|
integration_tests/.*
)$
args: [--disable-error-code=has-type,--disable-error-code=import-not-found]
additional_dependencies:
[
"types-jsonschema~=4.21.0",
"types-mock==5.0.*",
"types-PyYAML==6.0",
"types-toml~=0.10",
"types-requests~=2.13",
]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: ruff
exclude: tests/samples/
# todo: replace black with this?
# Run the formatter.
# - id: ruff-format
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
exclude: tests/samples/
args: ["--profile", "black"]
Loading