From 64d4bcb70c4e56cc780d5beb86b2c32c1cff9ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Puiggen=C3=A9?= Date: Thu, 13 Jun 2024 11:10:43 +0200 Subject: [PATCH] Travis --> Github actions --- .github/workflows/build-and-test.yml | 30 ++++++++ .travis.yml | 21 ------ README.rst | 4 +- buildout.cfg | 95 ++------------------------ requirements.txt | 2 +- src/senaite/ast/tests/base.py | 64 ++++++++++------- src/senaite/ast/tests/layers.py | 75 -------------------- src/senaite/ast/tests/test_doctests.py | 4 +- travis.cfg | 22 ------ 9 files changed, 78 insertions(+), 239 deletions(-) create mode 100644 .github/workflows/build-and-test.yml delete mode 100644 .travis.yml delete mode 100644 src/senaite/ast/tests/layers.py delete mode 100644 travis.cfg diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..d03c05a --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,30 @@ +name: build and test senaite.ast +on: + - push + - pull_request +env: + PLONE_VERSION: "5.2" +jobs: + build-and-test: + runs-on: 'ubuntu-20.04' + container: + image: python:2.7.18-buster + steps: + - uses: actions/checkout@v3 + - name: cache eggs + uses: actions/cache@v3 + with: + key: eggs-cache-${{ hashFiles('buildout.cfg', 'requirements.txt') }} + path: | + eggs/ + - name: install + run: | + pip install virtualenv + virtualenv -p `which python` . + bin/pip install --upgrade pip + bin/pip install -r requirements.txt + bin/buildout -N -t 3 annotate + bin/buildout -N -t 3 + - name: test + run: | + bin/test -s senaite.ast.tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f97fdaa..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: ~> 1.0 -language: python -os: linux -dist: xenial -cache: - pip: true - directories: - - eggs -matrix: - fast_finish: true - include: - - python: "2.7" - env: PLONE_VERSION="5.2" -before_install: - - virtualenv -p `which python` . - - bin/pip install -r requirements.txt - - bin/buildout -N -t 3 annotate -install: - - bin/buildout -N -t 3 -script: - - bin/test -s senaite.ast diff --git a/README.rst b/README.rst index 1e8c076..192ab42 100644 --- a/README.rst +++ b/README.rst @@ -4,8 +4,8 @@ Antibiotic Sensitivity Testing (AST) for SENAITE .. image:: https://img.shields.io/pypi/v/senaite.ast.svg?style=flat-square :target: https://pypi.python.org/pypi/senaite.ast -.. image:: https://img.shields.io/travis/com/senaite/senaite.ast/master.svg?style=flat-square - :target: https://app.travis-ci.com/github/senaite/senaite.ast +.. image:: https://img.shields.io/github/actions/workflow/status/senaite/senaite.ast/build-and-test.yml?branch=2.x + :target: https://github.com/senaite/senaite.ast/actions/workflows/build-and-test.yml?query=branch:2.x .. image:: https://readthedocs.org/projects/pip/badge/ :target: https://senaiteast.readthedocs.org diff --git a/buildout.cfg b/buildout.cfg index 3f7ef16..4d67720 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,105 +1,18 @@ [buildout] -index = https://pypi.org/simple/ -extends = https://dist.plone.org/release/5.2-latest/versions.cfg -find-links = - https://dist.plone.org/release/5.2-latest/ - https://dist.plone.org/thirdparty/ +extends = https://raw.githubusercontent.com/senaite/senaite.core/2.x/buildout.cfg + +package-name = senaite.ast parts = instance test omelette - i18ndude - zopepy update_translations write_code_headers -eggs = - senaite.core - senaite.app.listing - senaite.app.spotlight - senaite.app.supermodel - senaite.impress - senaite.jsonapi - senaite.lims - senaite.abx - senaite.microorganism - senaite.ast - plone.reload - Products.PrintingMailHost - -extensions = mr.developer - -package-name = senaite.ast - -versions = versions -show-picked-versions = true - -plone-user = admin:admin - -develop = . -sources = sources -auto-checkout = * - [sources] -senaite.core = git https://github.com/senaite/senaite.core.git branch=2.x -senaite.app.listing = git https://github.com/senaite/senaite.app.listing.git branch=2.x -senaite.app.spotlight = git https://github.com/senaite/senaite.app.spotlight.git branch=2.x -senaite.app.supermodel = git https://github.com/senaite/senaite.app.supermodel.git branch=2.x -senaite.impress = git https://github.com/senaite/senaite.impress.git branch=2.x -senaite.jsonapi = git https://github.com/senaite/senaite.jsonapi.git branch=2.x -senaite.lims = git https://github.com/senaite/senaite.lims.git branch=2.x -senaite.abx = git https://github.com/senaite/senaite.abx.git -senaite.microorganism = git https://github.com/senaite/senaite.microorganism.git - -[instance] -recipe = plone.recipe.zope2instance -http-address = 127.0.0.1:8080 -user = ${buildout:plone-user} -wsgi = on -eggs = - Plone - plone.app.upgrade - ${buildout:package-name} - ${buildout:eggs} -deprecation-warnings = on -environment-vars = - zope_i18n_compile_mo_files true -zcml = - -[i18ndude] -unzip = true -recipe = zc.recipe.egg -eggs = i18ndude - -[update_translations] -recipe = collective.recipe.template -output = ${buildout:directory}/bin/update_translations -input = ${buildout:directory}/templates/update_translations.in -mode = 755 - -[write_code_headers] -recipe = collective.recipe.template -output = ${buildout:directory}/bin/write_code_headers -input = ${buildout:directory}/templates/write_code_headers.py.in -mode = 755 +senaite.core = git https://github.com/senaite/senaite.core.git [test] -recipe = zc.recipe.testrunner -defaults = ['--auto-color', '--auto-progress'] eggs = senaite.ast [test] - -[omelette] -recipe = collective.recipe.omelette -eggs = ${buildout:eggs} - -[zopepy] -recipe = zc.recipe.egg -eggs = ${instance:eggs} -interpreter = zopepy -scripts = zopepy - -[versions] -setuptools = -zc.buildout = diff --git a/requirements.txt b/requirements.txt index b65a7a0..1e1b3ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -setuptools==42.0.2 +setuptools==44.1.1 zc.buildout==2.13.3 wheel diff --git a/src/senaite/ast/tests/base.py b/src/senaite/ast/tests/base.py index ad490c7..07ea9e4 100644 --- a/src/senaite/ast/tests/base.py +++ b/src/senaite/ast/tests/base.py @@ -18,31 +18,45 @@ # Copyright 2020-2024 by it's authors. # Some rights reserved, see README and LICENSE. -from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles -from plone.app.testing.bbb_at import PloneTestCase -from plone.protect.authenticator import createToken -from senaite.ast.tests.layers import BASE_TESTING +import transaction +from plone.app.testing import applyProfile +from plone.app.testing import FunctionalTesting +from plone.testing import zope +from senaite.core.tests.base import BaseTestCase +from senaite.core.tests.layers import BaseLayer -class BaseTestCase(PloneTestCase): - """Use for test cases which do not rely on the demo data +class SimpleTestLayer(BaseLayer): + + def setUpZope(self, app, configurationContext): + super(SimpleTestLayer, self).setUpZope(app, configurationContext) + + # Load ZCML + import senaite.abx + import senaite.microorganism + self.loadZCML(package=senaite.abx) + self.loadZCML(package=senaite.microorganism) + self.loadZCML(package=senaite.ast) + + # Install product and call its initialize() function + zope.installProduct(app, "senaite.abx") + zope.installProduct(app, "senaite.microorganism") + zope.installProduct(app, "senaite.ast") + + def setUpPloneSite(self, portal): + super(SimpleTestLayer, self).setUpPloneSite(portal) + applyProfile(portal, "senaite.ast:default") + transaction.commit() + + +SIMPLE_TEST_LAYER_FIXTURE = SimpleTestLayer() +SIMPLE_TESTING = FunctionalTesting( + bases=(SIMPLE_TEST_LAYER_FIXTURE, ), + name="senaite.ast:SimpleTesting" +) + + +class SimpleTestCase(BaseTestCase): + """Use for test cases which do not rely on demo data """ - layer = BASE_TESTING - - def setUp(self): - super(BaseTestCase, self).setUp() - # Fixing CSRF protection - # https://github.com/plone/plone.protect/#fixing-csrf-protection-failures-in-tests - self.request = self.layer["request"] - # Disable plone.protect for these tests - self.request.form["_authenticator"] = createToken() - # Eventuelly you find this also useful - self.request.environ["REQUEST_METHOD"] = "POST" - - setRoles(self.portal, TEST_USER_ID, ["LabManager", "Manager"]) - - # Default skin is set to "Sunburst Theme"! - # => This causes an `AttributeError` when we want to access - # e.g. 'guard_handler' FSPythonScript - self.portal.changeSkin("Plone Default") + layer = SIMPLE_TESTING diff --git a/src/senaite/ast/tests/layers.py b/src/senaite/ast/tests/layers.py deleted file mode 100644 index dafc302..0000000 --- a/src/senaite/ast/tests/layers.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of SENAITE.AST. -# -# SENAITE.AST is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation, version 2. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Copyright 2020-2024 by it's authors. -# Some rights reserved, see README and LICENSE. - -import transaction -from plone.app.testing import applyProfile -from plone.app.testing import FunctionalTesting -from plone.app.testing import PLONE_FIXTURE -from plone.app.testing import PloneSandboxLayer -from plone.testing import zope - - -class BaseLayer(PloneSandboxLayer): - defaultBases = (PLONE_FIXTURE,) - - def setUpZope(self, app, configurationContext): - super(BaseLayer, self).setUpZope(app, configurationContext) - - # Load ZCML - import bika.lims - import senaite.app.listing - import senaite.app.spotlight - import senaite.core - import senaite.abx - import senaite.ast - import senaite.impress - import senaite.microorganism - - self.loadZCML(package=bika.lims) - self.loadZCML(package=senaite.core) - self.loadZCML(package=senaite.app.listing) - self.loadZCML(package=senaite.app.spotlight) - self.loadZCML(package=senaite.impress) - self.loadZCML(package=senaite.lims) - self.loadZCML(package=senaite.abx) - self.loadZCML(package=senaite.microorganism) - self.loadZCML(package=senaite.ast) - - # Install product and call its initialize() function - zope.installProduct(app, "bika.lims") - zope.installProduct(app, "senaite.core") - zope.installProduct(app, "senaite.app.listing") - zope.installProduct(app, "senaite.app.spotlight") - zope.installProduct(app, "senaite.impress") - zope.installProduct(app, "senaite.lims") - zope.installProduct(app, "senaite.abx") - zope.installProduct(app, "senaite.microorganism") - zope.installProduct(app, "senaite.ast") - - def setUpPloneSite(self, portal): - # Install into Plone site using portal_setup - applyProfile(portal, "senaite.core:default") - applyProfile(portal, "senaite.ast:default") - transaction.commit() - - -BASE_LAYER_FIXTURE = BaseLayer() -BASE_TESTING = FunctionalTesting( - bases=(BASE_LAYER_FIXTURE,), name="SENAITE.AST:BaseTesting") diff --git a/src/senaite/ast/tests/test_doctests.py b/src/senaite/ast/tests/test_doctests.py index 2cb7b28..a472506 100644 --- a/src/senaite/ast/tests/test_doctests.py +++ b/src/senaite/ast/tests/test_doctests.py @@ -25,7 +25,7 @@ import unittest2 as unittest from senaite.ast import PRODUCT_NAME -from senaite.ast.tests.base import BaseTestCase +from senaite.ast.tests.base import SimpleTestCase from Testing import ZopeTestCase as ztc # Option flags for doctests @@ -38,7 +38,7 @@ def test_suite(): suite.addTests([ ztc.ZopeDocFileSuite( doctestfile, - test_class=BaseTestCase, + test_class=SimpleTestCase, optionflags=flags ) ]) diff --git a/travis.cfg b/travis.cfg deleted file mode 100644 index 0a97142..0000000 --- a/travis.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[buildout] -extends = - buildout.cfg - -parts = - instance - test - -[test] -recipe = collective.xmltestreport -defaults = ['--auto-color', '--auto-progress'] -eggs = - senaite.ast [test] - -# network speedup -socket-timeout = 5 -allow-hosts = - *.python.org - docutils.sourceforge.net - prdownloads.sourceforge.net - effbot.org - dist.plone.org