style: Fix all eslint errors

This commit is contained in:
Edmund Miller 2022-11-13 15:56:49 -06:00 committed by Thomas A. Christensen II
parent ea5ce95ba5
commit aebdb951b0
2 changed files with 36 additions and 20 deletions

View file

@ -1,11 +1,16 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as fs from 'fs' import * as fs from 'fs'
import retry = require('async-retry') import * as tc from '@actions/tool-cache'
import semver = require('semver') import {GitHub} from '@actions/github/lib/utils'
import retry from 'async-retry'
import semver from 'semver'
const NEXTFLOW_REPO = {owner: 'nextflow-io', repo: 'nextflow'} const NEXTFLOW_REPO = {owner: 'nextflow-io', repo: 'nextflow'}
async function all_nf_releases(ok) { // HACK Private but I want to test this
export async function all_nf_releases(
ok: InstanceType<typeof GitHub>
): Promise<object> {
return await ok.paginate( return await ok.paginate(
ok.rest.repos.listReleases, ok.rest.repos.listReleases,
NEXTFLOW_REPO, NEXTFLOW_REPO,
@ -13,7 +18,10 @@ async function all_nf_releases(ok) {
) )
} }
async function latest_stable_release_data(ok) { // HACK Private but I want to test this
export async function latest_stable_release_data(
ok: InstanceType<typeof GitHub>
): Promise<object> {
const {data: stable_release} = await ok.rest.repos.getLatestRelease( const {data: stable_release} = await ok.rest.repos.getLatestRelease(
NEXTFLOW_REPO NEXTFLOW_REPO
) )
@ -21,9 +29,12 @@ async function latest_stable_release_data(ok) {
return stable_release return stable_release
} }
export async function release_data(version, ok) { export async function release_data(
version: string,
ok: InstanceType<typeof GitHub>
): Promise<object> {
// Setup tag-based filtering // Setup tag-based filtering
let filter = r => { let filter = (r: object): boolean => {
return semver.satisfies(r.tag_name, version, true) return semver.satisfies(r.tag_name, version, true)
} }
@ -32,7 +43,8 @@ export async function release_data(version, ok) {
if (version.includes('latest')) { if (version.includes('latest')) {
if (version.includes('-everything')) { if (version.includes('-everything')) {
// No filtering // No filtering
filter = r => { // eslint-disable-next-line @typescript-eslint/no-unused-vars
filter = (r: object) => {
return true return true
} }
} else if (version.includes('-edge')) { } else if (version.includes('-edge')) {
@ -50,7 +62,7 @@ export async function release_data(version, ok) {
// Get all the releases // Get all the releases
const all_releases = await all_nf_releases(ok) const all_releases = await all_nf_releases(ok)
let matching_releases = all_releases.filter(filter) const matching_releases = all_releases.filter(filter)
matching_releases.sort(function (x, y) { matching_releases.sort(function (x, y) {
semver.compare(x.tag_name, y.tag_name, true) semver.compare(x.tag_name, y.tag_name, true)
@ -59,13 +71,13 @@ export async function release_data(version, ok) {
return matching_releases[0] return matching_releases[0]
} }
export function nextflow_bin_url(release, get_all) { export function nextflow_bin_url(release, get_all: boolean): string {
const release_assets = release.assets const release_assets = release.assets
const all_asset = release_assets.filter(a => { const all_asset = release_assets.filter(a => {
return a.browser_download_url.endsWith('-all') return a.browser_download_url.endsWith('-all')
})[0] })[0]
const regular_asset = release_assets.filter(a => { const regular_asset = release_assets.filter(a => {
return a.name == 'nextflow' return a.name === 'nextflow'
})[0] })[0]
const dl_asset = get_all ? all_asset : regular_asset const dl_asset = get_all ? all_asset : regular_asset
@ -73,9 +85,13 @@ export function nextflow_bin_url(release, get_all) {
return dl_asset.browser_download_url return dl_asset.browser_download_url
} }
export async function install_nextflow(url, version) { export async function install_nextflow(
url: string,
version: string
): Promise<string> {
core.debug(`Downloading Nextflow from ${url}`) core.debug(`Downloading Nextflow from ${url}`)
const nf_dl_path = await retry( const nf_dl_path = await retry(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async bail => { async bail => {
return await tc.downloadTool(url) return await tc.downloadTool(url)
}, },

View file

@ -3,9 +3,9 @@ import * as exec from '@actions/exec'
import * as fs from 'fs' import * as fs from 'fs'
import * as github from '@actions/github' import * as github from '@actions/github'
import * as tc from '@actions/tool-cache' import * as tc from '@actions/tool-cache'
import {release_data, nextflow_bin_url, install_nextflow} from './functions' import {install_nextflow, nextflow_bin_url, release_data} from './functions'
async function run() { async function run(): Promise<void> {
// Set environment variables // Set environment variables
core.exportVariable('CAPSULE_LOG', 'none') core.exportVariable('CAPSULE_LOG', 'none')
@ -20,19 +20,19 @@ async function run() {
let octokit = {} let octokit = {}
try { try {
octokit = github.getOctokit(token) octokit = github.getOctokit(token)
} catch (e: any) { } catch (e) {
core.setFailed( core.setFailed(
`Could not authenticate to GitHub Releases API with provided token\n${e.message}` `Could not authenticate to GitHub Releases API with provided token\n${e.message}`
) )
} }
// Get the release info for the desired release // Get the release info for the desired release
let release: any = {} let release = {}
try { try {
release = await release_data(version, octokit) release = await release_data(version, octokit)
resolved_version = release.tag_name resolved_version = release.tag_name
core.info(`Input version '${version}' resolved to Nextflow ${release.name}`) core.info(`Input version '${version}' resolved to Nextflow ${release.name}`)
} catch (e: any) { } catch (e) {
core.setFailed( core.setFailed(
`Could not retrieve Nextflow release matching ${version}.\n${e.message}` `Could not retrieve Nextflow release matching ${version}.\n${e.message}`
) )
@ -43,7 +43,7 @@ async function run() {
try { try {
url = nextflow_bin_url(release, get_all) url = nextflow_bin_url(release, get_all)
core.info(`Preparing to download from ${url}`) core.info(`Preparing to download from ${url}`)
} catch (e: any) { } catch (e) {
core.setFailed(`Could not parse the download URL\n${e.message}`) core.setFailed(`Could not parse the download URL\n${e.message}`)
} }
try { try {
@ -66,14 +66,14 @@ async function run() {
core.addPath(nf_path) core.addPath(nf_path)
core.info(`Downloaded \`nextflow\` to ${nf_path} and added to PATH`) core.info(`Downloaded \`nextflow\` to ${nf_path} and added to PATH`)
} catch (e: any) { } catch (e) {
core.setFailed(e.message) core.setFailed(e.message)
} }
// Run Nextflow so it downloads its dependencies // Run Nextflow so it downloads its dependencies
try { try {
const nf_exit_code = await exec.exec('nextflow', ['help']) await exec.exec('nextflow', ['help'])
} catch (e: any) { } catch (e) {
core.warning( core.warning(
'Nextflow appears to have installed correctly, but an error was thrown while running it.' 'Nextflow appears to have installed correctly, but an error was thrown while running it.'
) )