|
| 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 }} |
0 commit comments