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

Commit

Permalink
Add more test (#28)
Browse files Browse the repository at this point in the history
* Add more test

This allow to test `v fmt` and `v build`

* Change the path constraint

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

* Update test_github_action.yml

Co-authored-by: BOT_WORKFLOW <bot@nocturlab.fr>
  • Loading branch information
shiipou and BOT_WORKFLOW authored Aug 16, 2020
1 parent 7939e5a commit 83742e7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 16 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build_github_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
paths-ignore:
- '**.md'
- 'dist/**.js'
- .github/workflows/test_github_action.yml
pull_request:
paths-ignore:
- '**.md'
- 'dist/**.js'
- .github/workflows/test_github_action.yml

jobs:
build:
Expand All @@ -35,12 +37,12 @@ jobs:
- name: npm build
run: npm run build

- name: git push dist/
- name: git push dist
run : |
echo "${GITHUB_REF#refs/heads/}"
git config --global user.email "bot@nocturlab.fr"
git config --global user.name "BOT_WORKFLOW"
git remote set-url origin https://shiipou:${{ secrets.GITHUB_TOKEN }}@github.com/nocturlab/setup-vlang-action.git
git add dist
git commit -m "WORKFLOW_COMMIT - update dist/index.js [skip ci]"
git add dist -f
git commit -m "WORKFLOW_COMMIT - update dist/index.js"
git push
continue-on-error: true
25 changes: 18 additions & 7 deletions .github/workflows/test_github_action.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
name: Tests

on:
push:
paths:
- 'dist/**.js'
pull_request:
paths:
- 'dist/**.js'
paths:
- dist/
- .github/workflows/test_github_action.yml
schedule:
- cron: '0 8 * * *'

jobs:
test-ubuntu:
name: Run tests on ${{ matrix.os }} ${{ matrix.v-version }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
v-version: [latest, master, 0.1.27]
v-version: [latest, master, 0.1.29]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -26,6 +25,18 @@ jobs:
with:
v-version: ${{ matrix.v-version }}
id: v

- name: Test V is present
run: v version

- name: Test V fmt
run: v fmt word_counter.v
working-directory: ${{ steps.v.outputs.v_home }}/examples/word_counter

- name: Test V can compile something
run: v word_counter.v
working-directory: ${{ steps.v.outputs.v_home }}/examples/word_counter

- name: Test compiled program
run: ./word_counter cinderella.txt
working-directory: ${{ steps.v.outputs.v_home }}/examples/word_counter
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
v-version:
description: 'The V version to download and use.'
default: 'latest'
output:
v_home:
description: 'The path where V is located.'
runs:
using: 'node12'
main: 'dist/index.js'
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2885,7 +2885,7 @@ function run() {
let v_version = core.getInput('v-version');
console.log(`Setup V with version ${v_version}`);
if (v_version) {
let cache_dir = tc.find('v', v_version);
let cache_dir = tc.find('nocturlab/setup-vlang-action', v_version);
let install_dir;
if (!cache_dir) {
console.log(`V ${v_version} can't be found using cache, attempting to download ...`);
Expand All @@ -2894,6 +2894,7 @@ function run() {
}
if (install_dir) {
core.exportVariable('V_HOME', install_dir);
core.setOutput('v_home', install_dir);
core.addPath(install_dir);
console.log('Added V to the path');
}
Expand Down Expand Up @@ -4715,9 +4716,12 @@ function download_v(v_version) {
ext_path = path.join(ext_path, 'v-master/');
console.log(child_process_1.execSync(`make`, { cwd: ext_path }).toString());
}
else {
ext_path = path.join(ext_path, 'v/');
}
// 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);
cache_path = yield tc.cacheDir(ext_path, 'nocturlab/setup-vlang-action', v_version);
console.log(`V was added to cache using dir: ${cache_path}`);
}
catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-vlang-action",
"version": "1.1.1",
"version": "1.1.2",
"private": true,
"description": "setup vlang action",
"main": "src/index.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function run() {
console.log(`Setup V with version ${v_version}`);

if (v_version) {
let cache_dir: string | undefined = tc.find('v', v_version);
let cache_dir: string | undefined = tc.find('nocturlab/setup-vlang-action', v_version);
let install_dir: string | undefined;

if (!cache_dir) {
Expand All @@ -24,6 +24,7 @@ export async function run() {

if (install_dir) {
core.exportVariable('V_HOME', install_dir);
core.setOutput('v_home', install_dir);
core.addPath(install_dir);
console.log('Added V to the path');
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export async function download_v(v_version: string): Promise<string | undefined>
console.log(`Building V from sources`);
ext_path = path.join(ext_path, 'v-master/');
console.log(execSync(`make`, { cwd: ext_path }).toString());
}else{
ext_path = path.join(ext_path, 'v/');
}

// 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);
cache_path = await tc.cacheDir(ext_path, 'nocturlab/setup-vlang-action', v_version);
console.log(`V was added to cache using dir: ${cache_path}`);
} catch (error) {
throw new Error(`Failed to extract V version ${v_version}: ${error}`);
Expand Down

0 comments on commit 83742e7

Please sign in to comment.