mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Use GitHub actions (#295)
This commit is contained in:
parent
464c85295a
commit
dcc34570d5
21
.github/workflows/test.yml
vendored
Normal file
21
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Copy config
|
||||||
|
run: cp utils/ci/* .
|
||||||
|
- name: Build the Docker image
|
||||||
|
run: docker-compose build
|
||||||
|
- name: Start Docker
|
||||||
|
run: docker-compose up -d
|
||||||
|
- name: Run migrations
|
||||||
|
run: ./utils/run_migrations.sh
|
||||||
|
- name: Run tests
|
||||||
|
run: ./utils/tests_cov.sh
|
||||||
|
- name: Stop Docker
|
||||||
|
run: docker-compose down
|
@ -1,22 +0,0 @@
|
|||||||
image: docker/compose
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
cache:
|
|
||||||
key: "$CI_COMMIT_REF_SLUG"
|
|
||||||
paths:
|
|
||||||
- /var/lib/docker
|
|
||||||
|
|
||||||
# build:
|
|
||||||
# stage: build
|
|
||||||
# script:
|
|
||||||
# - cp utils/gitlabci/* .
|
|
||||||
# - docker-compose build
|
|
||||||
|
|
||||||
UI_Test:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- cp utils/gitlabci/* .
|
|
||||||
- docker-compose up -d
|
|
||||||
- ./utils/run_migrations.sh
|
|
||||||
- ./utils/tests_cov.sh
|
|
||||||
- docker-compose down
|
|
@ -1,5 +1,5 @@
|
|||||||
# Content Database
|
# Content Database
|
||||||
[![Build status](https://gitlab.com/minetest/contentdb/badges/master/pipeline.svg)](https://gitlab.com/minetest/contentdb/pipelines)
|
![Build Status](https://github.com/minetest/contentdb/workflows/test/badge.svg)
|
||||||
|
|
||||||
Content database for Minetest mods, games, and more.\
|
Content database for Minetest mods, games, and more.\
|
||||||
Developed by rubenwardy, license AGPLv3.0+.
|
Developed by rubenwardy, license AGPLv3.0+.
|
||||||
|
@ -53,7 +53,7 @@ def populate_test_data(session):
|
|||||||
ez.rank = UserRank.EDITOR
|
ez.rank = UserRank.EDITOR
|
||||||
session.add(ez)
|
session.add(ez)
|
||||||
|
|
||||||
not1 = Notification(admin_user, ez, "Awards approved", "/packages/rubenwardy/awards/")
|
not1 = Notification(admin_user, ez, NotificationType.PACKAGE_APPROVAL, "Awards approved", "/packages/rubenwardy/awards/")
|
||||||
session.add(not1)
|
session.add(not1)
|
||||||
|
|
||||||
jeija = User("Jeija")
|
jeija = User("Jeija")
|
||||||
|
@ -795,7 +795,9 @@ class MinetestRelease(db.Model):
|
|||||||
return release
|
return release
|
||||||
|
|
||||||
if protocol_num:
|
if protocol_num:
|
||||||
return MinetestRelease.query.filter_by(protocol=protocol_num).first()
|
# Find the closest matching release
|
||||||
|
return MinetestRelease.query.order_by(db.desc(MinetestRelease.protocol)) \
|
||||||
|
.filter(MinetestRelease.protocol <= protocol_num).first()
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
1
app/tests/__init__.py
Normal file
1
app/tests/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# This makes app/tests a package
|
@ -1,6 +1,7 @@
|
|||||||
from app.default_data import populate_test_data
|
from app.default_data import populate_test_data
|
||||||
from app.models import db, Package, PackageState
|
from app.models import db, Package, PackageState
|
||||||
from utils import parse_json, is_str, is_int, is_optional
|
from .utils import is_str, is_int, is_optional, parse_json
|
||||||
|
from .utils import client # noqa
|
||||||
|
|
||||||
|
|
||||||
def validate_package_list(packages, strict=False):
|
def validate_package_list(packages, strict=False):
|
||||||
@ -73,14 +74,15 @@ def test_packages_with_protocol_high(client):
|
|||||||
populate_test_data(db.session)
|
populate_test_data(db.session)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
rv = client.get("/api/packages/?protocol_version=40")
|
rv = client.get("/api/packages/?protocol_version=100")
|
||||||
|
|
||||||
packages = parse_json(rv.data)
|
packages = parse_json(rv.data)
|
||||||
|
|
||||||
assert len(packages) == 4
|
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
assert package["name"] != "mesecons"
|
assert package["name"] != "mesecons"
|
||||||
|
assert package["name"] != "handholds"
|
||||||
|
|
||||||
|
assert len(packages) == 4
|
||||||
|
|
||||||
validate_package_list(packages, True)
|
validate_package_list(packages, True)
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
from app.default_data import populate_test_data
|
from app.default_data import populate_test_data
|
||||||
from app.models import db
|
from app.models import db
|
||||||
|
from .utils import client # noqa
|
||||||
|
|
||||||
|
|
||||||
def test_homepage_empty(client):
|
def test_homepage_empty(client):
|
||||||
"""Start with a blank database."""
|
"""Start with a blank database."""
|
||||||
|
|
||||||
rv = client.get("/")
|
rv = client.get("/")
|
||||||
assert b"No packages available" in rv.data and b"packagetile" not in rv.data
|
assert b"No packages available" in rv.data and b"packagegridscrub" not in rv.data
|
||||||
|
|
||||||
|
|
||||||
def test_homepage_with_contents(client):
|
def test_homepage_with_contents(client):
|
||||||
@ -17,4 +18,4 @@ def test_homepage_with_contents(client):
|
|||||||
|
|
||||||
rv = client.get("/")
|
rv = client.get("/")
|
||||||
|
|
||||||
assert b"No packages available" not in rv.data and b"packagetile" in rv.data
|
assert b"packagegridscrub" in rv.data
|
||||||
|
Loading…
Reference in New Issue
Block a user