Compare commits

...

12 commits

Author SHA1 Message Date
8e5e5dbd4c art: Add nf-core logo to README 2023-08-11 12:20:28 -05:00
Robrecht Cannoodt
2008cb75f6 no matrix is specified for 'test-14' 2023-07-10 21:41:26 -05:00
Edmund Miller
b77a1defc2
Merge pull request #15 from data-intuitive/run-unit-test-in-ci
Fix testing ci
2023-06-30 10:10:57 -05:00
Robrecht Cannoodt
e066eb124a Add helper function for checking the latest releases in the unit tests (#15). 2023-06-28 11:07:13 +02:00
Robrecht Cannoodt
7136a6f06e update more releases 2023-06-28 11:07:13 +02:00
Robrecht Cannoodt
07f474dd40 Fix release version check in unit test (#15). 2023-06-28 11:07:13 +02:00
Robrecht Cannoodt
c6daa302be Fix testing ci 2023-06-28 11:07:13 +02:00
Edmund Miller
62561112a2
ci: Reorganize when maximize-build-space is ran 2023-06-23 14:39:47 -05:00
Edmund Miller
3323654b16
ci: Add a test for PR #14 2023-06-23 14:37:20 -05:00
Edmund Miller
b9495c9762
Merge pull request #14 from data-intuitive/add-try-catch
Add try catch to fs.renameSync
2023-06-23 14:36:56 -05:00
Robrecht Cannoodt
be72b1dc0f If fs.renameSync fails (e.g. because source and destination files are on different partitions), try fs.copySync and fs.unlinkSync instead. 2023-06-22 09:18:37 +02:00
519edf8749
refactor: Add redirect for publishing action
The publishing action assumes that main in package.json points to the
entrypoint of the action. Since v1.2.0, however, that is no longer the
case. Rather than try a new system (or dive deep into the internals of
npm and what every directive means), we'll trick the action into uploading
the correct script by modifying the package.json file right before upload.
Add that hack.
2023-05-23 16:06:28 -05:00
11 changed files with 88 additions and 12 deletions

View file

@ -42,3 +42,18 @@ jobs:
version: ${{ matrix.nextflow_version }} version: ${{ matrix.nextflow_version }}
all: ${{ matrix.all_distribution }} all: ${{ matrix.all_distribution }}
- run: nextflow -v - run: nextflow -v
test-14:
runs-on: ubuntu-latest
steps:
- uses: easimon/maximize-build-space@v7
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: "npm"
- run: npm ci
- run: npm run build
- run: npm run package
- uses: ./
- run: nextflow -v

View file

@ -16,6 +16,7 @@ jobs:
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: npm run package - run: npm run package
- run: sed -i 's%lib/src/main.js%dist/index.js%' package.json
- uses: JasonEtco/build-and-tag-action@v1 - uses: JasonEtco/build-and-tag-action@v1
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}

View file

@ -23,5 +23,6 @@ jobs:
- run: npm run format:check - run: npm run format:check
- run: npm run lint - run: npm run lint
- run: npm run package - run: npm run package
# FIXME Token doesn't get passed correctly - run: npm run test
# - run: npm run test env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## Changed
- If `fs.renameSync` fails (e.g. because source and destination files are on different partitions), try `fs.copySync` and `fs.unlinkSync` instead (#14).
## Fixed
- Re-enable npm run test in CI (#15).
- Fix release version check in unit test (#15).
- Add helper function for checking the latest releases in the unit tests (#15).
## [1.3.0] - 2023-05-19 ## [1.3.0] - 2023-05-19
## Changed ## Changed

View file

@ -1,4 +1,4 @@
# Setup Nextflow for GitHub Actions # ![nf-core/setup-nextflow](docs/images/nfcore-setupnextflow_logo.png#gh-light-mode-only) ![nf-core/setup-nextflow](docs/images/nfcore-setupnextflow_logo_dark.png#gh-dark-mode-only)
[![Testing](https://github.com/nf-core/setup-nextflow/actions/workflows/example.yml/badge.svg)](https://github.com/nf-core/setup-nextflow/actions/workflows/example.yml) [![Testing](https://github.com/nf-core/setup-nextflow/actions/workflows/example.yml/badge.svg)](https://github.com/nf-core/setup-nextflow/actions/workflows/example.yml)
[![MIT License](https://img.shields.io/github/license/nf-core/setup-nextflow?logo=opensourceinitiative)](https://github.com/nf-core/setup-nextflow/blob/master/LICENSE) [![MIT License](https://img.shields.io/github/license/nf-core/setup-nextflow?logo=opensourceinitiative)](https://github.com/nf-core/setup-nextflow/blob/master/LICENSE)

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View file

@ -106,7 +106,13 @@ export async function install_nextflow(
const temp_install_dir = fs.mkdtempSync(`nxf-${version}`) const temp_install_dir = fs.mkdtempSync(`nxf-${version}`)
const nf_path = `${temp_install_dir}/nextflow` const nf_path = `${temp_install_dir}/nextflow`
try {
fs.renameSync(nf_dl_path, nf_path) fs.renameSync(nf_dl_path, nf_path)
} catch (err: unknown) {
core.debug(`Failed to rename file: ${err}`)
fs.copyFileSync(nf_dl_path, nf_path)
fs.unlinkSync(nf_dl_path)
}
fs.chmodSync(nf_path, "0711") fs.chmodSync(nf_path, "0711")
return temp_install_dir return temp_install_dir

View file

@ -3,7 +3,7 @@ import { GitHub } from "@actions/github/lib/utils"
import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved
import * as functions from "../src/functions" import * as functions from "../src/functions"
import { getToken } from "./utils" import { getReleaseTag, getToken } from "./utils"
const test = anyTest as TestFn<{ const test = anyTest as TestFn<{
token: string token: string
@ -29,7 +29,8 @@ test("lastest_stable_release_data", async t => {
t.context["octokit"] t.context["octokit"]
) )
t.is(typeof result, "object") t.is(typeof result, "object")
t.is(result["tag_name"], "v22.10.2") const expected = await getReleaseTag("nextflow-io/nextflow", false)
t.is(result["tag_name"], expected)
}) })
test.todo("nextflow_bin_url") test.todo("nextflow_bin_url")

View file

@ -3,7 +3,7 @@ import { GitHub } from "@actions/github/lib/utils"
import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved
import { release_data } from "../src/functions" import { release_data } from "../src/functions"
import { getToken } from "./utils" import { getReleaseTag, getToken } from "./utils"
const test = anyTest as TestFn<{ const test = anyTest as TestFn<{
token: string token: string
@ -19,12 +19,22 @@ test.before(t => {
} }
}) })
const macro = test.macro(async (t, version: string, expected: string) => { const macro = test.macro(async (t, version: string) => {
let expected
if (version === "latest-stable") {
expected = await getReleaseTag("nextflow-io/nextflow", false)
} else if (version === "latest-edge") {
expected = await getReleaseTag("nextflow-io/nextflow", true)
} else if (version === "latest-everything") {
expected = await getReleaseTag("nextflow-io/nextflow", undefined)
} else {
expected = version
}
const result = await release_data(version, t.context["octokit"]) const result = await release_data(version, t.context["octokit"])
t.is(result["tag_name"], expected) t.is(result["tag_name"], expected)
}) })
test("hard version", macro, "v22.10.2", "v22.10.2") test("hard version", macro, "v22.10.2")
test("latest-stable", macro, "latest-stable", "v22.10.2") test("latest-stable", macro, "latest-stable")
test("latest-edge", macro, "latest-edge", "v22.09.7-edge") test("latest-edge", macro, "latest-edge")
test("latest-everything", macro, "latest-everything", "v22.10.2") test("latest-everything", macro, "latest-everything")

View file

@ -1,3 +1,5 @@
import fetch from "node-fetch"
export function getToken(first: boolean): string { export function getToken(first: boolean): string {
const token = process.env["GITHUB_TOKEN"] || "" const token = process.env["GITHUB_TOKEN"] || ""
if (!token && first) { if (!token && first) {
@ -10,3 +12,31 @@ export function getToken(first: boolean): string {
return token return token
} }
/**
* Retrieves the release from a GitHub repository. This function allows to fetch
* either the latest release or the latest pre-release ("edge" release).
*
* @param {string} repo - The GitHub repository to fetch the release from,
* in the format 'owner/repo'.
* @param {boolean} [prerelease] - If true, fetches the latest pre-release.
* If false or undefined, fetches the latest release regardless of whether
* it's a pre-release or not.
*
* @returns {Promise<string>} A Promise that resolves to a string representing the tag name
* of the found release. If no release is found, the Promise resolves to 'Release not found'.
*/
export async function getReleaseTag(
repo: string,
prerelease?: boolean
): Promise<string> {
const response = await fetch(`https://api.github.com/repos/${repo}/releases`)
const releases = await response.json()
const release = releases.find(
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
(rel: any) => prerelease === undefined || rel.prerelease === prerelease
)
return release ? release.tag_name : "No release found"
}