Skip to content

Commit

Permalink
Update CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Sep 4, 2024
1 parent 3c7aa88 commit a08783f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .github/deploy/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
dest: ~/docker-compose.yaml
mode: '0644'

- name: Copy Makefile
ansible.builtin.copy:
src: '{{ playbook_dir }}/../../Makefile'
dest: ~/Makefile
mode: '0644'

- name: Stop Services
shell:
cmd: 'docker-compose rm --stop --force'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: poetry
cache-dependency-path: backend/poetry.lock
python-version: '3.12'
- name: Run pre-commit
uses: pre-commit/[email protected]
Expand Down Expand Up @@ -58,6 +60,8 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: poetry
cache-dependency-path: backend/poetry.lock
python-version: '3.12'

- name: Install dependencies
Expand Down
50 changes: 28 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
build:
@docker compose build
@CMD="poetry install" $(MAKE) run-backend-local-command
@CMD="poetry run python manage.py migrate" $(MAKE) run-backend-local-command
@CMD="poetry install" $(MAKE) run-backend-command
@CMD="poetry run python manage.py migrate" $(MAKE) run-backend-command

collect-static:
@CMD="poetry run python manage.py collectstatic --noinput" $(MAKE) run-backend-local-command
@CMD="poetry run python manage.py collectstatic --noinput" $(MAKE) run-backend-command

github-sync-owasp-organization:
@CMD="poetry run python manage.py github_sync_owasp_organization" $(MAKE) run-backend-command

github-sync-related-repositories:
@CMD="poetry run python manage.py github_sync_related_repositories" $(MAKE) run-backend-command

migrate:
@CMD="poetry run python manage.py migrate" $(MAKE) run-backend-local-command
@CMD="poetry run python manage.py migrate" $(MAKE) run-backend-command

migrations:
@CMD="poetry run python manage.py makemigrations" $(MAKE) run-backend-local-command
@CMD="poetry run python manage.py makemigrations" $(MAKE) run-backend-command

run:
@docker compose up
owasp-scrape-site-data:
@CMD="poetry run python manage.py owasp_scrape_site_data" $(MAKE) run-backend-command

owasp-update-projects:
@CMD="poetry run python manage.py owasp_update_projects" $(MAKE) run-backend-command

pre-commit:
@pre-commit run -a

run-backend-local-command:
@docker compose run --rm backend-local $(CMD)
run:
@docker compose up

run-backend-command:
@docker compose run --rm backend $(CMD)

shell:
@CMD="/bin/bash" $(MAKE) run-backend-local-command
@CMD="/bin/bash" $(MAKE) run-backend-command

sync:
$(MAKE) github-sync-owasp-organization
$(MAKE) owasp-scrape-site-data
$(MAKE) github-sync-related-repositories
$(MAKE) owasp-update-projects

test:
@cd backend && poetry run pytest; cd ..

github-sync-owasp-organization:
@CMD="poetry run python manage.py github_sync_owasp_organization" $(MAKE) run-backend-local-command

github-sync-related-repositories:
@CMD="poetry run python manage.py github_sync_related_repositories" $(MAKE) run-backend-local-command

owasp-scrape-site-data:
@CMD="poetry run python manage.py owasp_scrape_site_data" $(MAKE) run-backend-local-command

owasp-update-projects:
@CMD="poetry run python manage.py owasp_update_projects" $(MAKE) run-backend-local-command
11 changes: 9 additions & 2 deletions backend/apps/github/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Github app."""

from django.conf import settings
import logging

from github.GithubException import UnknownObjectException

from apps.github.models.issue import Issue
from apps.github.models.label import Label
Expand All @@ -10,6 +12,8 @@
from apps.github.models.user import User
from apps.github.utils import check_owasp_site_repository

logger = logging.getLogger(__name__)


def sync_repository(gh_repository, organization=None, user=None):
"""Sync GitHub repository data."""
Expand Down Expand Up @@ -76,7 +80,10 @@ def sync_repository(gh_repository, organization=None, user=None):
# Labels.
issue.labels.clear()
for gh_issue_label in gh_issue.labels:
issue.labels.add(Label.update_data(gh_issue_label))
try:
issue.labels.add(Label.update_data(gh_issue_label))
except UnknownObjectException:
logger.info("Couldn't get GitHub issue label %s", issue.url)

# GitHub repository releases.
releases = []
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
backend-local:
backend:
container_name: nest-backend
command: >
bash -c
Expand Down

0 comments on commit a08783f

Please sign in to comment.