Skip to content

Commit

Permalink
added workshop testbot
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed May 29, 2024
1 parent 247049d commit c21e078
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests/example.m2
Original file line number Diff line number Diff line change
@@ -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))
38 changes: 38 additions & 0 deletions tests/testbot.m2
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c21e078

Please sign in to comment.