Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
refactor and bump to v1.1.0 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan authored and axetroy committed Nov 27, 2019
1 parent ed96cbd commit 27f6ba5
Show file tree
Hide file tree
Showing 195 changed files with 11,018 additions and 14,964 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/workflow.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Main workflow
on: [push]
name: ci
on: [push, pull_request]
jobs:
run:
name: Run on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@master

Expand All @@ -19,15 +19,15 @@ jobs:
run: npm install

- name: Lint
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: npm run format-check

- name: Set up deno v0.18.0
- name: Test
run: npm test

- name: Set up Deno
uses: ./
with:
deno-version: v0.18.0

- name: Run deno
run: |
which deno
deno https://deno.land/welcome.ts
deno --version
deno run https://deno.land/std/examples/welcome.ts
95 changes: 95 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Ignore node_modules, ncc is used to compile nodejs modules into a single file in the releases branch
node_modules/
__tests__/runner/*

# Ignore js files that are transpiled from ts files in src/
lib/

# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"proseWrap": "always"
}
40 changes: 20 additions & 20 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 The Deno Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
The MIT License (MIT)
Copyright (c) 2019 The Deno Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
101 changes: 52 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
# setup-deno

<p align="left">
<a href="https://github.com/denolib/setup-deno"><img alt="GitHub Actions status" src="https://github.com/denolib/setup-deno/workflows/Main%20workflow/badge.svg"></a>
</p>

This action sets up deno environment for use in actions by:

- optionally downloading and caching a version of deno - versioned and add to PATH

# Usage

See [action.yml](action.yml)

Basic:
```yaml
steps:
- uses: actions/checkout@master
- uses: denolib/setup-deno@v1
with:
deno-version: 'v0.18.0'
- run: deno https://deno.land/welcome.ts
```
Matrix Testing:
```yaml
jobs:
build:
runs-on: ubuntu-16.04
strategy:
matrix:
deno: [ 'v0.18.0', 'v0.17.0' ]
name: Deno ${{ matrix.deno }} sample
steps:
- uses: actions/checkout@master
- name: Setup deno
uses: denolib/setup-deno@v1
with:
deno-version: ${{ matrix.deno }}
- run: deno https://deno.land/welcome.ts
```
# License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
# Contributions
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
# setup-deno

[![GitHub Actions status](https://github.com/denolib/setup-deno/workflows/ci/badge.svg?branch=master)](https://github.com/denolib/setup-deno/actions)

This action sets up deno environment for use in actions by:

- optionally downloading and caching a version of deno - versioned and add to
PATH
- registering problem matchers for error output

# Usage

See [action.yml](action.yml)

Basic:

```yaml
steps:
- uses: actions/checkout@master
- uses: denolib/setup-deno@v1.1.0
with:
deno-version: 0.x
- run: deno run https://deno.land/std/examples/welcome.ts
```
Matrix Testing:
```yaml
jobs:
build:
runs-on: ubuntu-16.04
strategy:
matrix:
deno: [0.24.0, 0.23.0]
name: Deno ${{ matrix.deno }} sample
steps:
- uses: actions/checkout@master
- name: Setup Deno
uses: denolib/setup-deno@v1.1.0
with:
deno-version: ${{ matrix.deno }}
- run: deno run https://deno.land/std/examples/welcome.ts
```
# License
The scripts and documentation in this project are released under the
[MIT License](LICENSE)
# Contributions
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
100 changes: 100 additions & 0 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import * as io from "@actions/io";
import * as path from "path";
import * as fs from "fs";
import * as os from "os";

const toolDir = path.join(
__dirname,
"runner",
path.join(
Math.random()
.toString(36)
.substring(7)
),
"tools"
);
const tempDir = path.join(
__dirname,
"runner",
path.join(
Math.random()
.toString(36)
.substring(7)
),
"temp"
);

process.env["RUNNER_TOOL_CACHE"] = toolDir;
process.env["RUNNER_TEMP"] = tempDir;
import * as installer from "../src/installer";

const EXTENSION = process.platform == "win32" ? ".exe" : "";

describe("installer tests", () => {
beforeAll(async () => {
await io.rmRF(toolDir);
await io.rmRF(tempDir);
}, 100000);

it("Acquires version of deno if no matching version is installed", async () => {
await installer.getDeno("0.20.0");
const denoDir = path.join(toolDir, "deno", "0.20.0", os.arch());
console.log(`${denoDir}.complete`);
expect(fs.existsSync(`${denoDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(denoDir, `deno${EXTENSION}`))).toBe(true);
}, 100000);

it("Throws if no location contains correct deno version", async () => {
let thrown = false;
try {
await installer.getDeno("1000");
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});

it("Acquires version of deno with uncleaned version", async () => {
await installer.getDeno("v0.21.0");
const denoDir = path.join(toolDir, "deno", "0.21.0", os.arch());

expect(fs.existsSync(`${denoDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(denoDir, `deno${EXTENSION}`))).toBe(true);
}, 100000);

it("Uses version of deno installed in cache", async () => {
const denoDir = path.join(toolDir, "deno", "250.0.0", os.arch());
await io.mkdirP(denoDir);
fs.writeFileSync(`${denoDir}.complete`, "hello");
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getDeno("250.0.0");
return;
});

it("Doesnt use version of deno that was only partially installed in cache", async () => {
const denoDir: string = path.join(toolDir, "deno", "251.0.0", os.arch());
await io.mkdirP(denoDir);
let thrown = false;
try {
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getDeno("251.0.0");
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});

it("Resolves semantic versions of deno installed in cache", async () => {
const deno: string = path.join(toolDir, "deno", "252.0.0", os.arch());
await io.mkdirP(deno);
fs.writeFileSync(`${deno}.complete`, "hello");
// These will throw if it doesn't find it in the cache (because no such version exists)
await installer.getDeno("v252.0.0");
await installer.getDeno("252.0.0");
await installer.getDeno("v252.0.x");
await installer.getDeno("252.0.x");
await installer.getDeno("v252.0");
await installer.getDeno("252.0");
});
});
Loading

0 comments on commit 27f6ba5

Please sign in to comment.