Closed dustuu closed 1 year ago
First - thank you very much @dustuu for submitting this helpful and very well documented PR! I'm happy with the changes to use Repository Variables instead of requiring code changes. I'm a little worried that the automation and information about the test suite will be an overload for most of our package creators, who are not likely to create and run tests like this for their packages. I don't want anyone scared away because of how complicated it may look. Any thoughts on that, @Faxmashine?
@momo-the-monster No worries! I thought that might be the case.
I can open a new PR with a subset of the changes from this one.
Would you like me to include only the Repository Variable changes, or are you also interested in including the workflow cleanup changes such as the new zip
step or the updated comments & action versions?
@dustuu - I'm interested in all the workflow cleanup changes too, thanks!
@momo-the-monster I've opened a new PR #13 which has the reduced scope you're looking for. I'll go ahead and close this PR now. 🍍👍
This pull request adds optional support for automatically running Unit Tests via GitHub Actions and generating Code Coverage Reports from those tests. Configuration steps for this feature are outlined here. If this feature is not configured by a user, it will simply be skipped over during workflow execution.
Two configurable badges have also been added to the README file; one badge which displays the package's current VPM version, and another which shows the results of the Code Coverage Report (if the new automatic unit tests feature is enabled). These badges are outlined here. When set up properly, they look like this:
Clicking on the VPM badge opens the repository's VPM Listing Page, while clicking on the Code Coverage badge opens the the generated Code Coverage Report.
Additionally, this pull request removes the need for users to manually edit any of the workflow files. It does this by using repository variables to pass values into the workflows. Users can now create a repository variable named
PACKAGE_NAME
with the name of their package, such ascom.vrchat.demo-template
in this demo, instead of manually editing the workflow files. This step has been added to the README file here.If automatic unit testing is enabled, repository secrets can also be used for Unity License configuration, which are outlined here. There are also several more non-secret repository variables to be entered at this step.
PACKAGE_NAME
com.vrchat.demo-template
ASSEMBLY_NAME
VRChatPackageTemplate
REQUIRED_COVERAGE
100
UNITY_VERSION
2019.4.31f1
If the user requests for Code Coverage percentages to be enforced by setting the
REQUIRED_COVERAGE
variable to something greater than0
, theBuild Release
workflow will enforce their configured Code Coverage target. It does this by using my own custom fork of a GitHub Action that runs in a Docker Container: Kemocade.Unity.Coverage.Action. This Container is built during the start of theBuild Release
workflow'stest
job, and executed later in that same job'sEnforce Code Coverage
step.The
Build Release
workflow previously only contained one job,build
. It now contains three jobs:config
,test
, andbuild
:config
test
config
job, this job will be skipped.build
PACKAGE_NAME
variable to be configured, all other variables and secrets are optional. This job will run even if thetest
job is skipped.From this template repository, I've created 8 example repositories that show how the updated workflows respond to various possible configurations of repository variables, asset changes, or both:
template-package-unconfigured shows what happens when the workflows are run with no configuration.
PACKAGE_NAME
variable, theBuild Release
workflow will skip both thetest
andbuild
jobs:Build Repo Listing
workflow will be trigged to run as well, but it will fail as expected because there are no published releases.template-package-skip-tests shows what happens when only the
PACKAGE_NAME
variable is set, but none of the variables or secrets needed for running Unit Tests are. This is how workflows will run for users who don't opt-in to the new automatic Unit Tests feature, which is likely to be most users.Build Release
workflow will skip thetest
job because it is missing the necessary configuration, but will run thebuild
job and make a release:Build Repo Listing
workflow will be trigged to run and will succeed.template-package-full shows what happens when all repository variables and secrets are configured properly, and Unit Tests are present. This version uses all available new features.
Build Release
workflow will pass on all three jobs:Build Repo Listing
workflow will be trigged to run and will succeed, just as before. Additionally, this copies the previously created Code Coverage report onto the GitHub Pages website. This report can then be accessed via the Code Coverage badge in the README.template-package-template-package-fail-tests shows what happens when all repository variables and secrets are configured properly, but one or more Unit Tests are failing.
Build Release
workflow will fail because Unit Tests are present and configured to run by the user via repository variables, but failing:Build Repo Listing
workflow will fail as expected because there are no published releases.template-package-no-tests shows what happens when all repository variables and secrets are configured properly, but the actual Unit Test files are removed from the repository.
Build Release
workflow will fail because the user has indicated that Unit Tests are present, but they are not:Build Repo Listing
workflow will fail as expected because there are no published releases.template-package-runtime-tests-only-fail shows what happens when all repository variables and secrets are configured properly, but Unit Tests are only present for testing the package's Editor Scripts.
REQUIRED_COVERAGE
is still set to100
, theBuild Release
workflow will fail due to the Unit Tests no longer covering the Editor Scripts:Build Repo Listing
workflow will fail as expected because there are no published releases.template-package-runtime-tests-only shows the same scenario as template-package-runtime-tests-only-fail, but this time has
REQUIRED_COVERAGE
set to0
.Build Release
workflow will pass on all three jobs. even without Editor Tests. This is because the new configuration no longer requires full code coverage:Build Repo Listing
workflow will be trigged to run and will succeed.template-package-editor-tests-only shows the same scenario as template-package-runtime-tests-only, but with only Editor Tests instead of only Runtime Tests.
Build Release
workflow will pass on all three jobs:Build Repo Listing
workflow will be trigged to run and will succeed.Beyond the main features of Unit Tests, Code Coverage, and Repository Variable Configuration, this pull request also includes a few small additional changes.
Previously, zip releases were made with a third-party GitHub Action that used relative paths to back outwards from the package itself:
I have changed this to use the native Bash
zip
command, as well as absolute paths built from${{ github.workspace }}
.This new approach is also used to build the Code Coverage Report zip, if Automatic Unit Testing is enabled.
Finally, names and comments have been added to all workflow steps which did not previously have them. All workflow steps which use other actions via the
uses
keyword have also been set to use their source's commit ID instead of tags, keeping in line with how this was done in most of the original workflows.This pull request has been built on top of the existing work done in the approved but still-pending PR #11. Therefore, this pull request can be merged in place of or on top of that one with no merge conflicts.