CI/CD - Build accdb/accde from source (msaccess-vcs exports)
Thanks to Martin Leduc (DecimalTurn) for VBA-Build, which was a great reference.
inputs:
source-dir:
description: 'msaccess-vcs source folder'
required: false
default: 'source'
target-dir:
description: 'target dir for binary file'
required: false
default: ''
compile:
description: 'create accde file'
required: false
default: false
app-config:
description: 'application config file (set database properties, run procedures, etc.)'
required: false
default: ''
run-accunit-tests:
description: 'run accunit tests after build'
required: false
default: false
accunit-junit-xml:
description: 'path for AccUnit JUnit XML test results (requires run-accunit-tests), empty = don''t write'
required: false
default: ''
accunit-url:
description: 'AccUnit release url, empty = use installed AccUnitLoader add-in, download and install latest release if not installed'
required: false
default: ''
vcs-url:
description: 'msaccess-vcs release url'
required: false
default: 'https://api.github.com/repos/joyfullservice/msaccess-vcs-addin/releases/latest'
file-name:
description: 'build this filename, empty = use filename from vcs options'
required: false
default: ''
accunit-junit-xml requires an AccUnitLoader add-in with JUnit XML support (AccessCodeLib/AccUnit#84). If the file is not created, a warning is written to the log.
AccUnit tests use the installed AccUnitLoader add-in (%APPDATA%\Microsoft\AddIns\AccUnitLoader.accda). If it is not installed, the latest AccUnit release is downloaded and installed like AccUnitLoader_Install.vbs does it (compiled into %APPDATA%\Microsoft\AddIns and registered as menu add-in), so following runs use the installed add-in. Set accunit-url to always download and install from this url (e.g. to update or to use a specific release).
Example call:
jobs:
build:
runs-on: [self-hosted, Windows, Office]
steps:
- ...
- name: "Build Access file (accdb/accde)"
id: build_access_file
uses: AccessCodeLib/msaccess-vcs-build@main
with:
source-dir: "./Version Control.accda.src"
target-dir: "bin"
compile: "false"
vcs-url: "https://api.github.com/repos/joyfullservice/msaccess-vcs-addin/releases/latest"
- josef-poetzl/msaccess-vcs-addin: Build-self-hosted (on release)
- AccessCodeLib/BuildAccdeExample: Build-self-hosted-O64
- AccessCodeLib/BuildAccdeExample: Build-self-hosted-O64-O32: call 64 and 32 runner to get 32 and 64 bit accde
- Install Office with the appropriate bit version and license
- msaccess-vcs 5.1 or newer (the default
vcs-urldownloads the latest release). Older versions do not provideBuildHeadless.
- Pre-install msaccess-vcs (version 5.1 or newer) and set the vcs-url parameter to “”.
- Set the required Trusted Locations
You can also run the Runner on your own developer PC for testing purposes.
The build uses the headless API of msaccess-vcs (BuildHeadless, Continuous Integration) (available since msaccess-vcs 5.1). The build log is copied to the target folder (also on failure). To fail a build on your own criteria, set ValidateAfterBuild in vcs-options.json to a function in the database that returns True.
It is also possible to use only the PowerShell scripts to execute the build process locally.
- [string]$SourceDir = "", # empty use parameter SourceFile, don't use msaccess-vcs
- [string]$SourceFile = "", # empty = name from vcs options
- [string]$TargetDir = "", # Folder for output file, default (empty): current folder
- [string]$Compile = 'false', # Default to "false" if not specified
- [string]$AppConfigFile = "", # Default "" => don't change database properties etc.
- [string]$RunAccUnitTests = 'false', # "true" = run AccUnit tests after build
- [string]$AccUnitJUnitXml = "", # path for AccUnit JUnit XML test results (requires RunAccUnitTests), empty = don't write
- [string]$AccUnitUrl = "", # AccUnit release url, empty = use installed AccUnitLoader add-in, download and install latest release if not installed
- [string]$vcsUrl = "https://api.github.com/repos/joyfullservice/msaccess-vcs-addin/releases/latest", # empty = don't install msacess-vcs
- [string]$SetTrustedLocation = 'true' # set trusted location for current folder
.\Build.ps1 -SourceDir "source" -Compile $true -AppConfigFile ".\Application-Config.json"Steps:
- download msacesss-vcs
- build accdb from source via
VCS.BuildHeadless(file name from msaccess-vcs property file) - prepare accdb: remove modules and references from Application-Config.json
- compile accdb to accde
- run procedures and apply database properties from Application-Config.json to the accde
.\Build.ps1 -SourceFile "Test.accdb" -Compile $true -AppConfigFile ".\Application-Config.json"Steps:
- prepare Test.accdb: remove modules and references from Application-Config.json
- compile Test.accdb to Test.accde
- run procedures and apply database properties from Application-Config.json to Test.accde