Skip to content

Commit 53db5cd

Browse files
committed
Merge branch 'main' into better-initialization
2 parents 71f083c + 4472cc3 commit 53db5cd

File tree

5 files changed

+148
-2
lines changed

5 files changed

+148
-2
lines changed

.github/workflows/main.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
[push, pull_request]
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
# This workflow contains a single job called "build"
13+
build:
14+
# The type of runner that the job will run on
15+
runs-on: ubuntu-latest
16+
17+
env:
18+
#Environment variables usable throughout the "build" job, e.g. in OS-level commands
19+
20+
# ** FOR GENERAL USE, LIKELY NEED TO CHANGE **
21+
package: git-source-control
22+
container_image: intersystemsdc/iris-community:latest
23+
24+
# ** FOR GENERAL USE, MAY NEED TO CHANGE **
25+
build_flags: -dev -verbose
26+
test_package: UnitTest
27+
28+
# ** FOR GENERAL USE, SHOULD NOT NEED TO CHANGE **
29+
instance: iris
30+
artifact_dir: build-artifacts
31+
32+
# Note: test_reports value is duplicated in test_flags environment variable
33+
test_reports: test-reports
34+
test_flags: >-
35+
-verbose -DUnitTest.ManagerClass=TestCoverage.Manager -DUnitTest.JUnitOutput=/test-reports/junit.xml
36+
-DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=TestCoverage.Manager
37+
-DUnitTest.UserParam.CoverageReportClass=TestCoverage.Report.Cobertura.ReportGenerator
38+
-DUnitTest.UserParam.CoverageReportFile=/source/coverage.xml
39+
40+
# Steps represent a sequence of tasks that will be executed as part of the job
41+
steps:
42+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
43+
- uses: actions/checkout@v3
44+
45+
- name: Run Container
46+
run: |
47+
# Create test_reports directory to share test results before running container
48+
mkdir $test_reports
49+
chmod 777 $test_reports
50+
51+
# Same for artifact directory
52+
mkdir $artifact_dir
53+
chmod 777 $artifact_dir
54+
55+
# Run InterSystems IRIS Instance
56+
docker pull $container_image
57+
docker run -d -h $instance --name $instance -v $GITHUB_WORKSPACE:/source:rw -v $GITHUB_WORKSPACE/$test_reports:/$test_reports:rw -v $GITHUB_WORKSPACE/$artifact_dir:/$artifact_dir:rw --init $container_image
58+
echo halt > wait
59+
# Wait for instance to be ready
60+
until docker exec --interactive $instance iris session $instance < wait; do sleep 1; done
61+
62+
- name: Install TestCoverage
63+
run: |
64+
echo "zpm \"install testcoverage\":1:1" > install-testcoverage
65+
docker exec --interactive $instance iris session $instance -B < install-testcoverage
66+
67+
- name: Build and Test
68+
run: |
69+
# Run build
70+
echo "zpm \"load /source $build_flags\":1:1" > build.script
71+
# Test package is compiled first as a workaround for some dependency issues.
72+
echo "do \$System.OBJ.CompilePackage(\"$test_package\",\"ckd\") " > test.script
73+
# Run tests
74+
echo "zpm \"$package test -only $test_flags\":1:1" >> test.script
75+
docker exec --interactive $instance iris session $instance -B < build.script && docker exec --interactive $instance iris session $instance -B < test.script &&bash <(curl -s https://codecov.io/bash)
76+
77+
- name: Produce CE Artifact
78+
run: |
79+
echo "set version=##class(%ZPM.PackageManager.Developer.Module).NameOpen(\"git-source-control\").VersionString" > package.script
80+
echo "set file=\"/$artifact_dir/git-source-control-\"_version_\".xml\" write !,file,!" >> package.script
81+
echo "do ##class(SourceControl.Git.Utils).BuildCEInstallationPackage(file)" >> package.script
82+
echo "halt" >> package.script
83+
docker exec --interactive $instance iris session $instance -B < package.script
84+
echo $GITHUB_WORKSPACE/$artifact_dir
85+
ls $GITHUB_WORKSPACE/$artifact_dir
86+
87+
- name: Attach CE Artifact
88+
uses: actions/upload-artifact@v3
89+
if: always()
90+
with:
91+
name: "PreIRISInstallationPackage"
92+
path: ${{ github.workspace }}/${{ env.artifact_dir }}/*.xml
93+
if-no-files-found: error
94+
95+
- name: XUnit Viewer
96+
id: xunit-viewer
97+
uses: AutoModality/action-xunit-viewer@v1
98+
if: always()
99+
with:
100+
# With -DUnitTest.FailuresAreFatal=1 a failed unit test will fail the build before this point.
101+
# This action would otherwise misinterpret our xUnit style output and fail the build even if
102+
# all tests passed.
103+
fail: false
104+
105+
- name: Attach the report
106+
uses: actions/upload-artifact@v1
107+
if: always()
108+
with:
109+
name: ${{ steps.xunit-viewer.outputs.report-name }}
110+
path: ${{ steps.xunit-viewer.outputs.report-dir }}

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Changed
1919
- Various minor things under the hood to support use without the package manager and/or on older platforms
2020

21+
### Internal
22+
- Added CI script and tweaked unit tests to run properly in a container and bootstrap their own extension configuration
23+
2124
## [2.0.5] - 2022-12-02
2225

2326
### Fixed

test/UnitTest/SourceControl/Git/AddRemove.cls

+31
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Import SourceControl.Git
33
Class UnitTest.SourceControl.Git.AddRemove Extends %UnitTest.TestCase
44
{
55

6+
Method TestInit()
7+
{
8+
new %SourceControl
9+
do ##class(%Studio.SourceControl.Interface).SourceControlCreate()
10+
set sc = %SourceControl.UserAction(0,"%SourceMenu,Init","","",.action,.target,.msg,.reload)
11+
do $$$AssertStatusOK(sc)
12+
}
13+
614
Method TestMac()
715
{
816
do $$$AssertEquals(##class(Utils).IsInSourceControl("test.mac"),0)
@@ -34,5 +42,28 @@ Method OnBeforeAllTests() As %Status
3442
quit $$$OK
3543
}
3644

45+
Property InitialExtension As %String [ InitialExpression = {##class(%Studio.SourceControl.Interface).SourceControlClassGet()} ];
46+
47+
Property SourceControlGlobal [ MultiDimensional ];
48+
49+
Method %OnNew(initvalue) As %Status
50+
{
51+
Merge ..SourceControlGlobal = ^SYS("SourceControl")
52+
Kill ^SYS("SourceControl")
53+
Set folder = ##class(%Library.File).NormalizeFilename(##class(%Library.File).TempFilename()_"dir/")
54+
Set ^SYS("SourceControl","Git","settings","namespaceTemp") = folder
55+
Set ^SYS("SourceControl","Git","settings","mappings","MAC","*")="rtn/"
56+
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension")
57+
Quit ##super(initvalue)
58+
}
59+
60+
Method %OnClose() As %Status [ Private, ServerOnly = 1 ]
61+
{
62+
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension)
63+
Kill ^SYS("SourceControl")
64+
Merge ^SYS("SourceControl") = ..SourceControlGlobal
65+
Quit $$$OK
66+
}
67+
3768
}
3869

test/UnitTest/SourceControl/Git/NameToInternalNameTest.cls

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ Method OnBeforeAllTests() As %Status
9797
set ..OldNamespaceTemp = settings.namespaceTemp
9898
set ..OldPercentClassReplace = settings.percentClassReplace
9999
merge ..Mappings = @##class(SourceControl.Git.Utils).MappingsNode()
100-
set settings.namespaceTemp = $Piece(..Manager.CurrentDir,"test",1)
100+
set folder = ##class(%File).NormalizeDirectory(##class(%Library.File).TempFilename()_"dir/")
101+
set settings.namespaceTemp = folder
101102
set settings.percentClassReplace = "_"
102103
$$$ThrowOnError(settings.%Save())
104+
do ##class(%Library.File).CopyDir($Piece(..Manager.CurrentDir,"test"),folder,1)
103105
kill @##class(SourceControl.Git.Utils).MappingsNode()
104106
Set app = $System.CSP.GetDefaultApp($Namespace)
105107
If (app '= "") {
@@ -127,4 +129,3 @@ Method %OnClose() As %Status
127129
}
128130

129131
}
130-

test/UnitTest/coverage.list

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SourceControl.Git.PKG

0 commit comments

Comments
 (0)