Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
144 changes: 72 additions & 72 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,99 +2,99 @@ name: CI/CD Pipeline

on:
push:
branches: [ main, master ]
branches: [main, master]
pull_request:
branches: [ main, master ]
branches: [main, master]

jobs:
app-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install PyTorch CPU version first with the correct index
pip install torch==2.5.1+cpu torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu
# Install CI-specific requirements (CPU versions)
if [ -f app/requirements-ci.txt ]; then pip install -r app/requirements-ci.txt; fi
# Install test requirements
if [ -f app/tests/test_requirements.txt ]; then pip install -r app/tests/test_requirements.txt; fi
# Install SAM model (may be needed for imports, even though tests use mocks)
pip install git+https://github.com/facebookresearch/segment-anything.git
- name: Set test mode environment variable
run: |
echo "SAT_ANNOTATOR_TEST_MODE=1" >> $GITHUB_ENV
- name: Run tests
run: |
cd app/tests
python run_unittests.py
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install PyTorch CPU version first with the correct index
pip install torch==2.5.1+cpu torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu
# Install CI-specific requirements (CPU versions)
if [ -f app/requirements-ci.txt ]; then pip install -r app/requirements-ci.txt; fi
# Install test requirements
if [ -f app/tests/test_requirements.txt ]; then pip install -r app/tests/test_requirements.txt; fi
# Install SAM model (may be needed for imports, even though tests use mocks)
pip install git+https://github.com/facebookresearch/segment-anything.git

- name: Set test mode environment variable
run: |
echo "SAT_ANNOTATOR_TEST_MODE=1" >> $GITHUB_ENV

- name: Run tests
run: |
cd app/tests
python run_unittests.py

web-validation:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Validate HTML files
run: |
echo "Validating web static files..."
# Check if main HTML files exist
test -f web/index.html || (echo "Missing index.html" && exit 1)
test -f web/styles.css || (echo "Missing styles.css" && exit 1)
test -d web/js || (echo "Missing js directory" && exit 1)
echo "Web files validation passed"
- name: Check JavaScript syntax
run: |
echo "Checking JavaScript syntax..."
# Use Python to check basic JavaScript syntax if Node.js is available
if command -v node >/dev/null 2>&1; then
for js_file in web/js/*.js; do
if [ -f "$js_file" ]; then
echo "Checking $js_file..."
node -c "$js_file" || (echo "Syntax error in $js_file" && exit 1)
fi
done
else
echo "Node.js not available, skipping JS syntax check..."
fi
echo "JavaScript validation completed"
- uses: actions/checkout@v3

- name: Validate HTML files
run: |
echo "Validating web static files..."
# Check if main HTML files exist
test -f web/index.html || (echo "Missing index.html" && exit 1)
test -f web/styles.css || (echo "Missing styles.css" && exit 1)
test -d web/js || (echo "Missing js directory" && exit 1)
echo "Web files validation passed"

- name: Check JavaScript syntax
run: |
echo "Checking JavaScript syntax..."
# Use Python to check basic JavaScript syntax if Node.js is available
if command -v node >/dev/null 2>&1; then
for js_file in web/js/*.js; do
if [ -f "$js_file" ]; then
echo "Checking $js_file..."
node -c "$js_file" || (echo "Syntax error in $js_file" && exit 1)
fi
done
else
echo "Node.js not available, skipping JS syntax check..."
fi
echo "JavaScript validation completed"

docker-build:
runs-on: ubuntu-latest
needs: [app-tests, web-validation]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')

steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and test Docker images
run: |
echo "Building Docker images..."
docker compose build
echo "Docker build completed successfully"
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and test Docker images
run: |
echo "Building Docker images..."
docker compose build
echo "Docker build completed successfully"

# Uncomment and configure the following if you want to push to Docker Hub or another registry
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
#
#
# - name: Push Docker images
# run: |
# docker compose push
# docker compose push
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.tabSize": 4,
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Loading