Skip to content

Commit

Permalink
Fix lint errors (and add linting to CI)
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Lane <[email protected]>
  • Loading branch information
rick-a-lane-ii committed Mar 6, 2024
1 parent 56cc019 commit e6478c6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
1 change: 0 additions & 1 deletion .github/actions/provision-cluster/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const core = require('@actions/core')
const github = require('@actions/github')

const registry = require('./lib/registry.js')
const utils = require('./lib/utils.js')
Expand Down
5 changes: 2 additions & 3 deletions .github/actions/provision-cluster/delete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const core = require('@actions/core')
const github = require('@actions/github')

const registry = require('./lib/registry.js')
const slack = require('./lib/slack.js')
Expand All @@ -24,14 +23,14 @@ async function do_delete() {
return Promise.all(promises)
}

async function expire(provider, distribution) {
async function expire(provider) {
let orphaned = await provider.expireClusters()

if (orphaned.length == 0) {
return
}

core.notice(`Orhpaned Clusters: ${orphaned.join(', ')}`)
core.notice(`Orphaned Clusters: ${orphaned.join(', ')}`)
slack.notify(`Orphaned clusters:\n\n - ${orphaned.join("\n - ")}`)
}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/provision-cluster/lib/gke.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const core = require('@actions/core')
const container = require('@google-cloud/container')
const crypto = require('crypto')
const utils = require('./utils.js')

const STATUS_ENUM = container.protos.google.container.v1.Operation.Status
Expand Down
1 change: 0 additions & 1 deletion .github/actions/provision-cluster/lib/gke.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const gke = require('./gke.js')
const common = require('./common_test.js')
const mock = require('./mock.js')

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/provision-cluster/lib/kubeception.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('kubeception profile', async ()=>{
}
}
}
async del(url) {
async del() {
return {
message: {
statusCode: 200
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/provision-cluster/lib/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ class MockGKE {
return [cluster]
}

async getOperation(op) {
async getOperation() {
return [new MockOp()]
}

}

class MockAuth {

getAccessToken() {
return MOCK.ACCESS_TOKEN
}
Expand Down
15 changes: 12 additions & 3 deletions .github/actions/provision-cluster/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,35 @@ class Transient extends Error {}
async function fibonacciRetry(action, timeout=600000, minDelay=1000, maxDelay=30000) {
let start = Date.now()
let nextDelay = fibonacciDelaySequence(minDelay, maxDelay)
for (let count = 1; true; count++) {

let count = 0;
let timeoutReached = false;

do {
count++;

try {
return await action()
} catch (e) {
if (!(e instanceof Transient) && !(e instanceof Retry)) {
throw e
}
let delay = nextDelay()
let now = Date.now()
let elapsed = Date.now() - start
let remaining = timeout - elapsed
if (remaining > 0) {
let t = Math.min(delay, remaining)
core.info(`Error (${e.message}) retrying after ${t/1000}s ...`)
await sleep(t)
} else {
timeoutReached = true;
}

if (timeoutReached) {
throw new Error(`Error (${e.message}) failing after ${count} attempts over ${elapsed/1000}s.`)
}
}
}
} while (!timeoutReached);
}

module.exports = { getUniqueClusterName, writeFile, sleep, fibonacciDelaySequence, uid, Retry, Transient, fibonacciRetry }
2 changes: 2 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
node-version: ${{ matrix.node-version }}
- working-directory: .github/actions/provision-cluster
run: npm ci
- working-directory: .github/actions/provision-cluster
run: npm run lint
- working-directory: .github/actions/provision-cluster
run: npm run build --if-present
- working-directory: .github/actions/provision-cluster
Expand Down

0 comments on commit e6478c6

Please sign in to comment.