Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
114 stars 181 forks source link

[PR workflow][PR Summary] should not fail on `CI-NewRPNamespaceWithoutRPaaS` #6673

Open konrad-jamrozik opened 1 year ago

konrad-jamrozik commented 1 year ago

PR Summary should not fail, but we might want to block the scenario in a different way.

For more context, see https://github.com/Azure/azure-rest-api-specs/pull/24974#issuecomment-1664657867

For a workaround, see:

Relevant code adding the label that causes the PR summary task failure:

  if (
    labelsToAdd.has("new-rp-namespace") &&
    !labelsToAdd.has("RPaaS")
  ) {
    console.log(
      "Adding new RP namespace, but not RPaaS, block PR. New RP namespace should be onboarded in RPaaS first."
    );
    labelsToAdd.add("CI-NewRPNamespaceWithoutRPaaS");
    process.exitCode = 1;
  }

This is how RPaaS is being added:

function isRPSaaS(readmeFilePath: string) {
  const readmeParser = new ReadmeParser(readmeFilePath);
  const openapiSubtype = readmeParser.getGlobalConfigByName("openapi-subtype");
  console.log(
    `readmeFilePath: ${readmeFilePath} openapi-subtype: ${openapiSubtype}`
  );
  return openapiSubtype === "rpaas" || openapiSubtype === "providerHub";
}

This is how new-rp-namespace is being added:

async function processNewRPNamespace(context: IValidatorContext) {
  console.log("ENTER definition processNewRPNamespace")
  const pr = await createPullRequestProperties(
    context,
    "pr-summary-new-rp-namespace"
  );

  // ...

  const createSwaggerFileHandler = () => {
    return (e: PRChange) => {
      if (e.changeType === "Addition") {
        const rpFolder = getRPFolderFromSwaggerFile(dirname(e.filePath));
        console.log(`Processing newRPNameSpace rpFolder: ${rpFolder}`);
        if (rpFolder !== undefined) {
          const rpFolderFullPath = resolve(pr?.workingDir!, rpFolder);
          if (!existsSync(rpFolderFullPath)) {
            console.log(`Adding new RP namespace: ${rpFolder}`);
            labelsToAdd.add("new-rp-namespace");
          }
        }
      }
    };
  };
konrad-jamrozik commented 1 year ago

Another case:

konrad-jamrozik commented 7 months ago

Same for label CI-RpaaSRPNotInPrivateRepo processed by processBlockPRWhenRPaaSRPNotInPrivateRepo.

konrad-jamrozik commented 7 months ago

Pull Request 546923: Improve ARM review labels flow + no longer fail Summary task; block PR appropriately instead