Skip to content

Commit

Permalink
fail builds with wrong API levels
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Oct 4, 2023
1 parent 9a57aa2 commit 3e37686
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Plogon/BuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,18 @@ await this.dockerClient.Containers.RemoveContainerAsync(containerCreateResponse.
Directory.Move(imagesSourcePath, imagesDestinationPath);
}

// DELETE THIS!!
var manifestFile = new FileInfo(Path.Combine(repoOutputDir.FullName, $"{task.InternalName}.json"));
var manifestText = await File.ReadAllTextAsync(manifestFile.FullName);

var manifestObj = JObject.Parse(manifestText);
manifestObj["_isDip17Plugin"] = true;
manifestObj["_Dip17Channel"] = task.Channel;

// Get this from an API or something
var apiLevel = manifestObj["DalamudApiLevel"]?.Value<int>();
if (apiLevel is not PlogonSystemDefine.API_LEVEL)
throw new ApiLevelException(apiLevel ?? 0, PlogonSystemDefine.API_LEVEL);

await File.WriteAllTextAsync(manifestFile.FullName, manifestObj.ToString());
}
catch (Exception ex)
Expand Down Expand Up @@ -1033,4 +1037,30 @@ public MissingIconException()
{
}
}

/// <summary>
/// Exception when wrong API level is used
/// </summary>
public class ApiLevelException : Exception
{
/// <summary>
/// Have version
/// </summary>
public int Have { get; }

/// <summary>
/// Want version
/// </summary>
public int Want { get; }

/// <summary>
/// ctor
/// </summary>
public ApiLevelException(int have, int want)
: base("Wrong API level.")
{
Have = have;
Want = want;
}
}
}
12 changes: 12 additions & 0 deletions Plogon/PlogonSystemDefine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Plogon;

/// <summary>
/// Static values for Plogon.
/// </summary>
public static class PlogonSystemDefine
{
/// <summary>
/// Current API level.
/// </summary>
public const int API_LEVEL = 9;
}
10 changes: 10 additions & 0 deletions Plogon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ await webservices.StagePluginBuild(new WebServices.StagedPluginInfo

prLabels |= GitHubApi.PrLabel.NeedIcon;
}
catch (BuildProcessor.ApiLevelException api)
{
Log.Error("Bad API level!");
buildsMd.AddRow("🚦", $"{task.InternalName} [{task.Channel}]", fancyCommit,
$"Wrong API level! (have: {api.Have}, need: {api.Want})");
numFailed++;
numNoIcon++;

prLabels |= GitHubApi.PrLabel.VersionConflict;
}
catch (Exception ex)
{
Log.Error(ex, "Could not build");
Expand Down

0 comments on commit 3e37686

Please sign in to comment.