add test for github action
This commit is contained in:
parent
d3889f3cd3
commit
287f848cdd
22 changed files with 54 additions and 56 deletions
47
.github/workflows/django.yml
vendored
Normal file
47
.github/workflows/django.yml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
name: Django CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:12.13-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: admin123
|
||||||
|
POSTGRES_DB: test
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
max-parallel: 4
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.8', '3.11']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install django-ninja
|
||||||
|
pip install django-polymorphic
|
||||||
|
- run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install --yes --no-install-recommends postgresql-client
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
PGPASSWORD=admin123 psql template1 -U postgres -h localhost -c 'create extension hstore;'
|
||||||
|
new_data_model=1 python manage.py makemigrations auth mastodon users books movies games music sync management collection common sync management timeline catalog journal social
|
||||||
|
new_data_model=1 python manage.py test
|
50
.github/workflows/pysa.yml
vendored
50
.github/workflows/pysa.yml
vendored
|
@ -1,50 +0,0 @@
|
||||||
# This workflow uses actions that are not certified by GitHub.
|
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
|
|
||||||
# This workflow integrates Python Static Analyzer (Pysa) with
|
|
||||||
# GitHub's Code Scanning feature.
|
|
||||||
#
|
|
||||||
# Python Static Analyzer (Pysa) is a security-focused static
|
|
||||||
# analysis tool that tracks flows of data from where they
|
|
||||||
# originate to where they terminate in a dangerous location.
|
|
||||||
#
|
|
||||||
# See https://pyre-check.org/docs/pysa-basics/
|
|
||||||
|
|
||||||
name: Pysa
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "master" ]
|
|
||||||
schedule:
|
|
||||||
- cron: '45 12 * * 4'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pysa:
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
|
|
||||||
- name: Run Pysa
|
|
||||||
uses: facebook/pysa-action@f46a63777e59268613bd6e2ff4e29f144ca9e88b
|
|
||||||
with:
|
|
||||||
# To customize these inputs:
|
|
||||||
# See https://github.com/facebook/pysa-action#inputs
|
|
||||||
repo-directory: './'
|
|
||||||
requirements-path: 'requirements.txt'
|
|
||||||
infer-types: true
|
|
||||||
include-default-sapp-filters: true
|
|
|
@ -43,8 +43,10 @@ def get_mock_mode():
|
||||||
|
|
||||||
|
|
||||||
def get_mock_file(url):
|
def get_mock_file(url):
|
||||||
fn = re.sub(r'[^\w]', '_', url)
|
fn = url.replace('***REMOVED***', '1234') # Thank you, Github Action -_-!
|
||||||
return re.sub(r'_key_[A-Za-z0-9]+', '_key_19890604', fn)
|
fn = re.sub(r'[^\w]', '_', fn)
|
||||||
|
fn = re.sub(r'_key_[*A-Za-z0-9]+', '_key_8964', fn)
|
||||||
|
return fn
|
||||||
|
|
||||||
|
|
||||||
class DownloadError(Exception):
|
class DownloadError(Exception):
|
||||||
|
|
|
@ -250,7 +250,6 @@ class Item(SoftDeleteMixin, PolymorphicModel):
|
||||||
# TODO
|
# TODO
|
||||||
# ll = set(lookup_ids)
|
# ll = set(lookup_ids)
|
||||||
# ll = list(filter(lambda a, b: b, ll))
|
# ll = list(filter(lambda a, b: b, ll))
|
||||||
# print(ll)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
METADATA_COPY_LIST = ['title', 'brief'] # list of metadata keys to copy from resource to item
|
METADATA_COPY_LIST = ['title', 'brief'] # list of metadata keys to copy from resource to item
|
||||||
|
|
|
@ -67,7 +67,7 @@ class AbstractSite:
|
||||||
self.resource = ExternalResource(id_type=self.ID_TYPE, id_value=self.id_value, url=self.url)
|
self.resource = ExternalResource(id_type=self.ID_TYPE, id_value=self.id_value, url=self.url)
|
||||||
return self.resource
|
return self.resource
|
||||||
|
|
||||||
def bypass_scrape(self, data_from_link) -> ResourceContent | None:
|
def bypass_scrape(self, data_from_link) -> ResourceContent:
|
||||||
"""subclass may implement this to use data from linked resource and bypass actual scrape"""
|
"""subclass may implement this to use data from linked resource and bypass actual scrape"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ psql $* neodb -c "CREATE EXTENSION hstore WITH SCHEMA public;" || exit $?
|
||||||
|
|
||||||
find -type d -name migrations | xargs rm -rf
|
find -type d -name migrations | xargs rm -rf
|
||||||
|
|
||||||
python3 manage.py makemigrations mastodon users books movies games music sync management collection common sync management catalog journal social || exit $?
|
python3 manage.py makemigrations auth mastodon users books movies games music sync management collection common sync management timeline catalog journal social || exit $?
|
||||||
|
|
||||||
python3 manage.py migrate || exit $?
|
python3 manage.py migrate || exit $?
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ class Preference(models.Model):
|
||||||
class Report(models.Model):
|
class Report(models.Model):
|
||||||
submit_user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='sumbitted_reports', null=True)
|
submit_user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='sumbitted_reports', null=True)
|
||||||
reported_user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='accused_reports', null=True)
|
reported_user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='accused_reports', null=True)
|
||||||
image = models.ImageField(upload_to=report_image_path, height_field=None, width_field=None, max_length=None, blank=True, default='')
|
image = models.ImageField(upload_to=report_image_path, height_field=None, width_field=None, blank=True, default='')
|
||||||
is_read = models.BooleanField(default=False)
|
is_read = models.BooleanField(default=False)
|
||||||
submitted_time = models.DateTimeField(auto_now_add=True)
|
submitted_time = models.DateTimeField(auto_now_add=True)
|
||||||
message = models.CharField(max_length=1000)
|
message = models.CharField(max_length=1000)
|
||||||
|
|
Loading…
Add table
Reference in a new issue