diff --git a/index.js b/index.js index 41e3f7f..a02bdb6 100644 --- a/index.js +++ b/index.js @@ -10,8 +10,8 @@ const ECHIDNA_FAILURE_STATUS = 'failure'; (async function main() { process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'; process.env.PUPPETEER_EXECUTABLE_PATH = '/usr/bin/google-chrome'; - // await run('Install dependencies', installDependencies); - // await run('Validate spec', validate); + await run('Install dependencies', installDependencies); + await run('Validate spec', validate); await run('Publish to /TR/', publish); })(); @@ -48,8 +48,7 @@ async function validate() { } async function publish() { - const shouldPublish = - true || process.env.GITHUB_EVENT_NAME !== 'pull_request'; + const shouldPublish = process.env.GITHUB_EVENT_NAME !== 'pull_request'; if (!shouldPublish) { console.log('👻 Skipped.'); return; @@ -68,15 +67,13 @@ async function publish() { core.setSecret(data.token); const body = new URLSearchParams(Object.entries(data)).toString(); - const id = - 'foo' || - (await request('https://labs.w3.org/echidna/api/request', { - method: 'POST', - body, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - })); + const id = await request('https://labs.w3.org/echidna/api/request', { + method: 'POST', + body, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }); const result = await getPublishStatus(id); console.log(result); @@ -86,7 +83,7 @@ async function publish() { case ECHIDNA_FAILURE_STATUS: { for (const { message, id, name } of getSpecberusErrors(result.response)) { const msg = `echidna/specberus:\n\t${name}/${id}:\n\t${message}`; - issueCommand('error', { file, line: "1" }, msg); + issueCommand('error', { file, line: '1' }, msg); } throw new Error('💥 Echidna publish has failed.'); } @@ -95,7 +92,7 @@ async function publish() { } } -async function getPublishStatus(id = 'bar') { +async function getPublishStatus(id) { let url = new URL('https://labs.w3.org/echidna/api/status'); url.searchParams.set('id', id); url = url.href; @@ -106,8 +103,7 @@ async function getPublishStatus(id = 'bar') { // ... with a maximum of 18 seconds total wait. let RETRY_DURATIONS = [2, 3, 2, 4, 2, 5]; - const state = { id, status: ECHIDNA_FAILURE_STATUS, url, response: getMockResponse() }; - return state; + const state = { id, status: 'pending', url, response: undefined }; do { const wait = RETRY_DURATIONS.shift(); console.log(`⏱️ Wait ${wait}s for job to finish...`); @@ -199,184 +195,3 @@ function request(url, options) { req.end(); }); } - -function getMockResponse() { - return { - id: '870bc1a8-ed54-4db6-a5a7-60f1c98d7a8c', - url: 'https://w3c.github.io/web-share/ECHIDNA', - version: '1.14.11', - 'version-specberus': '4.3.0', - decision: - 'https://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0627.html', - editorial: false, - results: { - status: 'failure', - jobs: { - 'token-checker': { - status: '', - errors: [], - }, - 'third-party-checker': { - status: '', - errors: [], - }, - 'update-tr-shortlink': { - status: '', - errors: [], - }, - 'tr-install': { - status: '', - errors: [], - }, - publish: { - status: '', - errors: [], - }, - metadata: { - status: 'ok', - errors: [], - }, - specberus: { - status: 'failure', - errors: [ - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - { - key: 'no-id', - extra: { - text: 'Referenced in:', - }, - type: { - name: 'structure.section-ids', - section: 'document-body', - rule: 'headingWithoutID', - }, - }, - ], - }, - 'retrieve-resources': { - status: 'ok', - errors: [], - }, - 'transition-checker': { - status: '', - errors: [], - }, - }, - history: [ - { - time: '2020-06-04T11:25:24.454Z', - fact: 'The file has been retrieved.', - }, - { - time: '2020-06-04T11:25:25.515Z', - fact: 'The metadata have been extracted.', - }, - { - time: '2020-06-04T11:25:27.165Z', - fact: 'The document failed Specberus.', - }, - ], - metadata: { - previousVersion: 'https://www.w3.org/TR/2019/WD-web-share-20191217/', - editors: [91260, 67534], - delivererIDs: [114929], - docDate: '2020-6-4', - processRules: 'https://www.w3.org/2019/Process-20190301/', - profile: 'WD', - latestVersion: 'https://www.w3.org/TR/web-share/', - editorDraft: 'https://w3c.github.io/web-share/', - title: 'Web Share API', - thisVersion: 'https://www.w3.org/TR/2020/WD-web-share-20200604/', - rectrack: true, - informative: false, - }, - }, - }; -}