mirror of
https://gitea.com/actions/setup-deno.git
synced 2025-12-13 11:56:58 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
041b854f97 | ||
|
|
ef28d469f1 | ||
|
|
0df5d9c641 | ||
|
|
85bf53342c |
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
|||||||
deno-version: ${{ matrix.deno }}
|
deno-version: ${{ matrix.deno }}
|
||||||
|
|
||||||
- name: Test Deno
|
- name: Test Deno
|
||||||
run: deno run https://deno.land/std/examples/welcome.ts
|
run: deno run https://deno.land/std@0.198.0/examples/welcome.ts
|
||||||
|
|
||||||
- name: Test `deno install`
|
- name: Test `deno install`
|
||||||
run: |
|
run: |
|
||||||
deno install --allow-net -n deno_curl https://deno.land/std/examples/curl.ts
|
deno install --allow-net -n deno_curl https://deno.land/std@0.198.0/examples/curl.ts
|
||||||
deno_curl https://deno.land/std/examples/curl.ts
|
deno_curl https://deno.land/std@0.198.0/examples/curl.ts
|
||||||
|
|
||||||
- name: Format
|
- name: Format
|
||||||
if: runner.os == 'Linux' && matrix.deno == 'canary'
|
if: runner.os == 'Linux' && matrix.deno == 'canary'
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ outputs:
|
|||||||
is-canary:
|
is-canary:
|
||||||
description: "If the installed Deno version was a canary version."
|
description: "If the installed Deno version was a canary version."
|
||||||
runs:
|
runs:
|
||||||
using: "node16"
|
using: "node20"
|
||||||
main: "main.js"
|
main: "main.js"
|
||||||
|
|||||||
4
node_modules/.package-lock.json
generated
vendored
4
node_modules/.package-lock.json
generated
vendored
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-deno",
|
"name": "setup-deno",
|
||||||
"version": "1.1.0",
|
"version": "1.1.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-deno",
|
"name": "setup-deno",
|
||||||
"version": "1.1.0",
|
"version": "1.1.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "setup-deno",
|
"name": "setup-deno",
|
||||||
"version": "1.1.0",
|
"version": "1.1.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-deno",
|
"name": "setup-deno",
|
||||||
"description": "Set up Deno easially in GitHub Actions",
|
"description": "Set up Deno easially in GitHub Actions",
|
||||||
"version": "1.1.2",
|
"version": "1.1.4",
|
||||||
"author": "Deno Land Inc",
|
"author": "Deno Land Inc",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ function parseVersionRange(version) {
|
|||||||
async function resolveVersion({ range, isCanary }) {
|
async function resolveVersion({ range, isCanary }) {
|
||||||
if (isCanary) {
|
if (isCanary) {
|
||||||
if (range === "latest") {
|
if (range === "latest") {
|
||||||
const res = await fetch("https://dl.deno.land/canary-latest.txt");
|
const res = await fetchWithRetries(
|
||||||
|
"https://dl.deno.land/canary-latest.txt",
|
||||||
|
);
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Failed to fetch canary version info from dl.deno.land. Please try again later.",
|
"Failed to fetch canary version info from dl.deno.land. Please try again later.",
|
||||||
@@ -60,10 +62,10 @@ async function resolveVersion({ range, isCanary }) {
|
|||||||
return { version: range, isCanary: true };
|
return { version: range, isCanary: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch("https://deno.com/versions.json");
|
const res = await fetchWithRetries("https://deno.com/versions.json");
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Failed to fetch stable version info from raw.githubusercontent.com. Please try again later.",
|
"Failed to fetch stable version info from deno.com/versions.json. Please try again later.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const versionJson = await res.json();
|
const versionJson = await res.json();
|
||||||
@@ -88,6 +90,28 @@ async function resolveVersion({ range, isCanary }) {
|
|||||||
return { version, isCanary: false };
|
return { version, isCanary: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param {string} url */
|
||||||
|
async function fetchWithRetries(url, maxRetries = 5) {
|
||||||
|
let sleepMs = 250;
|
||||||
|
let iterationCount = 0;
|
||||||
|
while (true) {
|
||||||
|
iterationCount++;
|
||||||
|
try {
|
||||||
|
const res = await fetch(url);
|
||||||
|
if (res.status === 200 || iterationCount > maxRetries) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (iterationCount > maxRetries) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.warn(`Failed fetching. Retrying in ${sleepMs}ms...`);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, sleepMs));
|
||||||
|
sleepMs = Math.min(sleepMs * 2, 10_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
parseVersionRange,
|
parseVersionRange,
|
||||||
resolveVersion,
|
resolveVersion,
|
||||||
|
|||||||
Reference in New Issue
Block a user