Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Dec 9, 2023
1 parent 46016f4 commit 5788b42
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
repo: wcag-issues-action
input: wcag-em.json
create-labels: true
create-artifact: false
create-artifact: true
description: "This is just an example."
title: "GitHub Action for WCAG reports in GitHub Issues"
token: ${{ secrets.GH_ISSUES_TOKEN }}

- name: Print Output
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: "Frameless"
inputs:
input:
description: "WCAG-EM JSON file that is the basis for your report."
required: true
required: false
default: "wcag-evaluation.json"
create-artifact:
description: "Upload GitHub Artifact with JSON result"
Expand All @@ -31,6 +31,12 @@ inputs:
website:
description: "URL of the website the WCAG compliance report is about."
required: true
description:
description: "Describe the scope of the evaluation."
required: false
title:
description: "Title of the evaluation report."
required: false

outputs:
json:
Expand Down
110 changes: 110 additions & 0 deletions src/earl-json-ld.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
export const createJSON = ({ title, description }) => ({
"@context": {
reporter: "http://github.com/w3c/wai-wcag-em-report-tool/",
wcagem: "http://www.w3.org/TR/WCAG-EM/#",
Evaluation: "wcagem:procedure",
defineScope: "wcagem:step1",
scope: "wcagem:step1a",
step1b: { "@id": "wcagem:step1b", "@type": "@id" },
conformanceTarget: "step1b",
accessibilitySupportBaseline: "wcagem:step1c",
additionalEvaluationRequirements: "wcagem:step1d",
exploreTarget: "wcagem:step2",
essentialFunctionality: "wcagem:step2b",
pageTypeVariety: "wcagem:step2c",
technologiesReliedUpon: "wcagem:step2d",
selectSample: "wcagem:step3",
structuredSample: "wcagem:step3a",
randomSample: "wcagem:step3b",
Website: "wcagem:website",
Webpage: "wcagem:webpage",
auditSample: "wcagem:step4",
reportFindings: "wcagem:step5",
documentSteps: "wcagem:step5a",
commissioner: "wcagem:commissioner",
evaluator: "wcagem:evaluator",
evaluationSpecifics: "wcagem:step5b",
WCAG: "http://www.w3.org/TR/WCAG/#",
WCAG20: "http://www.w3.org/TR/WCAG20/#",
WCAG21: "http://www.w3.org/TR/WCAG21/#",
WAI: "http://www.w3.org/WAI/",
A: "WAI:WCAG2A-Conformance",
AA: "WAI:WCAG2AA-Conformance",
AAA: "WAI:WCAG2AAA-Conformance",
wcagVersion: "WAI:standards-guidelines/wcag/#versions",
reportToolVersion: "wcagem:reportToolVersion",
earl: "http://www.w3.org/ns/earl#",
Assertion: "earl:Assertion",
TestMode: "earl:TestMode",
TestCriterion: "earl:TestCriterion",
TestCase: "earl:TestCase",
TestRequirement: "earl:TestRequirement",
TestSubject: "earl:TestSubject",
TestResult: "earl:TestResult",
OutcomeValue: "earl:OutcomeValue",
Pass: "earl:Pass",
Fail: "earl:Fail",
CannotTell: "earl:CannotTell",
NotApplicable: "earl:NotApplicable",
NotTested: "earl:NotTested",
assertedBy: "earl:assertedBy",
mode: "earl:mode",
result: "earl:result",
subject: "earl:subject",
test: "earl:test",
outcome: "earl:outcome",
dcterms: "http://purl.org/dc/terms/",
title: "dcterms:title",
description: "dcterms:description",
summary: "dcterms:summary",
date: "dcterms:date",
hasPart: "dcterms:hasPart",
isPartOf: "dcterms:isPartOf",
id: "@id",
type: "@type",
language: "@language",
},
language: "en",
type: "Evaluation",
reportToolVersion: "3.0.3",
defineScope: {
id: "_:defineScope",
scope: {
description,
title,
},
conformanceTarget: "AA",
accessibilitySupportBaseline: "",
additionalEvaluationRequirements: "",
wcagVersion: "2.1",
},
exploreTarget: {
id: "_:exploreTarget",
essentialFunctionality: "",
pageTypeVariety: "",
technologiesReliedUpon: ["HTML", "CSS", "WAI-ARIA", "JavaScript", "SVG"],
},
selectSample: {
id: "_:selectSample",
structuredSample: [],
randomSample: [],
},
auditSample: [],
reportFindings: {
date: {
type: "http://www.w3.org/TR/NOTE-datetime",
"@value": "Sat Dec 09 2023",
},
summary: "",
title: "",
commissioner: "",
evaluator: "",
documentSteps: [
{ id: "_:about" },
{ id: "_:defineScope" },
{ id: "_:exploreTarget" },
{ id: "_:selectSample" },
],
evaluationSpecifics: "",
},
});
6 changes: 5 additions & 1 deletion src/github-action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {
uploadArtifact,
} from "./lib.mjs";

const input = getInput("input", { required: true });
const input = getInput("input", { required: false });
const owner = getInput("owner", { required: true });
const repo = getInput("repo", { required: true });
const labelColor = getInput("label-color", { required: false });
const website = getInput("label-color", { required: true });
const token = getInput("token", { required: true });
const title = getInput("title", { required: false });
const description = getInput("description", { required: false });
const createLabels =
getBooleanInput("create-labels", {
required: false,
Expand All @@ -36,6 +38,8 @@ await mergeResults({
inputFile: input,
auditResults,
outputFile: "tmp/wcag-em.json",
title,
description,
});

if (createArtifact) {
Expand Down
15 changes: 9 additions & 6 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
uploadArtifact,
} from "./lib.mjs";

const inputFile = "./wcag-evaluation.json";
const inputFile = null;
// const inputFile = "./wcag-evaluation.json";
const outputFile = "tmp/wcag-evaluation.json";
const owner = "frameless";
const repo = "wcag-issues-action";
Expand All @@ -15,17 +16,19 @@ const website = "https://github.com/frameless/wcag-issues-action";
const token = process.env.GITHUB_TOKEN;
const createNewLabels = true;
const createArtifact = false;
const description = "This is just an example.";
const title = "GitHub Action for WCAG reports in GitHub Issues";

const octokit = await login({ token });

if (createNewLabels) {
createWcagLabels({ octokit, owner, repo, color: labelColor });
}

// const auditResult = await loadWcagIssues({ owner, repo, octokit, website });
const auditResult = await loadWcagIssues({ owner, repo, octokit, website });

// await mergeResults({ inputFile, outputFile, auditResult });
await mergeResults({ inputFile, outputFile, auditResult, title, description });

// if (createArtifact) {
// await uploadArtifact({ outputFile });
// }
if (createArtifact) {
await uploadArtifact({ outputFile });
}
15 changes: 12 additions & 3 deletions src/lib.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { basename } from "node:path";
import { successCriteria } from "./wcag21.mjs";
import cloneDeep from "lodash.clonedeep";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { createJSON } from "./earl-json-ld.mjs";

Octokit.plugin(paginateRest);

Expand Down Expand Up @@ -50,7 +51,7 @@ export const createWcagLabels = async ({ octokit, owner, repo, color }) => {

const createResult = await Promise.all(
newLabels.map(({ name, description }) =>
octokit.rest.issues.createLabel({
octokit.paginate(octokit.rest.issues.createLabel, {
owner,
repo,
name,
Expand Down Expand Up @@ -121,8 +122,16 @@ export const loadWcagIssues = async ({ octokit, owner, repo, website }) => {
return auditResult;
};

export const mergeResults = async ({ inputFile, auditResult, outputFile }) => {
const inputJSON = JSON.parse(await readFile(inputFile));
export const mergeResults = async ({
inputFile,
auditResult,
outputFile,
title,
description,
}) => {
const inputJSON = inputFile
? JSON.parse(await readFile(inputFile))
: createJSON({ title, description });
const out = cloneDeep(inputJSON);
out.auditSample = [...inputJSON.auditSample, ...auditResult];

Expand Down

0 comments on commit 5788b42

Please sign in to comment.