Skip to content

Commit 94d2ba7

Browse files
authored
Add build/test/IRIS package script
1 parent b0560f6 commit 94d2ba7

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/main.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
artifacts: artifacts
31+
# Note: test_reports value is duplicated in test_flags environment variable
32+
test_reports: test-reports
33+
test_flags: >-
34+
-verbose -DUnitTest.ManagerClass=TestCoverage.Manager -DUnitTest.JUnitOutput=/test-reports/junit.xml
35+
-DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=TestCoverage.Manager
36+
-DUnitTest.UserParam.CoverageReportClass=TestCoverage.Report.Cobertura.ReportGenerator
37+
-DUnitTest.UserParam.CoverageReportFile=/source/coverage.xml
38+
39+
# Steps represent a sequence of tasks that will be executed as part of the job
40+
steps:
41+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
42+
- uses: actions/checkout@v3
43+
44+
- name: Run Container
45+
run: |
46+
# Create test_reports directory to share test results before running container
47+
mkdir $test_reports
48+
chmod 777 $test_reports
49+
50+
# Run InterSystems IRIS Instance
51+
docker pull $container_image
52+
docker run -d -h $instance --name $instance -v $GITHUB_WORKSPACE:/source:rw -v $GITHUB_WORKSPACE/$test_reports:/$test_reports -v $GITHUB_WORKSPACE/$artifacts:/$artifacts --init $container_image
53+
echo halt > wait
54+
# Wait for instance to be ready
55+
until docker exec --interactive $instance iris session $instance < wait; do sleep 1; done
56+
57+
- name: Install TestCoverage
58+
run: |
59+
echo "zpm \"install testcoverage\":1:1" > install-testcoverage
60+
docker exec --interactive $instance iris session $instance -B < install-testcoverage
61+
# WOrkaround for permissions issues in TestCoverage (creating directory for source export)
62+
chmod 777 $GITHUB_WORKSPACE
63+
chmod -R 777 $GITHUB_WORKSPACE/tests/_reference/compare
64+
65+
66+
- name: Build and Test
67+
run: |
68+
# Run build
69+
echo "zpm \"load /source $build_flags\":1:1" > build
70+
# Test package is compiled first as a workaround for some dependency issues.
71+
echo "do \$System.OBJ.CompilePackage(\"$test_package\",\"ckd\") " > test
72+
# Run tests
73+
echo "zpm \"$package test -only $test_flags\":1:1" >> test
74+
docker exec --interactive $instance iris session $instance -B < build && docker exec --interactive $instance iris session $instance -B < test &&bash <(curl -s https://codecov.io/bash)
75+
76+
- name: Produce CE Artifact
77+
run: |
78+
#
79+
echo "set version=##class(%ZPM.PackageManager.Developer.Module).NameOpen(\"git-source-control\").Version" > package
80+
echo "do ##class(SourceControl.Git.Utils).BuildCEInstallationPackage(\"$artifacts/git-source-control-\"_version_\".xml\")" >> package
81+
echo "halt" >> package
82+
docker exec --interactive $instance iris session $instance -B < package
83+
84+
- name: Attache CE Artifact
85+
uses: actions/upload-artifact@v1
86+
if: always()
87+
with:
88+
name: "PreIRISInstallationPackage"
89+
path: ${{ artifacts }}
90+
91+
- name: XUnit Viewer
92+
id: xunit-viewer
93+
uses: AutoModality/action-xunit-viewer@v1
94+
if: always()
95+
with:
96+
# With -DUnitTest.FailuresAreFatal=1 a failed unit test will fail the build before this point.
97+
# This action would otherwise misinterpret our xUnit style output and fail the build even if
98+
# all tests passed.
99+
fail: false
100+
101+
- name: Attach the report
102+
uses: actions/upload-artifact@v1
103+
if: always()
104+
with:
105+
name: ${{ steps.xunit-viewer.outputs.report-name }}
106+
path: ${{ steps.xunit-viewer.outputs.report-dir }}

0 commit comments

Comments
 (0)