Skip to content

Commit

Permalink
Merge pull request #49 from freezingsaddles/add-actions-ci
Browse files Browse the repository at this point in the history
add actions ci
  • Loading branch information
obscurerichard authored Nov 20, 2024
2 parents d876c5b + 5f0602d commit 543011e
Show file tree
Hide file tree
Showing 31 changed files with 195 additions and 105 deletions.
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
# Thanks https://www.reddit.com/r/learnpython/comments/rr6y69/comment/hqeqt68/?utm_source=share&utm_medium=web2x&context=3
ignore = E203, W503, E501

max-line-length = 88
max-complexity = 39
extend-ignore = E203
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
38 changes: 38 additions & 0 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Build and Deploy Latest

on:
push:
branches:
- 'master'

jobs:

build:
uses: freezingsaddles/freezing-web/.github/workflows/[email protected]
concurrency: build-deploy-and-test
with:
tag: latest
repo: freezing-sync
secrets: inherit

deploy:
concurrency: build-deploy-and-test
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- name: install
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
set -euo pipefail
cd /opt/compose
docker-compose pull freezing-sync
docker-compose up -d freezing-sync
15 changes: 15 additions & 0 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Build Tag

on:
push:
tags:
- '*'

jobs:
build:
uses: freezingsaddles/freezing-web/.github/workflows/[email protected]
with:
tag: ${{ github.ref_name }}
repo: freezing-sync
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Build

on: pull_request

jobs:
build:
uses: freezingsaddles/freezing-web/.github/workflows/[email protected]
with:
tag: latest-actions-build
repo: freezing-sync
secrets: inherit
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Lint

on: pull_request

jobs:

# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
lint:
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: black Lint
uses: psf/[email protected]
- name: isort Lint
uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt requirements-test.txt"
- name: flake8 Lint
uses: py-actions/flake8@v2
# There are too many errors to start with to fail on this
continue-on-error: true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# hidden files
.*
# Local config files
.env*
*.cfg

/data/
Expand Down
5 changes: 3 additions & 2 deletions freezing/sync/autolog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import absolute_import
import sys
import logging

import inspect
import logging
import sys


class EagerFormattingAdapter(logging.LoggerAdapter):
Expand Down
4 changes: 2 additions & 2 deletions freezing/sync/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import abc
import logging
import argparse
import logging

from colorlog import ColoredFormatter

from freezing.model import init_model

from freezing.sync.config import config, init_logging
from freezing.sync.exc import CommandError

Expand Down
6 changes: 2 additions & 4 deletions freezing/sync/cli/sync_activities.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from datetime import timedelta, datetime

import arrow
from freezing.model import meta, orm
from pytz import utc
from sqlalchemy import and_

from freezing.model import meta, orm

from freezing.sync.config import config
from freezing.sync.data.activity import ActivitySync

from . import BaseCommand


Expand Down
10 changes: 4 additions & 6 deletions freezing/sync/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
import logging
import os
from datetime import timedelta, tzinfo
import pytz
from typing import List
from datadog import initialize, DogStatsd

import arrow
import pytz
from colorlog import ColoredFormatter
from datadog import DogStatsd, initialize
from envparse import env

import arrow

from freezing.model import init_model

envfile = os.environ.get("APP_SETTINGS", os.path.join(os.getcwd(), ".env"))
Expand Down
4 changes: 2 additions & 2 deletions freezing/sync/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import time
from typing import Union

from stravalib import Client

from freezing.model import meta
from freezing.model.orm import Athlete
from stravalib import Client

from freezing.sync.config import Config


Expand Down
20 changes: 8 additions & 12 deletions freezing/sync/data/activity.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import logging
import re
from typing import List, Optional
from datetime import datetime, timedelta
from typing import List, Optional

import arrow
from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideEffort, RideError, RideGeo, RidePhoto
from geoalchemy import WKTSpatialElement

from sqlalchemy import and_, func
from sqlalchemy.orm import joinedload

from freezing.sync.utils.cache import CachingActivityFetcher
from stravalib import unithelper
from stravalib.exc import ObjectNotFound, AccessUnauthorized, Fault

from stravalib.exc import AccessUnauthorized, Fault, ObjectNotFound
from stravalib.model import Activity, ActivityPhotoPrimary

from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideEffort, RidePhoto, RideError, RideGeo

from freezing.sync.config import config, statsd
from freezing.sync.exc import (
DataEntryError,
CommandError,
ActivityNotFound,
CommandError,
DataEntryError,
IneligibleActivity,
)
from freezing.sync.utils.cache import CachingActivityFetcher

from . import StravaClientForAthlete, BaseSync
from . import BaseSync, StravaClientForAthlete


class ActivitySync(BaseSync):
Expand Down
27 changes: 10 additions & 17 deletions freezing/sync/data/athlete.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
import logging
import re
from typing import List
from datetime import datetime

import arrow
from geoalchemy import WKTSpatialElement

from sqlalchemy import and_
from sqlalchemy.orm import joinedload

from freezing.sync.utils.cache import CachingActivityFetcher
from stravalib import unithelper

from stravalib import model as sm
from stravalib.exc import Fault

from freezing.model import meta
from freezing.model.orm import (
Athlete,
Ride,
RideEffort,
RidePhoto,
RideError,
RideGeo,
RidePhoto,
Team,
)
from geoalchemy import WKTSpatialElement
from sqlalchemy import and_
from sqlalchemy.orm import joinedload
from stravalib import model as sm
from stravalib import unithelper
from stravalib.exc import Fault

from freezing.sync.config import config
from freezing.sync.exc import (
DataEntryError,
CommandError,
DataEntryError,
MultipleTeamsError,
NoTeamsError,
)
from freezing.sync.utils.cache import CachingActivityFetcher

from . import StravaClientForAthlete, BaseSync
from . import BaseSync, StravaClientForAthlete


class AthleteSync(BaseSync):
Expand Down
6 changes: 3 additions & 3 deletions freezing/sync/data/photos.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from instagram import InstagramAPIError
from sqlalchemy import and_

from freezing.model import meta, orm

# from freezing.web.utils.insta import configured_instagram_client, photo_cache_path
from freezing.model.orm import RidePhoto
from instagram import InstagramAPIError
from sqlalchemy import and_

from freezing.sync.data import StravaClientForAthlete

from . import BaseSync
Expand Down
18 changes: 7 additions & 11 deletions freezing/sync/data/streams.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import os
import json
import logging
from typing import Dict, Any, List
from typing import Dict, List

from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideTrack
from geoalchemy import WKTSpatialElement
from polyline.codec import PolylineCodec
from sqlalchemy import update, or_, and_
from sqlalchemy import and_, or_, update
from sqlalchemy.orm import joinedload

from freezing.sync.utils.cache import CachingStreamFetcher
from stravalib.exc import ObjectNotFound
from stravalib.model import Activity, Stream

from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideTrack

from freezing.sync.config import config
from freezing.sync.exc import ConfigurationError, ActivityNotFound
from freezing.sync.exc import ActivityNotFound, ConfigurationError
from freezing.sync.utils import wktutils
from freezing.sync.utils.cache import CachingStreamFetcher

from . import StravaClientForAthlete, BaseSync
from . import BaseSync, StravaClientForAthlete


class StreamSync(BaseSync):
Expand Down
9 changes: 3 additions & 6 deletions freezing/sync/data/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
from decimal import Decimal
from statistics import mean

from sqlalchemy import text

from freezing.model import meta, orm

from freezing.sync.utils.wktutils import parse_point_wkt
from freezing.sync.wx.visualcrossing.api import HistoVisualCrossing
from sqlalchemy import text

from freezing.sync.config import config

from freezing.sync.data import BaseSync
from freezing.sync.utils.wktutils import parse_point_wkt
from freezing.sync.wx.visualcrossing.api import HistoVisualCrossing


# We only synchronize weather for yesterday's rides to avoid syncing early in the day and then having
Expand Down
14 changes: 7 additions & 7 deletions freezing/sync/run.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import arrow
import threading
from apscheduler.schedulers.background import BackgroundScheduler
from greenstalk import Client

import arrow
from apscheduler.schedulers.background import BackgroundScheduler
from freezing.model import init_model
from freezing.model.msg.mq import DefinedTubes
from greenstalk import Client

from freezing.sync.config import config, init_logging
from freezing.sync.autolog import log
from freezing.sync.config import config, init_logging
from freezing.sync.data.activity import ActivitySync
from freezing.sync.data.athlete import AthleteSync
from freezing.sync.data.weather import WeatherSync

# from freezing.sync.workflow import configured_publisher
from freezing.sync.subscribe import ActivityUpdateSubscriber
from freezing.sync.data.activity import ActivitySync
from freezing.sync.data.weather import WeatherSync
from freezing.sync.data.athlete import AthleteSync


def main():
Expand Down
Loading

0 comments on commit 543011e

Please sign in to comment.