Skip to content

Commit

Permalink
CTX-5783: Added github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Vuk Manojlovic committed Jul 5, 2024
1 parent 0d76879 commit 9cd99b3
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/linter-code-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Linter code check

on:
push:
branches:
- main
- stage
- develop
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
- stage
- develop

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install mypy globally
run: |
pip install mypy
- name: Analysing templates with mypy
run: |
eval "$(conda shell.bash hook)"
for dir in tasks/* ; do
echo "Checking directory: $dir"
# Skip the directory if no .mypy.ini file is found
if [ ! -f "$dir/.mypy.ini" ]; then
echo "No .mypy.ini file found in $dir, skipping..."
continue
fi
if [ -f "$dir/environment.yml" ]; then
echo "Setting up conda environment for $dir"
conda env create -n $(basename "$dir") -f "$dir/environment.yml"
echo "Created conda environment"
conda activate $(basename "$dir")
pip install mypy
elif [ -f "$dir/requirements.txt" ]; then
echo "Setting up venv for $dir"
python -m venv "$dir/venv"
source "$dir/venv/bin/activate"
pip install -r "$dir/requirements.txt"
pip install mypy
fi
echo "Running mypy in $dir"
set +e # Disable exit on error
mypy_output=$(mypy --config-file "$dir/.mypy.ini" "$dir" 2>&1)
set -e # Re-enable exit on error
echo "$mypy_output"
if echo "$mypy_output" | grep -q 'error:'; then
echo "Running install-types in $dir"
mypy --install-types --non-interactive --config-file "$dir/.mypy.ini" "$dir"
fi
if [ -f "$dir/environment.yml" ]; then
conda deactivate
conda remove -y -n $(basename "$dir") --all
elif [ -f "$dir/requirements.txt" ]; then
deactivate
rm -rf "$dir/venv"
fi
done

0 comments on commit 9cd99b3

Please sign in to comment.