mirror of
https://github.com/MillironX/setup-nextflow.git
synced 2024-12-22 12:58:17 +00:00
style: Fix all eslint errors
This commit is contained in:
parent
ea5ce95ba5
commit
aebdb951b0
2 changed files with 36 additions and 20 deletions
|
@ -1,11 +1,16 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as fs from 'fs'
|
||||
import retry = require('async-retry')
|
||||
import semver = require('semver')
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import {GitHub} from '@actions/github/lib/utils'
|
||||
import retry from 'async-retry'
|
||||
import semver from 'semver'
|
||||
|
||||
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(
|
||||
ok.rest.repos.listReleases,
|
||||
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(
|
||||
NEXTFLOW_REPO
|
||||
)
|
||||
|
@ -21,9 +29,12 @@ async function latest_stable_release_data(ok) {
|
|||
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
|
||||
let filter = r => {
|
||||
let filter = (r: object): boolean => {
|
||||
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('-everything')) {
|
||||
// No filtering
|
||||
filter = r => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
filter = (r: object) => {
|
||||
return true
|
||||
}
|
||||
} else if (version.includes('-edge')) {
|
||||
|
@ -50,7 +62,7 @@ export async function release_data(version, ok) {
|
|||
// Get all the releases
|
||||
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) {
|
||||
semver.compare(x.tag_name, y.tag_name, true)
|
||||
|
@ -59,13 +71,13 @@ export async function release_data(version, ok) {
|
|||
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 all_asset = release_assets.filter(a => {
|
||||
return a.browser_download_url.endsWith('-all')
|
||||
})[0]
|
||||
const regular_asset = release_assets.filter(a => {
|
||||
return a.name == 'nextflow'
|
||||
return a.name === 'nextflow'
|
||||
})[0]
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
export async function install_nextflow(url, version) {
|
||||
export async function install_nextflow(
|
||||
url: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
core.debug(`Downloading Nextflow from ${url}`)
|
||||
const nf_dl_path = await retry(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async bail => {
|
||||
return await tc.downloadTool(url)
|
||||
},
|
||||
|
|
18
src/main.ts
18
src/main.ts
|
@ -3,9 +3,9 @@ import * as exec from '@actions/exec'
|
|||
import * as fs from 'fs'
|
||||
import * as github from '@actions/github'
|
||||
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
|
||||
core.exportVariable('CAPSULE_LOG', 'none')
|
||||
|
||||
|
@ -20,19 +20,19 @@ async function run() {
|
|||
let octokit = {}
|
||||
try {
|
||||
octokit = github.getOctokit(token)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
core.setFailed(
|
||||
`Could not authenticate to GitHub Releases API with provided token\n${e.message}`
|
||||
)
|
||||
}
|
||||
|
||||
// Get the release info for the desired release
|
||||
let release: any = {}
|
||||
let release = {}
|
||||
try {
|
||||
release = await release_data(version, octokit)
|
||||
resolved_version = release.tag_name
|
||||
core.info(`Input version '${version}' resolved to Nextflow ${release.name}`)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
core.setFailed(
|
||||
`Could not retrieve Nextflow release matching ${version}.\n${e.message}`
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ async function run() {
|
|||
try {
|
||||
url = nextflow_bin_url(release, get_all)
|
||||
core.info(`Preparing to download from ${url}`)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
core.setFailed(`Could not parse the download URL\n${e.message}`)
|
||||
}
|
||||
try {
|
||||
|
@ -66,14 +66,14 @@ async function run() {
|
|||
core.addPath(nf_path)
|
||||
|
||||
core.info(`Downloaded \`nextflow\` to ${nf_path} and added to PATH`)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
core.setFailed(e.message)
|
||||
}
|
||||
|
||||
// Run Nextflow so it downloads its dependencies
|
||||
try {
|
||||
const nf_exit_code = await exec.exec('nextflow', ['help'])
|
||||
} catch (e: any) {
|
||||
await exec.exec('nextflow', ['help'])
|
||||
} catch (e) {
|
||||
core.warning(
|
||||
'Nextflow appears to have installed correctly, but an error was thrown while running it.'
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue