Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 8977638

Browse files
committed
feat: init
0 parents  commit 8977638

File tree

10 files changed

+307
-0
lines changed

10 files changed

+307
-0
lines changed

.github/workflows/test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Test the action
2+
3+
on:
4+
push: { branches: [main] }
5+
pull_request: { branches: [main] }
6+
workflow_dispatch:
7+
8+
jobs:
9+
basic:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
15+
name: Test basic usage on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Use basic action
23+
uses: ./
24+
25+
- name: Test basic usage
26+
shell: bash
27+
run: deno run -A ./test/basic/main.ts
28+
29+
customized:
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
os: [ubuntu-latest, macos-latest, windows-latest]
34+
35+
name: Test customized usage on ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}
37+
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Test action
43+
uses: ./
44+
with:
45+
deno-version: 1.x
46+
deno-lock-path: "test/customized/deno.lock"
47+
deno-json-path: "test/customized/deno.json"
48+
scripts-dir: "test/customized/"
49+
50+
- name: Test customized usage
51+
shell: bash
52+
run: deno run -A --config ./test/customized/deno.json ./test/customized/main.ts

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"deno.enable": true
3+
}

action.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Setup Deno with cache"
2+
3+
description: "Composite action wrapper around denoland/setup-deno and actions/cache to setup Deno and cache its dependencies."
4+
5+
inputs:
6+
deno-version:
7+
description: "The Deno version to install. Can be a semver version of a stable release, 'canary' for the latest canary, or the Git hash of a specific canary release."
8+
default: "1.x"
9+
deno-json-path:
10+
description: "The path to the Deno config file to use for caching. Defaults to an empty string, using the built-in CLI default."
11+
default: ""
12+
deno-lock-path:
13+
description: "The path to the lock file to use for caching. Defaults to `./deno.lock`."
14+
default: "./deno.lock"
15+
scripts-dir:
16+
description: "The path to the scripts to cache. Defaults to the repo root (`.`)."
17+
default: "."
18+
19+
outputs:
20+
deno-version:
21+
description: "The Deno version that was installed."
22+
value: ${{ steps.setup-deno.outputs.deno-version }}
23+
is-canary:
24+
description: "If the installed Deno version was a canary version."
25+
value: ${{ steps.setup-deno.outputs.is-canary }}
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- name: Setup Deno
31+
id: setup-deno
32+
uses: denoland/setup-deno@v1
33+
with:
34+
deno-version: ${{ inputs.deno-version }}
35+
36+
- name: Set Deno cache dir
37+
shell: bash
38+
run: echo "DENO_DIR=${{ runner.os == 'Windows' && 'C:\\deno_cache' || '/tmp/deno_cache' }}" >> $GITHUB_ENV
39+
40+
- name: Cache Deno dependencies
41+
uses: actions/cache@v3
42+
with:
43+
key: ${{ hashFiles(inputs.deno-lock-path) }}
44+
path: ${{ env.DENO_DIR }}
45+
46+
- name: Install GNU findutils
47+
if: runner.os == 'macOS'
48+
shell: bash
49+
run: brew install findutils
50+
51+
- name: Restore Deno dependencies
52+
shell: bash
53+
run: |
54+
export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
55+
find ${{ inputs.scripts-path }} \
56+
-regex '.+\.[tj]sx?$' \
57+
-exec deno cache {} ${{ inputs.deno-config-path != '' && '--config=' || '' }}${{ inputs.deno-config-path }} \;

deno.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"imports": {
3+
"std/": "https://deno.land/std@0.207.0/",
4+
"cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/"
5+
}
6+
}

deno.lock

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shell.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{ pkgs ? import <nixpkgs> {}}:
2+
pkgs.mkShell {
3+
packages = with pkgs; [act deno];
4+
}

test/basic/main.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env -S deno run -A
2+
// just get any stdlib for the cache test
3+
import { red, yellow, green, cyan, magenta } from "std/fmt/colors.ts";
4+
5+
const helloWorld = [
6+
red("He"),
7+
yellow("llo"),
8+
" ",
9+
green("Wo"),
10+
cyan("rl"),
11+
magenta("d!"),
12+
].join("");
13+
14+
console.log(helloWorld);

test/customized/deno.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"imports": {
3+
"std/": "https://deno.land/std@0.207.0/",
4+
"cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/"
5+
},
6+
"lock": "./deno.lock"
7+
}

0 commit comments

Comments
 (0)