From c4a89c234882fefd2f1b82c09473f251b0fcbb41 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sat, 31 Aug 2019 21:33:20 +0200 Subject: [PATCH 01/24] Test github actions --- .github/workflows/workflow.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..f414c64 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,22 @@ +name: CI +on: + pull_request: + branches: + - master + push: + branches: + - master +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Use Node.js 10.x + uses: actions/setup-node@v1 + with: + version: 10.x + - name: Build + run: | + npm ci + npm run test + npm run build --if-present From de00888a627043f66898931c90132763efeaed06 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sat, 31 Aug 2019 21:36:31 +0200 Subject: [PATCH 02/24] Update GA-workflow Use npm install until we have package-lock --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f414c64..1ac4d26 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -17,6 +17,6 @@ jobs: version: 10.x - name: Build run: | - npm ci + npm install npm run test npm run build --if-present From 5599b6aa3fa5892f299ca1e3622370fc536ad677 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sat, 31 Aug 2019 21:44:47 +0200 Subject: [PATCH 03/24] Minor update Unable to re-trigger build ? --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 1ac4d26..30aebbf 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,4 @@ -name: CI +name: Github CI on: pull_request: branches: From 6ddd57053ead0d9bdb20203e3008b36ab5acd430 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sat, 31 Aug 2019 21:52:57 +0200 Subject: [PATCH 04/24] request secrets access --- .github/workflows/workflow.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 30aebbf..e6c123b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -16,6 +16,9 @@ jobs: with: version: 10.x - name: Build + env: + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_TOKEN: ${{ secrets.SAUCE_ACCESS_TOKEN }} run: | npm install npm run test From f70ab7239bffa63a2cc4fb2e0af376ed0b874ba7 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 07:36:22 +0200 Subject: [PATCH 05/24] split steps, use eslint --- .github/workflows/workflow.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e6c123b..212ec76 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -15,11 +15,14 @@ jobs: uses: actions/setup-node@v1 with: version: 10.x - - name: Build + - name: Install + run: npm install + - name: ESLint + uses: gimenete/eslint-action@1.0 + - name: Test env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_TOKEN: ${{ secrets.SAUCE_ACCESS_TOKEN }} - run: | - npm install - npm run test - npm run build --if-present + run: npm run test + - name: Build + run: npm run build --if-present From 264682e506b3c1221383095c2bddc80d420908a7 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 07:41:30 +0200 Subject: [PATCH 06/24] add github token for eslint --- .github/workflows/workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 212ec76..52403b9 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,6 +19,8 @@ jobs: run: npm install - name: ESLint uses: gimenete/eslint-action@1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} From 446c4ef44a6f6cb4b412f5b9d8cb2f1eab7e0416 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 08:10:40 +0200 Subject: [PATCH 07/24] cc --- .github/workflows/workflow.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 52403b9..2f1f1f3 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -20,11 +20,18 @@ jobs: - name: ESLint uses: gimenete/eslint-action@1.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Test + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Test and report env: + CC_TEST_REPORTER_ID: 5286fe366f9880c571dcdfe0d7748a6343eb7eb0788250626df792cd3120ab87 + NEO_CC_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 + NEO_CC: $HOME/cc/cc-test-reporter SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_TOKEN: ${{ secrets.SAUCE_ACCESS_TOKEN }} - run: npm run test + run: | + ([[ -e $NEO_CC ]] || curl -L $NEO_CC_URL > $NEO_CC) && chmod +x $NEO_CC + $NEO_CC before-build + npm run test $([ -z "$SAUCE_ACCESS_KEY"] && echo "-- --skip-plugin sauce") + $NEO_CC after-build --exit-code $? - name: Build run: npm run build --if-present From ad7f116b0d7ba840ef613deb592430f364a46e08 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 08:48:39 +0200 Subject: [PATCH 08/24] relative reporter path --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2f1f1f3..1a09d82 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -25,7 +25,7 @@ jobs: env: CC_TEST_REPORTER_ID: 5286fe366f9880c571dcdfe0d7748a6343eb7eb0788250626df792cd3120ab87 NEO_CC_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 - NEO_CC: $HOME/cc/cc-test-reporter + NEO_CC: cc-test-reporter SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_TOKEN: ${{ secrets.SAUCE_ACCESS_TOKEN }} run: | From b3b978724fe6797acbcb17a9d92562e22157abe1 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 14:33:07 +0200 Subject: [PATCH 09/24] fix reporter? --- .github/workflows/workflow.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 1a09d82..b4dfffe 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -10,22 +10,27 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - name: Checkout + uses: actions/checkout@master + - name: Use Node.js 10.x uses: actions/setup-node@v1 with: version: 10.x + - name: Install run: npm install + - name: ESLint uses: gimenete/eslint-action@1.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Test and report env: CC_TEST_REPORTER_ID: 5286fe366f9880c571dcdfe0d7748a6343eb7eb0788250626df792cd3120ab87 NEO_CC_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 - NEO_CC: cc-test-reporter + NEO_CC: ./cc-test-reporter SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_TOKEN: ${{ secrets.SAUCE_ACCESS_TOKEN }} run: | @@ -33,5 +38,6 @@ jobs: $NEO_CC before-build npm run test $([ -z "$SAUCE_ACCESS_KEY"] && echo "-- --skip-plugin sauce") $NEO_CC after-build --exit-code $? + - name: Build run: npm run build --if-present From b2d15dd3072e619d8a8053b31c6338d01e314d7b Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 15:09:11 +0200 Subject: [PATCH 10/24] add polymer lint --- .github/workflows/workflow.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b4dfffe..3a5d67f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,7 +24,10 @@ jobs: - name: ESLint uses: gimenete/eslint-action@1.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Polymer lint + run: npx polymer lint cosmoz-treenode.js - name: Test and report env: From 7669671c3fdec985648638dfe0229d0fc014b430 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 15:11:29 +0200 Subject: [PATCH 11/24] add eslint eror --- cosmoz-treenode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cosmoz-treenode.js b/cosmoz-treenode.js index 2d15d0c..8706188 100644 --- a/cosmoz-treenode.js +++ b/cosmoz-treenode.js @@ -162,7 +162,7 @@ class CosmozTreenode extends ComputingLitElement { } _computePathText(pathToRender, valueProperty, pathSeparator) { - + console.log('test eslint error'); if (!pathToRender) { return ''; } From 96acdc25028829b28afc169b63487f8cff2581eb Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Sun, 1 Sep 2019 17:07:46 +0200 Subject: [PATCH 12/24] try another eslint --- .github/workflows/workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3a5d67f..d5788b5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -20,9 +20,9 @@ jobs: - name: Install run: npm install - - - name: ESLint - uses: gimenete/eslint-action@1.0 + + - name: Annotated ESLint + uses: rkusa/eslint-action@1.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 08fd3abc0b1dcead741474f17b640f489b0dcd59 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Tue, 3 Sep 2019 11:55:33 +0200 Subject: [PATCH 13/24] Drop travis --- .travis.yml | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6c7403a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -language: node_js -node_js: "lts/*" -dist: xenial - -addons: - firefox: latest - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - -cache: - yarn: true - directories: - - node_modules - - .eslintcache - - $HOME/.cache/bower - - $HOME/cc - -env: - global: - - CC_TEST_REPORTER_ID=5286fe366f9880c571dcdfe0d7748a6343eb7eb0788250626df792cd3120ab87 - - SAUCE_USERNAME=nomego - - secure: j1R1meQnv2Gc9nk1v76q2DbDf1vThlA1DW/8fhySdit19/vESnn2bVPKlcnQA5AOsqgkR/lmcsOWaWV1FU4CD6jn6AWesRjLjYkZrqt+aXZ/l1dHTjrf0O9bF6zgif4lzAgwJCu5ADfRZYhrHX+jipqB/Elxl9UE95EXEs6XeCJbDtaUjamYlEnMAeoS188bs15BEudR+xRTggRBjFGRIhqKKGZ/vyGTK+0G0G9I8utgi2kF2zI8vypw2LgW+k2dcihl7vm4GsjfDFv+9toCzMw43nnMPE2Co/uoPDp9oqnW0NUdHjmY6b/RGX2IfJBEr6klOnCFbJHB67ERgYsuWybIlLJQA9ImSquYjw5R/VQ/Tpk7WZaeT7Q8Vbo2zHMVU2tmOyGzewXGHdvctSOAgB6Ky/53pmCNln2FT4QkyKZxQH3B0WlLdEWtiTMLf7k+yOlIgZ87/sMSnjd5SA2KjcCqK/3CHfBWZju6RbrjuAg0od/HOxFvpx7zz5vJI+RKL7wcD3Unz0BaL3Y6Ci8PJSTxqhl4L3rZXkUDxnLaET6shnxnrVBczrjaLbM+xh8K3utammZIzVmdyTXkR1FDqds2h+obxGZvdaIP574/UaC4j6lbFFLJ2fR/0hlQenifKnGhF9sW2FmH/69G8klKoE0mUHW5463m0/D0j4M0uPE= - - NEO_CC_URL=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 - - NEO_CC=$HOME/cc/cc-test-reporter - - -before_script: - - yarn lint - - ([[ -e $NEO_CC ]] || curl -L $NEO_CC_URL > $NEO_CC) && chmod +x $NEO_CC - - $NEO_CC before-build -script: - - yarn test $([ -z "$SAUCE_ACCESS_KEY"] && echo "--skip-plugin sauce") - - $NEO_CC after-build --exit-code $TRAVIS_TEST_RESULT - -notifications: - slack: - secure: h7CJKsyJdZstrUUBuyRbWpXVpT5ZrDR8cnsRSoAWbpC37y7FQTtUR/70umVGphm5JlRuwxxeg2WASjgaToIYuwb/1G2CnwuVfitNl/SyxwAmyeFLkdmpG2VoV0PYs475x2Ta24tmSojAwmJhuHdVPE5SMyUdxcUcQpvfkHIlo9hizdfvdHMru38eDZBjnx8FDAX9a79qEtUDkUoN79GsoyO4qqxUjXqpMoY64OonyhIslgHbJmd+jUaTCnD9WqhS2PH6h0NBW2U/jw2G5hvWUDyex65I6PV6YAQt58bNH7yf+o+pkTDlq675LqrJZ1Wcf30U9QZiR74Su2bv6xUiY1pbnzf8MMV/mwKYKFU1MpNE/FV5JXhTMN3RYJ4udQ4weQVKoEob4wS7XYgrjBNJ9Wkl+Je+H1PgiYHAHEb5RVzVDtznSMqWBu/I13/sEj10JIJwEZMXtuZmRT1Kyatkhl38PKldPSQtR7H8rvT+tUeUvlDRWt3kpBwOPsiK5/XEDmxlu2TtMnX+MMARCNPfP/Z23dkHCPAdK3Sjc+IatZECOKFYH1Km2p8lnBEIrCKgFMqQH9WqUaM9DMaLVzHqP3S5NkuYYQUvBOQCM9tw/1115Z2AHTq1lR1oXBPO+RTFo/UL0S3ohw3UD+u+j53DOpLDIJjgp8NTvpjkTeeLiks= From d14d9f1550263e6f9052ba3f19b9eff885802c76 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Tue, 3 Sep 2019 12:04:40 +0200 Subject: [PATCH 14/24] try in parallel --- .github/workflows/workflow.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d5788b5..6a4a118 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -7,7 +7,7 @@ on: branches: - master jobs: - build: + eslint: runs-on: ubuntu-latest steps: - name: Checkout @@ -24,8 +24,21 @@ jobs: - name: Annotated ESLint uses: rkusa/eslint-action@1.0.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Use Node.js 10.x + uses: actions/setup-node@v1 + with: + version: 10.x + - name: Install + run: npm install - name: Polymer lint run: npx polymer lint cosmoz-treenode.js @@ -41,6 +54,3 @@ jobs: $NEO_CC before-build npm run test $([ -z "$SAUCE_ACCESS_KEY"] && echo "-- --skip-plugin sauce") $NEO_CC after-build --exit-code $? - - - name: Build - run: npm run build --if-present From 604848740eb005b698963dfa2b19bb5536cb217c Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Tue, 10 Sep 2019 20:59:42 +0200 Subject: [PATCH 15/24] Try our own eslint annotator --- .github/workflows/workflow.yml | 6 ++ annotate-eslint.js | 133 +++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 annotate-eslint.js diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6a4a118..1b18dff 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -39,6 +39,12 @@ jobs: - name: Install run: npm install + + - name: ESLint + run: node annotate-eslint.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Polymer lint run: npx polymer lint cosmoz-treenode.js diff --git a/annotate-eslint.js b/annotate-eslint.js new file mode 100644 index 0000000..4b85c87 --- /dev/null +++ b/annotate-eslint.js @@ -0,0 +1,133 @@ +/* eslint-disable camelcase */ // github API convention +/* eslint-env node */ +const exitWithError = err => { + console.error('Error', err.stack); + if (err.data) { + console.error(err.data); + } + process.exit(1); + }, + { GITHUB_SHA, GITHUB_EVENT_PATH, GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env; + +if (GITHUB_TOKEN == null) { + exitWithError(new Error('Missing Github token')); +} + +const https = require('https'), + request = (url, options) => + new Promise((resolve, reject) => { + const req = https + .request(url, options, res => { + let data = ''; + res.on('data', chunk => { + data += chunk; + }); + res.on('end', () => { + if (res.statusCode >= 400) { + const err = new Error(`Received status code ${ res.statusCode }`); + err.response = res; + err.data = data; + reject(err); + } else { + resolve({ res, data: JSON.parse(data) }); + } + }); + }) + .on('error', reject); + if (options.body) { + req.end(JSON.stringify(options.body)); + } else { + req.end(); + } + }), + event = require(GITHUB_EVENT_PATH), + { repository } = event, + { owner: { login: owner } } = repository, + { name: repo } = repository, + checkName = 'ESLint check', + headers = { + 'Content-Type': 'application/json', + Accept: 'application/vnd.github.antiope-preview+json', + Authorization: `Bearer ${ GITHUB_TOKEN }`, + 'User-Agent': 'eslint-action' + }, + createCheck = async () => { + const body = { + name: checkName, + head_sha: GITHUB_SHA, + status: 'in_progress', + started_at: new Date() + }, + { data } = await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs`, { + method: 'POST', + headers, + body + }), + { id } = data; + console.log('check create', data); + return id; + }, + eslint = () => { + const eslint = require('eslint'), + cli = new eslint.CLIEngine(), + report = cli.executeOnFiles(['.']), + // fixableErrorCount, fixableWarningCount are available too + { results, errorCount, warningCount } = report, + levels = ['', 'warning', 'failure']; + + console.log('results', results); + + const annotations = results.reduce((annoList, result) => { + const { filePath, messages } = result, + path = filePath.substring(GITHUB_WORKSPACE.length + 1); + return annoList.concat(messages.map(msg => { + const { line, severity, ruleId, message } = msg, + annotationLevel = levels[severity]; + return { + path, + start_line: line, + end_line: line, + annotation_level: annotationLevel, + message: `[${ruleId}] ${message}` + }; + })); + }, []); + + return { + conclusion: errorCount > 0 ? 'failure' : 'success', + output: { + title: checkName, + summary: `${ errorCount } error(s), ${ warningCount } warning(s) found`, + annotations + } + }; + }, + updateCheck = async (id, conclusion, output) => + await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs/${ id }`, { + method: 'PATCH', + headers, + body: { + name: checkName, + head_sha: GITHUB_SHA, + status: 'completed', + completed_at: new Date(), + conclusion, + output + } + }), + run = async () => { + const id = await createCheck(); + try { + const { conclusion, output } = eslint(); + console.log(conclusion, output); + await updateCheck(id, conclusion, output); + if (conclusion === 'failure') { + process.exit(78); + } + } catch (err) { + await updateCheck(id, 'failure'); + exitWithError(err); + } + }; + +run().catch(exitWithError); From ebf9cc2cce2f1c4eead844f966e2cbc021ffed5c Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Tue, 10 Sep 2019 21:31:33 +0200 Subject: [PATCH 16/24] Add some to APIs --- annotate-eslint.js | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/annotate-eslint.js b/annotate-eslint.js index 4b85c87..876e7e9 100644 --- a/annotate-eslint.js +++ b/annotate-eslint.js @@ -52,20 +52,18 @@ const https = require('https'), 'User-Agent': 'eslint-action' }, createCheck = async () => { - const body = { + const { data } = await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs`, { + method: 'POST', + headers, + body: { name: checkName, head_sha: GITHUB_SHA, status: 'in_progress', - started_at: new Date() - }, - { data } = await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs`, { - method: 'POST', - headers, - body - }), - { id } = data; + started_at: (new Date()).toISOString() + } + }); console.log('check create', data); - return id; + return data.id; }, eslint = () => { const eslint = require('eslint'), @@ -73,22 +71,26 @@ const https = require('https'), report = cli.executeOnFiles(['.']), // fixableErrorCount, fixableWarningCount are available too { results, errorCount, warningCount } = report, - levels = ['', 'warning', 'failure']; + levels = ['notice', 'warning', 'failure']; console.log('results', results); const annotations = results.reduce((annoList, result) => { const { filePath, messages } = result, path = filePath.substring(GITHUB_WORKSPACE.length + 1); - return annoList.concat(messages.map(msg => { - const { line, severity, ruleId, message } = msg, - annotationLevel = levels[severity]; + return annoList.concat(messages.map(m => { + console.log('msg', m); + const singleLine = m.line === m.endLine; return { path, - start_line: line, - end_line: line, - annotation_level: annotationLevel, - message: `[${ruleId}] ${message}` + start_column: singleLine && m.column, + end_column: singleLine && m.endColumn, + start_line: m.line, + end_line: m.endLine, + annotation_level: levels[m.severity], + // title: `${ path }#L${ m.line }`, + message: `${ m.ruleId }: ${ m.message }`, + raw_details: 'Nothing much' }; })); }, []); @@ -98,6 +100,7 @@ const https = require('https'), output: { title: checkName, summary: `${ errorCount } error(s), ${ warningCount } warning(s) found`, + text: 'A little bit of text', annotations } }; @@ -110,7 +113,7 @@ const https = require('https'), name: checkName, head_sha: GITHUB_SHA, status: 'completed', - completed_at: new Date(), + completed_at: (new Date()).toISOString(), conclusion, output } @@ -130,4 +133,6 @@ const https = require('https'), } }; +console.log(event); + run().catch(exitWithError); From 7626b388cc38383f041ea4186f48592a7dd1708f Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Wed, 11 Sep 2019 06:47:43 +0200 Subject: [PATCH 17/24] Try another SHA --- annotate-eslint.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/annotate-eslint.js b/annotate-eslint.js index 876e7e9..361f9d2 100644 --- a/annotate-eslint.js +++ b/annotate-eslint.js @@ -41,6 +41,7 @@ const https = require('https'), } }), event = require(GITHUB_EVENT_PATH), + { pull_request: { head: { sha: prSha }}} = event, { repository } = event, { owner: { login: owner } } = repository, { name: repo } = repository, @@ -57,7 +58,7 @@ const https = require('https'), headers, body: { name: checkName, - head_sha: GITHUB_SHA, + head_sha: prSha || GITHUB_SHA, status: 'in_progress', started_at: (new Date()).toISOString() } @@ -111,7 +112,7 @@ const https = require('https'), headers, body: { name: checkName, - head_sha: GITHUB_SHA, + head_sha: prSha || GITHUB_SHA, status: 'completed', completed_at: (new Date()).toISOString(), conclusion, From 75eb579f163d7d067847132121664605411c4301 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Wed, 11 Sep 2019 07:42:46 +0200 Subject: [PATCH 18/24] Clean-up --- annotate-eslint.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/annotate-eslint.js b/annotate-eslint.js index 361f9d2..caef82d 100644 --- a/annotate-eslint.js +++ b/annotate-eslint.js @@ -41,11 +41,21 @@ const https = require('https'), } }), event = require(GITHUB_EVENT_PATH), - { pull_request: { head: { sha: prSha }}} = event, - { repository } = event, - { owner: { login: owner } } = repository, - { name: repo } = repository, + { + pull_request: { + head: { + sha: prSha + } + }, + repository: { + name: repo, + owner: { + login: owner + } + } + } = event, checkName = 'ESLint check', + checkSha = prSha || GITHUB_SHA, headers = { 'Content-Type': 'application/json', Accept: 'application/vnd.github.antiope-preview+json', @@ -58,12 +68,11 @@ const https = require('https'), headers, body: { name: checkName, - head_sha: prSha || GITHUB_SHA, + head_sha: checkSha, status: 'in_progress', started_at: (new Date()).toISOString() } }); - console.log('check create', data); return data.id; }, eslint = () => { @@ -71,16 +80,11 @@ const https = require('https'), cli = new eslint.CLIEngine(), report = cli.executeOnFiles(['.']), // fixableErrorCount, fixableWarningCount are available too - { results, errorCount, warningCount } = report, levels = ['notice', 'warning', 'failure']; - console.log('results', results); - - const annotations = results.reduce((annoList, result) => { - const { filePath, messages } = result, - path = filePath.substring(GITHUB_WORKSPACE.length + 1); - return annoList.concat(messages.map(m => { - console.log('msg', m); + const annotations = report.results.reduce((annoList, result) => { + const path = result.filePath.substring(GITHUB_WORKSPACE.length + 1); + return annoList.concat(result.messages.map(m => { const singleLine = m.line === m.endLine; return { path, @@ -90,12 +94,14 @@ const https = require('https'), end_line: m.endLine, annotation_level: levels[m.severity], // title: `${ path }#L${ m.line }`, - message: `${ m.ruleId }: ${ m.message }`, - raw_details: 'Nothing much' + // raw_details: 'Nothing much', + message: `${ m.ruleId }: ${ m.message }` }; })); }, []); + const { errorCount, warningCount } = report; + return { conclusion: errorCount > 0 ? 'failure' : 'success', output: { @@ -112,7 +118,7 @@ const https = require('https'), headers, body: { name: checkName, - head_sha: prSha || GITHUB_SHA, + head_sha: checkSha, status: 'completed', completed_at: (new Date()).toISOString(), conclusion, @@ -134,6 +140,4 @@ const https = require('https'), } }; -console.log(event); - run().catch(exitWithError); From 800a145ec3bf58332dbe00a6d8b60a4065cf09c7 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Wed, 11 Sep 2019 09:53:05 +0200 Subject: [PATCH 19/24] Use published github-actions-eslint-annotator with npx Signed-off-by: Patrik Kullman Signed-off-by: Patrik Kullman --- .github/workflows/workflow.yml | 21 +---- annotate-eslint.js | 143 --------------------------------- 2 files changed, 1 insertion(+), 163 deletions(-) delete mode 100644 annotate-eslint.js diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 1b18dff..0c7852f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -7,25 +7,6 @@ on: branches: - master jobs: - eslint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - - name: Use Node.js 10.x - uses: actions/setup-node@v1 - with: - version: 10.x - - - name: Install - run: npm install - - - name: Annotated ESLint - uses: rkusa/eslint-action@1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - test: runs-on: ubuntu-latest steps: @@ -41,7 +22,7 @@ jobs: run: npm install - name: ESLint - run: node annotate-eslint.js + run: npx @neovici/github-actions-eslint-annotator@0.1.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/annotate-eslint.js b/annotate-eslint.js deleted file mode 100644 index caef82d..0000000 --- a/annotate-eslint.js +++ /dev/null @@ -1,143 +0,0 @@ -/* eslint-disable camelcase */ // github API convention -/* eslint-env node */ -const exitWithError = err => { - console.error('Error', err.stack); - if (err.data) { - console.error(err.data); - } - process.exit(1); - }, - { GITHUB_SHA, GITHUB_EVENT_PATH, GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env; - -if (GITHUB_TOKEN == null) { - exitWithError(new Error('Missing Github token')); -} - -const https = require('https'), - request = (url, options) => - new Promise((resolve, reject) => { - const req = https - .request(url, options, res => { - let data = ''; - res.on('data', chunk => { - data += chunk; - }); - res.on('end', () => { - if (res.statusCode >= 400) { - const err = new Error(`Received status code ${ res.statusCode }`); - err.response = res; - err.data = data; - reject(err); - } else { - resolve({ res, data: JSON.parse(data) }); - } - }); - }) - .on('error', reject); - if (options.body) { - req.end(JSON.stringify(options.body)); - } else { - req.end(); - } - }), - event = require(GITHUB_EVENT_PATH), - { - pull_request: { - head: { - sha: prSha - } - }, - repository: { - name: repo, - owner: { - login: owner - } - } - } = event, - checkName = 'ESLint check', - checkSha = prSha || GITHUB_SHA, - headers = { - 'Content-Type': 'application/json', - Accept: 'application/vnd.github.antiope-preview+json', - Authorization: `Bearer ${ GITHUB_TOKEN }`, - 'User-Agent': 'eslint-action' - }, - createCheck = async () => { - const { data } = await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs`, { - method: 'POST', - headers, - body: { - name: checkName, - head_sha: checkSha, - status: 'in_progress', - started_at: (new Date()).toISOString() - } - }); - return data.id; - }, - eslint = () => { - const eslint = require('eslint'), - cli = new eslint.CLIEngine(), - report = cli.executeOnFiles(['.']), - // fixableErrorCount, fixableWarningCount are available too - levels = ['notice', 'warning', 'failure']; - - const annotations = report.results.reduce((annoList, result) => { - const path = result.filePath.substring(GITHUB_WORKSPACE.length + 1); - return annoList.concat(result.messages.map(m => { - const singleLine = m.line === m.endLine; - return { - path, - start_column: singleLine && m.column, - end_column: singleLine && m.endColumn, - start_line: m.line, - end_line: m.endLine, - annotation_level: levels[m.severity], - // title: `${ path }#L${ m.line }`, - // raw_details: 'Nothing much', - message: `${ m.ruleId }: ${ m.message }` - }; - })); - }, []); - - const { errorCount, warningCount } = report; - - return { - conclusion: errorCount > 0 ? 'failure' : 'success', - output: { - title: checkName, - summary: `${ errorCount } error(s), ${ warningCount } warning(s) found`, - text: 'A little bit of text', - annotations - } - }; - }, - updateCheck = async (id, conclusion, output) => - await request(`https://api.github.com/repos/${ owner }/${ repo }/check-runs/${ id }`, { - method: 'PATCH', - headers, - body: { - name: checkName, - head_sha: checkSha, - status: 'completed', - completed_at: (new Date()).toISOString(), - conclusion, - output - } - }), - run = async () => { - const id = await createCheck(); - try { - const { conclusion, output } = eslint(); - console.log(conclusion, output); - await updateCheck(id, conclusion, output); - if (conclusion === 'failure') { - process.exit(78); - } - } catch (err) { - await updateCheck(id, 'failure'); - exitWithError(err); - } - }; - -run().catch(exitWithError); From 2d3a59b9785f9cdeef91408a5baca20bca905bf7 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Wed, 11 Sep 2019 10:12:31 +0200 Subject: [PATCH 20/24] Use annotator as dev dep Signed-off-by: Patrik Kullman --- .github/workflows/workflow.yml | 2 +- package-lock.json | 9 +++++++++ package.json | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 0c7852f..d6bfa4f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -22,7 +22,7 @@ jobs: run: npm install - name: ESLint - run: npx @neovici/github-actions-eslint-annotator@0.1.1 + run: npx github-actions-eslint-annotator env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package-lock.json b/package-lock.json index 29daa45..2282ba1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -206,6 +206,15 @@ "from": "github:neovici/eslint-config#semver:^1.0.0", "dev": true }, + "@neovici/github-actions-eslint-annotator": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@neovici/github-actions-eslint-annotator/-/github-actions-eslint-annotator-0.1.1.tgz", + "integrity": "sha512-N2lUeF1XqfMC/8Cb+94mWe2V4t4+EI67qZnS5PMAZe+J6Rop/xVHS84r47RfZ7SOLEbOPIfl2c4vsqvHA1CYjQ==", + "dev": true, + "requires": { + "eslint": "^5.15.1" + } + }, "@polymer/app-layout": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@polymer/app-layout/-/app-layout-3.1.0.tgz", diff --git a/package.json b/package.json index 122223b..05c9937 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ }, "devDependencies": { "@neovici/eslint-config": "github:neovici/eslint-config#semver:^1.0.0", + "@neovici/github-actions-eslint-annotator": "^0.1.1", "@polymer/iron-component-page": "^4.0.0", "@polymer/iron-demo-helpers": "^3.0.0", "@polymer/iron-test-helpers": "^3.0.0", From 0ccb7be42dc14ca50a7aaed810274b903005743e Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Thu, 12 Sep 2019 09:15:21 +0200 Subject: [PATCH 21/24] Drop more Polymer stuff Signed-off-by: Patrik Kullman --- .github/workflows/workflow.yml | 5 +---- package.json | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d6bfa4f..9c25a85 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,15 +19,12 @@ jobs: version: 10.x - name: Install - run: npm install + run: npm ci - name: ESLint run: npx github-actions-eslint-annotator env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Polymer lint - run: npx polymer lint cosmoz-treenode.js - name: Test and report env: diff --git a/package.json b/package.json index 05c9937..5e8a46c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "4.0.1", "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-treenode.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-treenode)", "keywords": [ - "polymer", + "lit-element", "web-components" ], "homepage": "https://github.com/neovici/cosmoz-treenode#readme", @@ -15,13 +15,12 @@ "url": "git+https://github.com/neovici/cosmoz-treenode.git" }, "license": "Apache-2.0", - "author": "", + "author": "Neovici dev", "main": "cosmoz-treenode.js", "directories": { "test": "test" }, "scripts": { - "analyze": "polymer analyze --input cosmoz-*.js > analysis.json", "lint": "eslint --cache --ext .js .", "preversion": "npm run lint && npm run test -- --skip-plugin sauce", "postversion": "git push && git push --tags", From 647f878e7fa4461b8b118a5412787fc720f3643a Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Thu, 12 Sep 2019 09:16:36 +0200 Subject: [PATCH 22/24] Upgrade annotator Signed-off-by: Patrik Kullman --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2282ba1..edb510d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -207,9 +207,9 @@ "dev": true }, "@neovici/github-actions-eslint-annotator": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@neovici/github-actions-eslint-annotator/-/github-actions-eslint-annotator-0.1.1.tgz", - "integrity": "sha512-N2lUeF1XqfMC/8Cb+94mWe2V4t4+EI67qZnS5PMAZe+J6Rop/xVHS84r47RfZ7SOLEbOPIfl2c4vsqvHA1CYjQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@neovici/github-actions-eslint-annotator/-/github-actions-eslint-annotator-0.1.2.tgz", + "integrity": "sha512-42ZL8wW3XqWlVhpua19jVEQIkn6/7JWcCqmEsz7sJqiV2mUFgwv19/JH7B9Uuxj5Xv68ZIGdiprRKJz3r3HN0w==", "dev": true, "requires": { "eslint": "^5.15.1" diff --git a/package.json b/package.json index 5e8a46c..294a5ed 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@neovici/eslint-config": "github:neovici/eslint-config#semver:^1.0.0", - "@neovici/github-actions-eslint-annotator": "^0.1.1", + "@neovici/github-actions-eslint-annotator": "^0.1.2", "@polymer/iron-component-page": "^4.0.0", "@polymer/iron-demo-helpers": "^3.0.0", "@polymer/iron-test-helpers": "^3.0.0", From 0f9d39ac0c4387e0a82079c9fd05ce65a7af8b75 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Thu, 12 Sep 2019 11:31:26 +0200 Subject: [PATCH 23/24] Try to fix code climate references Signed-off-by: Patrik Kullman --- .github/workflows/workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9c25a85..7d7311b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -29,6 +29,8 @@ jobs: - name: Test and report env: CC_TEST_REPORTER_ID: 5286fe366f9880c571dcdfe0d7748a6343eb7eb0788250626df792cd3120ab87 + GIT_BRANCH: ${{ github.ref }} + GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} NEO_CC_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 NEO_CC: ./cc-test-reporter SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} From 71a460a744faa55293c38cb28598824728b55243 Mon Sep 17 00:00:00 2001 From: Patrik Kullman Date: Thu, 12 Sep 2019 11:41:36 +0200 Subject: [PATCH 24/24] Fix eslint error Signed-off-by: Patrik Kullman --- cosmoz-treenode.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cosmoz-treenode.js b/cosmoz-treenode.js index 8706188..db1f672 100644 --- a/cosmoz-treenode.js +++ b/cosmoz-treenode.js @@ -162,7 +162,6 @@ class CosmozTreenode extends ComputingLitElement { } _computePathText(pathToRender, valueProperty, pathSeparator) { - console.log('test eslint error'); if (!pathToRender) { return ''; }