Skip to content

Commit

Permalink
Merge pull request #3 from ayys/main
Browse files Browse the repository at this point in the history
Adds version input to the action
  • Loading branch information
ayys authored Nov 15, 2022
2 parents 178bc54 + 390bcef commit d0a9bba
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 23 deletions.
52 changes: 50 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,55 @@ jobs:
# Verify Wasmer runs
- name: Verify Wasmer runs
run: |
wapm config set registry.url "https://registry.wapm.io"
mkdir test-dir
cd test-dir
wapm install robert/echo
wasmer run -- ./wapm_packages/robert/echo\@0.1.5/echo.wasm "${{ env.ECHO_STRING }}" > output.txt
grep "${{ env.ECHO_STRING }}" output.txt
test-versions:
name: Test version on ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
# Checkout source code
- name: Checkout source code
uses: actions/checkout@v2

# Setup Wasmer
- name: Setup Wasmer
uses: ./
with:
version: "v3.0.0-rc.2"

# Verify Wasmer is installed
- name: Verify Wasmer is installed
shell: pwsh
run: |
Get-Command wasmer
Get-Command wapm
Get-Command wax
# Verify Wasmer version is correct
- name: Verify Wasmer version is correct
uses: MeilCli/[email protected]
with:
command: wapm execute echo ${{ env.ECHO_STRING }}
expect_contain: ${{ env.ECHO_STRING }}
command: wasmer --version
expect_contain: "wasmer 3.0.0-rc.2"

# Verify Wasmer runs
- name: Verify Wasmer runs
run: |
wapm config set registry.url "https://registry.wapm.io"
mkdir test-dir
cd test-dir
wapm install robert/echo
wasmer run -- ./wapm_packages/robert/echo\@0.1.5/echo.wasm "${{ env.ECHO_STRING }}" > output.txt
grep "${{ env.ECHO_STRING }}" output.txt
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ branding:
icon: package
runs:
using: node12
main: dist/index.js
main: dist/index.js

inputs:
version:
default: ''
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "GitHub action for setting up Wasmer",
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.ts --minify --license license.txt"
"build": "tsc && ncc build src/index.ts --minify --license LICENSE"
},
"repository": {
"type": "git",
Expand All @@ -24,11 +24,13 @@
"temp": "^0.9.4"
},
"devDependencies": {
"ts-node-dev": "^2.0.0",
"@types/temp": "^0.9.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"@vercel/ncc": "^0.28.6",
"@vercel/ncc": "^0.34.0",
"eslint": "^7.28.0",
"typescript": "^4.3.2"
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
}
}
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//Imports
import got from 'got';
import {addPath, debug, endGroup, exportVariable, info, setFailed, startGroup} from '@actions/core';
import {getInput, addPath, debug, endGroup, exportVariable, info, setFailed, startGroup} from '@actions/core';
import {createWriteStream} from 'fs';
import {exec} from '@actions/exec';
import {homedir} from 'os';
Expand All @@ -19,6 +19,7 @@ const pipeline = promisify(pipelineCB);
const main = async () =>
{
//Get if the host is Windows or not
const version = getInput("version");
const isWindows = process.platform == 'win32';

//Create a temporary file to store the installer
Expand Down Expand Up @@ -49,12 +50,13 @@ const main = async () =>
endGroup();

info('Downloaded installer.');
const exec_input = version.length == 0 ? [tmp] : [tmp, version];
const exec_shell = isWindows ? 'pwsh' : 'sh';
info(`${exec_shell} ${exec_input} -- install for version ${version}`);

//Execute the installer
startGroup('Execute the installer.');
const exitCode = await exec(isWindows ? 'pwsh' : 'sh', [
tmp
]);
const exitCode = await exec(exec_shell, exec_input);

if (exitCode != 0)
{
Expand Down
24 changes: 12 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules"
]
}
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"lib": ["esnext"]
},
"exclude": ["node_modules"]
}

0 comments on commit d0a9bba

Please sign in to comment.