Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/GitHub action #16

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
779e9cf
Closes #213
natrimmer Jun 26, 2024
56d928a
test(exclude-coverage): excludes callback function from coverage
nifedara Jul 15, 2024
8721fd8
test(model-factories): adds model factories to isolate test data
nifedara Jul 15, 2024
8c366fa
test(endpoints-&-view): adds tests for the endpoints
nifedara Jul 15, 2024
41de917
Merge pull request #258 from natrimmer/na_dev
kshitijrajsharma Jul 15, 2024
47f59fe
test(exclude-coverage): omit everything in /usr from coverage
nifedara Jul 16, 2024
0aee788
test(test-backend-build): adds run project tests in Github action wor…
nifedara Jul 16, 2024
f86dc4d
test(fix-backend-build): fixes install dependecies failing
nifedara Jul 16, 2024
9c0e5ff
test(backend-build): restores install project dependencies
nifedara Jul 16, 2024
656e268
test(backend-build): adds install coverage
nifedara Jul 16, 2024
8033d1e
feat(aoi-upload): let user upload aoi from geojson file
kshitijrajsharma Jul 17, 2024
8adf03b
refactor(aoi): clean unused code
kshitijrajsharma Jul 17, 2024
c7f8d2e
Check for frontend build , Remove old version of node
kshitijrajsharma Jul 17, 2024
9d65e42
Remove node restriction
kshitijrajsharma Jul 17, 2024
ec97521
Add dev dependecies ajv
kshitijrajsharma Jul 17, 2024
aff00d1
Restore check for 16 version of node !
kshitijrajsharma Jul 17, 2024
567b77a
Merge pull request #261 from hotosm/feature/upload-AOI
omranlm Jul 17, 2024
7b8ac72
test(github-action): restores makemigrations
nifedara Jul 17, 2024
7fd9f85
test(github-action): adds install factory boy
nifedara Jul 17, 2024
3917c9d
ci(backend-build): runs tests on pr
nifedara Jul 22, 2024
8357abb
Merge branch 'hotosm:master' into test/github-action
nifedara Jul 22, 2024
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
7 changes: 6 additions & 1 deletion .github/workflows/backend_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:

- name: Run tests
env:
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}
TESTING_TOKEN: ${{ os.environ['TESTING_TOKEN'] }}
run: |
cd backend/

Expand All @@ -129,3 +129,8 @@ jobs:
python manage.py migrate
python manage.py migrate login
python manage.py migrate core

pip install coverage
pip install factory-boy
coverage run manage.py test tests
coverage report
50 changes: 24 additions & 26 deletions .github/workflows/frontend_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,41 @@ name: Frontend Build

on:
push:
branches: [ master ]
branches: [master]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build.yml'
- "frontend/**"
- ".github/workflows/frontend_build.yml"
pull_request:
branches: [ master ]
branches: [master]
paths:
- 'frontend/**'
- '.github/workflows/frontend_build.yml'
- "frontend/**"
- ".github/workflows/frontend_build.yml"

jobs:
Build_On_Ubuntu:

runs-on: ubuntu-latest
env:
CI: false

strategy:
matrix:
node-version: [ 16.14.2, 16, 18, 20 ]
node-version: [16, 18, 20]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: |
cd frontend/
npm install --legacy-peer-deps

- name: Build
run: |
cd frontend/
npm run build

- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: |
cd frontend/
npm install --legacy-peer-deps

- name: Build
run: |
cd frontend/
npm run build
2 changes: 1 addition & 1 deletion backend/login/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get(self, request, format=None):


class callback(APIView):
def get(self, request, format=None):
def get(self, request, format=None): # pragma: no cover
"""Callback method redirected from osm callback method

Args:
Expand Down
6 changes: 6 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ distribution = true
dev = [
"commitizen>=3.27.0",
"ruff>=0.4.9",
"coverage>=7.6.0",
]

[tool.commitizen]
Expand All @@ -54,3 +55,8 @@ tag_format = "\"v$version\""
version_scheme = "semver2"
version = "1.0.1"
update_changelog_on_bump = true

[tool.coverage.run]
omit = [
"/usr/*"
]
137 changes: 137 additions & 0 deletions backend/tests/factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import factory
from login.models import OsmUser
from django.contrib.gis.geos import Polygon
from core.models import (
Dataset,
AOI,
Label,
Model,
Training,
Feedback,
FeedbackAOI,
FeedbackLabel,
)


class OsmUserFactory(factory.django.DjangoModelFactory):
class Meta:
model = OsmUser

osm_id = 123456


class DatasetFactory(factory.django.DjangoModelFactory):
class Meta:
model = Dataset

name = "My test dataset"
source_imagery = "https://tiles.openaerialmap.org/5ac4fc6f26964b0010033112/0/5ac4fc6f26964b0010033113/{z}/{x}/{y}"
created_by = factory.SubFactory(OsmUserFactory)


class AoiFactory(factory.django.DjangoModelFactory):
class Meta:
model = AOI

geom = Polygon(
(
(32.588507094820351, 0.348666499011499),
(32.588517512656978, 0.348184682976698),
(32.588869114643053, 0.348171660921362),
(32.588840465592334, 0.348679521066151),
(32.588507094820351, 0.348666499011499),
)
)
dataset = factory.SubFactory(DatasetFactory)


class LabelFactory(factory.django.DjangoModelFactory):
class Meta:
model = Label

aoi = factory.SubFactory(AoiFactory)
geom = Polygon(
(
(32.588507094820351, 0.348666499011499),
(32.588517512656978, 0.348184682976698),
(32.588869114643053, 0.348171660921362),
(32.588840465592334, 0.348679521066151),
(32.588507094820351, 0.348666499011499),
)
)


class ModelFactory(factory.django.DjangoModelFactory):
class Meta:
model = Model

dataset = factory.SubFactory(DatasetFactory)
name = "My test model"
created_by = factory.SubFactory(OsmUserFactory)


class TrainingFactory(factory.django.DjangoModelFactory):
class Meta:
model = Training

model = factory.SubFactory(ModelFactory)
description = "My very first training"
created_by = factory.SubFactory(OsmUserFactory)
epochs = 1
zoom_level = [20, 21]
batch_size = 1


class FeedbackFactory(factory.django.DjangoModelFactory):
class Meta:
model = Feedback

geom = Polygon(
(
(32.588507094820351, 0.348666499011499),
(32.588517512656978, 0.348184682976698),
(32.588869114643053, 0.348171660921362),
(32.588840465592334, 0.348679521066151),
(32.588507094820351, 0.348666499011499),
)
)
training = factory.SubFactory(TrainingFactory)
zoom_level = 19
feedback_type = "TP"
user = factory.SubFactory(OsmUserFactory)
source_imagery = "https://tiles.openaerialmap.org/5ac4fc6f26964b0010033112/0/5ac4fc6f26964b0010033113/{z}/{x}/{y}"


class FeedbackAoiFactory(factory.django.DjangoModelFactory):
class Meta:
model = FeedbackAOI

training = factory.SubFactory(TrainingFactory)
geom = Polygon(
(
(32.588507094820351, 0.348666499011499),
(32.588517512656978, 0.348184682976698),
(32.588869114643053, 0.348171660921362),
(32.588840465592334, 0.348679521066151),
(32.588507094820351, 0.348666499011499),
)
)
label_status = -1
source_imagery = "https://tiles.openaerialmap.org/5ac4fc6f26964b0010033112/0/5ac4fc6f26964b0010033113/{z}/{x}/{y}"
user = factory.SubFactory(OsmUserFactory)


class FeedbackLabelFactory(factory.django.DjangoModelFactory):
class Meta:
model = FeedbackLabel

feedback_aoi = factory.SubFactory(FeedbackAoiFactory)
geom = Polygon(
(
(32.588507094820351, 0.348666499011499),
(32.588517512656978, 0.348184682976698),
(32.588869114643053, 0.348171660921362),
(32.588840465592334, 0.348679521066151),
(32.588507094820351, 0.348666499011499),
)
)
Loading