Skip to content

Commit

Permalink
Add git info and fix output copy (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Oct 8, 2019
1 parent 3689ac8 commit f52aa94
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
24 changes: 18 additions & 6 deletions .ci/build-manifest.cake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ using Xamarin.Nuget.Validator;
var VERBOSITY = Argument ("v", Argument ("verbosity", Verbosity.Normal));
var CONFIGURATION = Argument ("c", Argument ("configuration", "Release"));

var FAIL_ON_BUILD_FAIL = Argument ("failonbuildfail", true);

var GIT_PREVIOUS_COMMIT = Argument ("gitpreviouscommit", "");
var GIT_COMMIT = Argument ("gitcommit", "");
var GIT_BRANCH = Argument ("gitbranch", "origin/master");
Expand Down Expand Up @@ -211,6 +209,8 @@ Information ("");

// SECTION: Build

var buildExceptions = new List<Exception> ();

if (groupsToBuild.Count == 0) {
// Make a note if nothing changed...
Warning ("No changed files affected any of the paths from the manifest.yaml.");
Expand Down Expand Up @@ -300,8 +300,8 @@ if (groupsToBuild.Count == 0) {
StackTrace = ex.ToString()
};

if (FAIL_ON_BUILD_FAIL)
throw;
// Record that failure so we can throw later
buildExceptions.Add (ex);
}

// Add the test run to the collection
Expand Down Expand Up @@ -329,7 +329,7 @@ if (groupsToBuild.Count == 0) {
// SECTION: Copy Output

// Log all the things that were found after a build
var artifacts = GetFiles ($"{ROOT_DIR}/**/output/**/*") - GetFiles ($"{ROOT_OUTPUT_DIR}/**/*");
var artifacts = GetFiles ($"{ROOT_DIR}/*/**/output/**/*");
Information ("Found {0} Artifacts:" + Environment.NewLine +
" - " + string.Join (Environment.NewLine + " - ", artifacts),
artifacts.Count);
Expand All @@ -339,12 +339,24 @@ Information ("");
if (COPY_OUTPUT_TO_ROOT) {
Information ("Copying all {0} artifacts to the root output directory...", artifacts.Count);
EnsureDirectoryExists (ROOT_OUTPUT_DIR);
CopyFiles (artifacts, ROOT_OUTPUT_DIR, false);
var dirs = GetDirectories ($"{ROOT_DIR}/*/**/output");
foreach (var dir in dirs) {
Information ("Copying {0}...", dir);
CopyDirectory (dir, ROOT_OUTPUT_DIR);
}
Information ("Copy complete.");
}
Information ("");


// SECTION: Clean up

// There were exceptions, so throw them now
if (buildExceptions.Count > 0) {
throw new AggregateException (buildExceptions);
}


// SECTION: Helper Methods and Types

public enum PodRepoUpdate {
Expand Down
11 changes: 8 additions & 3 deletions .ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ parameters:
forceBuild: 'false' # [manifest] whether or not to force the build
namesFilter: '' # [manifest] the names of the items to build
targetsFilter: '' # [manifest] the targets of the items to build
failOnBuildFail: 'true' # [manifest] whether or not to fail the build when a single build fails

jobs:
- job: ${{ parameters.name }}
Expand Down Expand Up @@ -186,6 +185,10 @@ jobs:
displayName: 'Run build'
env:
JavaSdkDirectory: $(JAVA_HOME)
RepositoryCommit: $(Build.SourceVersion)
RepositoryBranch: $(Build.SourceBranchName)
RepositoryUrl: $(Build.Repository.Uri)
RepositoryType: $(Build.Repository.Provider)
# the manifest-based build
- ${{ if eq(parameters.buildType, 'manifest') }}:
- pwsh: |
Expand All @@ -197,21 +200,23 @@ jobs:
$force = if ("$env:FORCEBUILD") { "$env:FORCEBUILD" } else { "${{ parameters.forceBuild }}" }
$names = if ("$env:BUILDMANIFESTNAMES") { "$env:BUILDMANIFESTNAMES" } else { "${{ parameters.namesFilter }}" }
$targets = if ("$env:BUILDMANIFESTTARGETS") { "$env:BUILDMANIFESTTARGETS" } else { "${{ parameters.targetsFilter }}" }
$fail = if ("$env:FAILONBUILDFAIL") { "$env:FAILONBUILDFAIL" } else { "${{ parameters.failOnBuildFail }}" }
dotnet cake build-manifest.cake `
--gitpreviouscommit="$(GitLastSuccessfulCommit)" `
--gitcommit="$(Build.SourceVersion)" `
--gitbranch="$(Build.SourceBranch)" `
--forcebuild="$force" `
--names="$names" `
--targets="$targets" `
--failonbuildfail="$fail" `
--copyoutputtoroot=true `
--configuration="${{ parameters.configuration }}" `
--verbosity="${{ parameters.verbosity }}"
displayName: 'Run build'
env:
JavaSdkDirectory: $(JAVA_HOME)
RepositoryCommit: $(Build.SourceVersion)
RepositoryBranch: $(Build.SourceBranchName)
RepositoryUrl: $(Build.Repository.Uri)
RepositoryType: $(Build.Repository.Provider)
- task: PublishTestResults@2
displayName: Publish the test results
condition: always()
Expand Down
3 changes: 0 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
var VERBOSITY = Argument ("v", Argument ("verbosity", Verbosity.Normal));
var CONFIGURATION = Argument ("c", Argument ("configuration", "Release"));

var FAIL_ON_BUILD_FAIL = Argument ("failonbuildfail", true);

var BUILD_NAMES = Argument ("names", Argument ("name", ""));
var BUILD_TARGETS = Argument ("build-targets", Argument ("targets", Argument ("target", "Default")));

Expand All @@ -27,7 +25,6 @@ var cakeSettings = new CakeSettings {
{ "targets", BUILD_TARGETS },
{ "forcebuild", true.ToString () },
{ "repo-update", POD_REPO_UPDATE.ToString () },
{ "failonbuildfail", FAIL_ON_BUILD_FAIL.ToString () },
},
Verbosity = VERBOSITY
};
Expand Down

0 comments on commit f52aa94

Please sign in to comment.