Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Checkout v from master (#15)
Browse files Browse the repository at this point in the history
* Just download the zip of Master branch if v_version is equal to master.

* WORKFLOW_COMMIT - update dist/index.js [skip ci]

* Try to build using make bash command

* Add test for master build

* Change subpath if master

* Update README.md

Co-authored-by: alexesprit <alex.esprit@gmail.com>
  • Loading branch information
shiipou and alexesprit authored Apr 18, 2020
1 parent c1317f1 commit 3c43c7f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/test_github_action_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test Latest

on:
push:
paths:
- 'dist/**.js'
pull_request:
paths:
- 'dist/**.js'

jobs:
test-ubuntu:
name: Test with ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up V version latest
uses: ./
with:
v-version: latest
id: v

- name: Test V is present
run: v version

test-macos:
name: Test on MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up V version latest
uses: ./
with:
v-version: latest
id: v

- name: Test V is present
run: v version

test-windows:
name: Test on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up V version latest
uses: ./
with:
v-version: latest
id: v

- name: Test V is present
run: v version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Test Master

on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Set up V version master
uses: ./
with:
v-version: latest
v-version: master
id: v

- name: Test V is present
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Set up V version master
uses: ./
with:
v-version: latest
v-version: master
id: v

- name: Test V is present
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Set up V version master
uses: ./
with:
v-version: latest
v-version: master
id: v

- name: Test V is present
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
## Inputs
- `v-version`: V version. Can be either exact version number, or `latest` (by default).
- `v-version`: V version. Can be either exact version number, `latest` (by default), or `master` (use the master branch instead of release).
13 changes: 12 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

module.exports =
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
Expand Down Expand Up @@ -4649,7 +4650,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const tc = __importStar(__webpack_require__(533));
const path = __importStar(__webpack_require__(622));
const sys = __importStar(__webpack_require__(913));
const child_process_1 = __webpack_require__(129);
function download_v(v_version) {
return __awaiter(this, void 0, void 0, function* () {
let download_path;
Expand All @@ -4660,6 +4663,9 @@ function download_v(v_version) {
let download_url = `https://github.com/vlang/v/releases/`;
if (v_version.includes('latest'))
download_url += `${v_version}/download/v_${sys.getPlatform()}.zip`;
else if (v_version.includes('master')) {
download_url = `https://github.com/vlang/v/archive/master.zip`;
}
else
download_url += `download/${v_version}/v_${sys.getPlatform()}.zip`;
console.log(`Downloading V from ${download_url}`);
Expand All @@ -4674,6 +4680,11 @@ function download_v(v_version) {
console.log('Extracting V...');
ext_path = yield tc.extractZip(download_path, './.vlang_tmp_build');
console.log(`V extracted to ${ext_path}`);
if (v_version.includes('master')) {
console.log(`Building V from sources`);
ext_path = path.join(ext_path, 'v-master/');
console.log(child_process_1.execSync(`make`, { cwd: ext_path }).toString());
}
// extracts with a root folder that matches the fileName downloaded
console.log(`Add V to cache`);
cache_path = yield tc.cacheDir(ext_path, 'v', v_version);
Expand Down Expand Up @@ -4876,4 +4887,4 @@ exports.exec = exec;

/***/ })

/******/ });
/******/ });
11 changes: 10 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'path';
import * as httpm from '@actions/http-client';
import * as sys from './system';
import {debug} from '@actions/core';
import {execSync} from 'child_process';

export async function download_v(v_version: string): Promise<string | undefined> {
let download_path: string | undefined;
Expand All @@ -14,7 +15,9 @@ export async function download_v(v_version: string): Promise<string | undefined>
let download_url: string = `https://github.com/vlang/v/releases/`
if(v_version.includes('latest'))
download_url+= `${v_version}/download/v_${sys.getPlatform()}.zip`
else
else if(v_version.includes('master')){
download_url = `https://github.com/vlang/v/archive/master.zip`
}else
download_url+= `download/${v_version}/v_${sys.getPlatform()}.zip`

console.log(`Downloading V from ${download_url}`);
Expand All @@ -31,6 +34,12 @@ export async function download_v(v_version: string): Promise<string | undefined>
ext_path = await tc.extractZip(download_path, './.vlang_tmp_build');
console.log(`V extracted to ${ext_path}`);

if(v_version.includes('master')) {
console.log(`Building V from sources`);
ext_path = path.join(ext_path, 'v-master/');
console.log(execSync(`make`, { cwd: ext_path }).toString());
}

// extracts with a root folder that matches the fileName downloaded
console.log(`Add V to cache`);
cache_path = await tc.cacheDir(ext_path, 'v', v_version);
Expand Down

0 comments on commit 3c43c7f

Please sign in to comment.