diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..04ce387 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,26 @@ +name: Project Testbot + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +jobs: + test-bot: + name: Testing ${{ github.head_ref || github.ref_name }} + runs-on: ubuntu-latest + container: + image: 'ghcr.io/macaulay2/testbot:latest' + volumes: + - '${{ github.workspace }}:/home/macaulay' + + steps: + - name: Checkout the project repository + uses: actions/checkout@v2 + + - name: Run testbot on project branch + run: | + M2 --script tests/testbot.m2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac40f42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +.#* +.*.swp +*~ diff --git a/tests/example.m2 b/tests/example.m2 new file mode 100644 index 0000000..7e7e5aa --- /dev/null +++ b/tests/example.m2 @@ -0,0 +1,11 @@ +-- Note: to load the necessary packages from the repository, either: +-- first call installPackage in testbot.m2: +-- installPackage("Elimination", FileName => "/home/macaulay/Elimination.m2") +-- or specify the path to needsPackage: +-- needsPackage("Elimination", FileName => "/home/macaulay/Elimination.m2") +needsPackage "Elimination" + +-- test code and assertions +R = ZZ/101[a..d] +I = monomialCurveIdeal(R, {1, 3, 4}) +assert(eliminate(I, {b}) == ideal(c^4-a*d^3)) diff --git a/tests/testbot.m2 b/tests/testbot.m2 new file mode 100644 index 0000000..8f692eb --- /dev/null +++ b/tests/testbot.m2 @@ -0,0 +1,38 @@ +-- This is the default testbot.m2 provided for this workshop. + +-- It contains Macaulay2 code and is automatically run every time you open +-- a pull request or push a new commit to a project branch on the GitHub +-- respository, unless you add the string "[skip ci]" to the commit message. + +-- If you have the software Docker installed and would like to run the same +-- tests locally or run M2 inside a container, use one of these commands from +-- the top directory of the workshop repository: +-- docker run -v "`pwd`":"/home/macaulay" ghcr.io/macaulay2/testbot --script tests/testbot.m2 +-- docker run -v "`pwd`":"/home/macaulay" -it --entrypoint bash ghcr.io/macaulay2/testbot:latest + +-- Uncomment and edit the following line to add your project directories +-- containing Macaulay2 source code files to the load path. Terminate each +-- directory name with a "/". +--path = join( { currentDirectory() | "src/singularities/", ... }, path ) + +-- Uncomment and edit the following lines to preload and check your package or +-- to run a series of examples with every push on GitHub. +--needsPackage "LocalRings" +--check LocalRings +--load "tests/example.m2" +--capture get "tests/example.m2" + +-- The following lines automatically run every file in the "tests" directory. +-- If you wish, you can change testDir to any other directory. +testDir = currentDirectory() | "tests/" + +testFiles = select(readDirectory testDir, + file -> match("\\.m2$", file) and file != "testbot.m2") +printerr("Found ", toString(#testFiles), " test file(s) matching '", testDir, "*.m2'.") +TEST(testFiles / (filename -> testDir | "/" | filename), FileName => true) + +-- workaround for https://github.com/Macaulay2/M2/issues/2835 +importFrom_Core {"PackageIsLoaded"} +User.PackageIsLoaded = true + +check(User, Verbose => true)