Skip to content

Commit

Permalink
fix(validate/pubrules): API key is no longer required (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
deniak authored Sep 12, 2023
1 parent 9584000 commit 6377180
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ inputs:
VALIDATE_PUBRULES:
description: Validate against W3C Publication Rules
default: false
W3C_API_KEY:
description: W3C API Key (required for VALIDATE_PUBRULES for now)
GH_PAGES_BRANCH:
description: Provide a branch name to deploy to GitHub pages.
GH_PAGES_BUILD_OVERRIDE:
Expand Down Expand Up @@ -134,7 +132,6 @@ runs:
env:
INPUTS_VALIDATE_PUBRULES: ${{ steps.prepare.outputs.validate && fromJson(steps.prepare.outputs.validate).pubrules }}
OUTPUTS_BUILD: ${{ steps.build.outputs.w3c && toJson(fromJson(steps.build.outputs.w3c)) }}
INPUTS_W3C_API_KEY: ${{ inputs.W3C_API_KEY }}

- name: Validate Web IDL
run: |
Expand Down
9 changes: 2 additions & 7 deletions src/validate-pubrules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,22 @@ if (module === require.main) {
}

const input: Input = JSON.parse(env("OUTPUTS_BUILD"));
const apiKey = env("INPUTS_W3C_API_KEY");
main(input, apiKey).catch(err => exit(err.message || "Failed", err.code));
main(input).catch(err => exit(err.message || "Failed", err.code));
}

export default async function main({ dest, file }: Input, apiKey: string) {
export default async function main({ dest, file }: Input) {
console.log(`Pubrules ${file}...`);
await install("specberus");

const server = await new StaticServer(dest).start();
let result;
try {
process.env.W3C_API_KEY = apiKey;
// TODO: use correct file in URL
result = await validate(server.url);
} catch (error) {
console.error(error);
exit("Something went wrong");
} finally {
delete process.env.W3C_API_KEY;
await server.stop();
}

Expand Down Expand Up @@ -85,8 +82,6 @@ function sinkAsync<T>() {
};
}

// TODO:
// - API key exception handling (based on apiKey being required or not)
async function validate(url: URL) {
const { Specberus } = require("specberus");

Expand Down
4 changes: 1 addition & 3 deletions test/validate-pubrules.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { env } from "../src/utils.js";
import main from "../src/validate-pubrules.js";
import { Outputs } from "./index.test.js";

Expand All @@ -10,6 +9,5 @@ export default async function validatePubrules(outputs: Outputs) {

const { dest = process.cwd() + ".w3c", file = "index.html" } =
outputs?.build?.w3c || {};
const apiKey = env("W3C_API_KEY");
return await main({ dest, file }, apiKey);
return await main({ dest, file });
}

0 comments on commit 6377180

Please sign in to comment.