This is a basic template of a dev environment to edit, make a package module, compile, debug, test, commit/push the objectscript code with InterSystems IRIS.
The idea of the repository is to provide a read-to-go dev environment if one needs to code InterSystems ObjectScript.
- The template runs InterSystems IRIS Community Edition running in a docker container
- It creates a fresh new namespace and database IRISAPP
- It loads the ObjectScript code into IRISAPP database using Package Manager
- It suggests development with 'Package First' paradigm. Watch the video](https://www.youtube.com/watch?v=havPyPbUj1I)
- Provides unittests environment: sample unittests, tests module enablement
start a new dev repository with InterSystems IRIS using this one as a template. Once you clone the new repo on your laptop and open the VSCode with installed InterSystems Pack you'll be able to start development immediately
Make sure you have git and Docker desktop installed.
Clone/git pull the repo into any local directory
$ git clone https://github.com/intersystems-community/intersystems-iris-dev-template.git
Open the terminal in this directory and call the command to build and run InterSystems IRIS in container:
$ docker-compose up -d
To open IRIS Terminal do:
$ docker-compose exec iris iris session iris -U IRISAPP
IRISAPP>
To exit the terminal, do any of the following:
Enter HALT or H (not case-sensitive)
THe sample repository contains two simplest examples of ObjectScript classes: ObjectScript method that returns value and method that creates a persistent record. 1. Open IRIS terminal and run the ObjectScript Test() method to see if runs the script and returns values from IRIS:
$ docker-compose exec iris iris session iris -U IRISAPP
IRISAPP>write ##class(dc.sample.ObjectScript).Test()
It works!
42
Class dc.sample.PersistentClass contains a method CreateRecord that creates an object with one property Test and returns its id. Open IRIS terminal and run:
IRISAPP>write ##class(dc.sample.PersistentClass).CreateRecord(.id)
1
IRISAPP>write id
1
In your case the value of id could be different. And it will be different with every call of the method.
You can check whether the record exists and try to right the property of the object by its id.
IRISAPP>write ##class(dc.sample.PersistentClass).ReadProperty(id)
Test string
This repository is ready to code in VSCode with ObjectScript plugin.
Install VSCode, Docker and ObjectScript plugin and open the folder in VSCode.
Open /src/cls/PackageSample/ObjectScript.cls class and try to make changes - it will be compiled in running IRIS docker container.
Feel free to delete PackageSample folder and place your ObjectScript classes in a form /src/organisation/package/Classname.cls Read more about folder setup for InterSystems ObjectScript and her on the naming convention
The template contains to test classes: TestObjectScript.cls and TestPersistentClass.cls To run the unittests we can use Package Manager environment.
IRISAPP>zpm
=============================================================================
|| Welcome to the Package Manager Shell (ZPM). ||
|| Enter q/quit to exit the shell. Enter ?/help to view available commands ||
=============================================================================
zpm:IRISAPP>load /irisrun/repo
[dc-sample-template] Reload START (/irisrun/repo/)
[dc-sample-template] Reload SUCCESS
[dc-sample-template] Module object refreshed.
[dc-sample-template] Validate START
[dc-sample-template] Validate SUCCESS
[dc-sample-template] Compile START
[dc-sample-template] Compile SUCCESS
[dc-sample-template] Activate START
[dc-sample-template] Configure START
[dc-sample-template] Configure SUCCESS
[dc-sample-template] MakeDeployed START
[dc-sample-template] MakeDeployed SUCCESS
[dc-sample-template] Activate SUCCESS
zpm:IRISAPP>test dc-sample-template
[dc-sample-template] Reload START (/irisrun/repo/)
[dc-sample-template] Reload SUCCESS
[dc-sample-template] Module object refreshed.
[dc-sample-template] Validate START
[dc-sample-template] Validate SUCCESS
[dc-sample-template] Compile START
[dc-sample-template] Compile SUCCESS
[dc-sample-template] Activate START
[dc-sample-template] Configure START
[dc-sample-template] Configure SUCCESS
[dc-sample-template] MakeDeployed START
[dc-sample-template] MakeDeployed SUCCESS
[dc-sample-template] Activate SUCCESS
[dc-sample-template] Test STARTIt works!
Use the following URL to view the result:
http://172.28.0.2:52773/csp/sys/%25UnitTest.Portal.Indices.cls?Index=1&$NAMESPACE=IRISAPP
All PASSED
[dc-sample-template] Test SUCCESS
zpm:IRISAPP>
In case of test errors you can check it back in the UnitTest portal, that can be easily opened via ObjectScript menu in VSCode:
it contains to github actions workflows:
- github-registry.yml Once changes pushed to the repo, the action builds the docker image on Github side and pushes the image to Github registry that can be very convenient to further cloud deployement, e.g. kubernetes.
- objectscript-qaulity.yml with every push to master or main branch the workflow launches the repo test on objectscript issues with Objectscript Quality tool, see the examples. This works if the repo is open-source only.
Both workflows are repo agnostic: so they work with any repository where they exist.
it contains to files to setup vscode environment:
Settings file to let you immedietly code in VSCode with VSCode ObjectScript plugin)
Config file if you want to debug with VSCode ObjectScript
contains source files. src/iris contains InterSystems IRIS Objectscript code
contains unittests for the ObjectScript classes
contains a set of useful commands that will help during the development
a docker engine helper file to manage images building and rule ports mapping an the host to container folders(volumes) mapping
The simplest dockerfile which starts IRIS and imports code from /src folder into it. Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders.
contains objectscript commands that are feeded to iris during the image building
IPM Module's description of the code in the repository. It describes what is loaded with the method, how it is being tested and what apps neeed to be created, what files need to be copied.