ACE unit tests running against your code
In my last post I demonstrated how to run some ACE based unit tests inside a custom container that we created.?
Our container was based on an IBM Docker image with some extra components to make test coverage easier.
As covered in my last post, we have 2 ways to support test coverage for ACE/IIB/WMB.
Tracing - where we consume the trace file and convert it to a code coverage report.
Instrumentation - where we add instrumentation/profile points to running code to capture events around what has been executed. We then save that as a code coverage report.
In both cases we send the code analyzed and coverage report to SonarQube to generate a coverage dashboard (and all the issues and other metrics).
So we can demonstrate how this works when we run the container.
But this is really only useful as a demonstration tool. Not something that will help anyone to develop Ci/Cd processes.
So the next step is be able to demonstrate this process running with some one else's code. So not the pre-packaged demonstration project but some real code that comes from a version control system and is assembled using a real process.
There are a few platforms for Ci/Cd out there on the cloud. I have been doing some other work with GitHub, so I started to look into developing a GitHub action.
After a bit of reading on how to write an action, I started developing one with a Docker image based action.?
The other option is write a type script based action, but that installs the necessary software on the GitHub launched VM, which wouldn't provide that isolation that a container provides.
The ACE image is based on Redhat and some IBM components. My initial attempts to turn the Docker image into an action were un-successful.
The next option was to run a Docker image via a GitHub workflow.
So, the first step was to push the image to somewhere that will be publicly available. We published it to DockerHub here.
There were a few options, but DockerHub is popular and doesn't need a login / credential for most pulls.
I found a good example for running steps in a container:
I didn't end up needing to change the Docker file:
And then it was just a matter of replicating what was in the startup.sh file.
In the workflow steps:
Pass the license acceptance flag:
--env LICENSE=accept
Mount the default checkout directory into the container ${{github.workspace}}:
领英推荐
-v ${{ github.workspace }}:/tmp/work/other/code
And make sure we set the working directory:
-w /tmp/work/other/code
Which matches the paths in the checked out code and the paths in the ANT script.
<exec dir="/opt/ibm/ace-12/server/bin" executable="mqsipackagebar" failonerror="true" > ? ?
<arg value="-w"/>
? ? <arg value="/tmp/work/other/code"/>
? ? <arg value="-a"/>
? ? <arg value="/tmp/work/other/code/BarFiles/UnitTests.bar"/> ? ? ? ? ?
? ? <arg value="-t"/>
? ? <arg value="TestSimple_Project_Test"/>
? ? <arg value="-k"/>
? ? <arg value="TestSimple_Project"/>? ? ? ? ?
</exec>
<exec dir="/opt/ibm/ace-12/server/bin" executable="mqsicreateworkdir" failonerror="true" > ? ?
? ? ? ? <arg value="/tmp/work/other/code/test_work_dir"/>
? ?
? ? </exec>
<copy file="/tmp/work/other/code/config/server.conf.yaml"
? ? ? ? ? ? todir="/tmp/work/other/code/test_work_dir" force="true" failonerror="true" />
<exec executable="IntegrationServer" dir="/opt/ibm/ace-12/server/bin" failonerror="true" > ? ?
<arg value="--default-application-name"/>
? <arg value="TestSimple_Project_UnitTestsApp"/>? ? ? ? ? ? ?
? <arg value="--console-log"/> ? ? ? ? ? ? ? ?
? <arg value="--work-dir"/>
? <arg value="/tmp/work/other/code/test_work_dir"/>
? <arg value="--test-project"/>
? <arg value="TestSimple_Project_Test"/>
? <arg value="--start-msgflows"/>
? <arg value="false"/> ? ? ? ? ? ?
? <arg value="--stop-after-duration"/>
? <arg value="60000" />? ? ? ? ? ? ? ?
</exec>
Then run the steps:
- name: Run the build process with Docker
? uses: addnab/docker-run-action@v3
? with:
? image: richardh65/bct-tools:latest
? ? options: --env LICENSE=accept -v ${{ github.workspace }}:/tmp/work/other/code -w /tmp/work/other/code
? ? run: |
/usr/local/ant/apache-ant-1.10.12/bin/ant -f trace_build.xml
ls -la /tmp/work/other/code/coveragetemp
/usr/local/sonar-scanner/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner -Dproject.settings=./sonar-project-tracing.properties
Again, this will send the coverage reports to our demonstration SonarQube instance, and are available here:
We are doing a quick walkthrough later on in the week for anyone who is interested or has any questions. You can register here:
If anyone is interested in a demonstration or has any questions, thoughts or wants to try it internally please reach out to me either on LinkedIn or via our website:
You can also reach me via email at:
Or contact me via the contact page on our website:
Regards
Richard