-
Notifications
You must be signed in to change notification settings - Fork 0
Continuous Integration
The integration of the MtconnectTranspiler into continuous integration (CI) workflows aims to enhance flexibility and automation in library development. This page provides guidance on automating the development of your libraries in response to updates in the MTConnect Standard.
As of early 2023, the MTConnect Standard's release process does not include Webhooks. The standard has only recently started publishing Releases on GitHub, making Tags and Releases the recommended triggers for automation.
A practical approach for initiating workflows in response to the mtconnect/mtconnect_sysml_model
release is to establish a Scheduled workflow. This workflow periodically checks the latest Release Tag from the mtconnect/mtconnect_sysml_model
repository against your project's version.
For instance, the MtconnectCore repository adopts this strategy. Given that MtconnectCore
aligns its semantic versioning with the MTConnect Standard, comparing the versions to determine if the mtconnect_sysml_model
version is newer becomes straightforward.
Should the mtconnect_sysml_model
repository have a higher semantic version, this can automatically trigger a transpilation workflow within your project.
Implementing a CI workflow typically involves several key steps:
- Environment Setup: Configure your build environment, often Windows for .NET Core solutions.
-
NuGet Source Addition: Since the
MtconnectTranspiler
may be hosted on the GitHub Packages registry, add it as a NuGet source. - Solution Build: Build your solution using the appropriate tools and configurations.
- Transpiler Execution: Run the transpiler to generate or update code based on the SysML model.
- Change Management: Track the generated changes and use Git to update your repository accordingly.
Below is a basic YAML configuration to get started with a GitHub Actions workflow for transpilation:
name: Transpile from SysML
on:
workflow_dispatch:
jobs:
build-and-generate:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Add NuGet source
run: |
nuget sources add -name "GitHub Packages (MTConnect)" -source "https://nuget.pkg.github.com/mtconnect/index.json" -username ${{ github.actor }} -password ${{ secrets.GITHUB_TOKEN }}
- name: Build solution
run: dotnet build "*.sln" --configuration Release
- name: Run transpiler
run: */bin/Release/net6.0/*.exe "param1" "param2"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: develop/generated
base: master
commit-message: "Transpiled SysML model"
committer: GitHub Action <[email protected]>
title: "Continuous Integration"
body: "This pull request is automatically generated by a GitHub Action. Changes are based on the `MtconnectTranspiler.Sinks.*` implementation."
draft: true
delete-branch: true
This example demonstrates a workflow dispatch that builds the environment, adds the necessary NuGet source, builds the solution, runs the transpiler, and then creates a pull request with the changes. The MtconnectCore
repository showcases an excellent implementation of this workflow, utilizing a ITranspilerSink
implementation in a console application that accepts up to two arguments: the destination directory for the C# files and an optional reference to the XML representing the SysML model.