Skip to content

Commit

Permalink
Merge pull request #123 from lf-lang/update-error-message
Browse files Browse the repository at this point in the history
Update message for missing dependencies
  • Loading branch information
petervdonovan committed Jul 24, 2023
2 parents 5682c9f + f9d2b61 commit 1f33508
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 44 deletions.
15 changes: 0 additions & 15 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,3 @@ runs:
- name: Install pylint
run: python3 -m pip install pylint
shell: bash
- name: Install pnpm
run: npm i -g pnpm
shell: bash
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: ${{ matrix.rust }}
components: clippy
- name: Install RTI
run: |
cd lingua-franca
.github/actions/install-rti/install.sh
cd ..
shell: bash
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on:
workflow_call:
inputs:
partial:
required: false
default: true
type: boolean

jobs:
build:
steps:
- name: Check out vscode-lingua-franca repository
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 1
- name: Set up Java 17
run: |
echo "$JAVA_HOME_17_X64/bin" >> $GITHUB_PATH
echo "org.gradle.java.home=${JAVA_HOME_17_X64//\\/\/}" >> gradle.properties
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
shell: bash
- name: Check settings
run: |
echo $(which java)
cat gradle.properties
echo $JAVA_HOME
shell: bash
- name: Build the VS Code extension
run: npm install --ignore-scripts
shell: bash
- name: Install pylint
run: python3 -m pip install pylint
shell: bash
- name: Install pnpm
run: npm i -g pnpm
shell: bash
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable
components: clippy
- name: Install RTI
run: |
cd lingua-franca
.github/actions/install-rti/install.sh
cd ..
shell: bash
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
32 changes: 15 additions & 17 deletions .github/workflows/dependency-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,27 @@ on:
branches:
- main
paths:
- '**/check_dependencies.ts'
- '**/version_checker.ts'
- '**/version.ts'
- "**/check_dependencies.ts"
- "**/version_checker.ts"
- "**/version.ts"
# Trigger this workflow also on pull_request events.
pull_request:
paths:
- '**/check_dependencies.ts'
- '**/version_checker.ts'
- '**/version.ts'
- "**/check_dependencies.ts"
- "**/version_checker.ts"
- "**/version.ts"

jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
rust: [nightly]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@main
test-dependencies-outdated:
strategy:
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@main
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@update-error-message
- name: Uninstall dependencies
run: |
python3 -m pip uninstall -y pylint
- name: Downgrade dependencies
run: |
pip install -I pylint==2.10.0
Expand All @@ -49,7 +44,10 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@main
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@update-error-message
- name: Uninstall dependencies
run: |
python3 -m pip uninstall -y pylint
- name: Run tests (Linux)
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test-dependencies-missing-extended
if: ${{ runner.os == 'Linux' }}
Expand All @@ -62,7 +60,7 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@main
- uses: lf-lang/vscode-lingua-franca/.github/actions/build@update-error-message
- name: Run tests (Linux)
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test-dependencies-missing-basic
if: ${{ runner.os == 'Linux' }}
Expand Down
8 changes: 5 additions & 3 deletions src/check_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ export const watcherConfig: CheckSet[] = [
},
];

export const caveat = 'If this dependency is already on your system, start VS Code from a terminal emulator so that VS Code sees the same value of your PATH that you see in your terminal.'

/**
* Return a dependency checker that returns whether the given dependency is satisfied and, as a side
* effect, warns the user if not.
Expand All @@ -277,10 +279,10 @@ const checkDependency: UserFacingVersionCheckerMaker = (dependency: DependencyIn
(MessageDisplayHelper: MessageDisplayHelper) => async () => {
const checkerResult: versionChecker.VersionCheckResult = await dependency.checker();
if (checkerResult.isCorrect) return true;
const message: string = await (checkerResult.isCorrect === false ? (
const message: string = (await (checkerResult.isCorrect === false ? (
dependency.wrongVersionMessage?.(checkerResult)
?? dependency.message(checkerResult)
) : dependency.message(checkerResult));
) : dependency.message(checkerResult))) + ' ' + caveat;
const installCommand: InstallCommand = await dependency.installCommand?.(checkerResult);
if (!installCommand && !dependency.installLink) {
MessageDisplayHelper(message);
Expand Down Expand Up @@ -320,7 +322,7 @@ export const checkerFor: CheckerGetter = (name: Dependency) => {
};

const doDependencyCheck = (document: vscode.TextDocument) => {
if (document.languageId != "lflang") return;
if (document.languageId != 'lflang') return;
for (const checkSet of watcherConfig.filter(it => it.regexp.test(document.getText()))) {
for (const check of checkSet.checks.filter(
it => !it.alreadyChecked || (it.isEssential && !it.satisfied))
Expand Down
16 changes: 8 additions & 8 deletions src/test/check_dependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as vscode from 'vscode';
import chai from 'chai';
import spies from 'chai-spies';
import { expect } from 'chai';
import { after, Context } from 'mocha';
import { after } from 'mocha';
import { MessageDisplayHelper } from '../utils';
import * as http from 'http';
import * as url from 'url';
Expand Down Expand Up @@ -60,7 +60,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing0:
await expectFailure(dependency, spy);
expect(spy).to.have.been.called.with(depMissingMessage);
expect(spy).to.have.been.called.with(depMissingMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
this.test.skip();
Expand Down Expand Up @@ -96,7 +96,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing1:
await expectFailure(Dependency.Pylint, spy);
expect(spy).to.have.been.called.with(checkDependencies.pylintMessage);
expect(spy).to.have.been.called.with(checkDependencies.pylintMessage + " " + checkDependencies.caveat);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pylint, spy);
break;
Expand All @@ -105,7 +105,7 @@ suite('test dependency checking', () => {
expect(spy).to.have.been.called.with(
`The Lingua Franca language server is tested with Pylint version `
+ `${config.pylintVersion.major}.${config.pylintVersion.minor} and newer, but `
+ `the version detected on your system is 2.10.0.`
+ `the version detected on your system is 2.10.0. ${checkDependencies.caveat}`
);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pylint, spy);
Expand All @@ -126,13 +126,13 @@ suite('test dependency checking', () => {
break;
case DependencyStatus.Missing0:
await expectFailure(Dependency.Pnpm, spy);
expect(spy).to.have.been.called.with(checkDependencies.pnpmMessage);
expect(spy).to.have.been.called.with(checkDependencies.pnpmMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
await expectFailure(Dependency.Pnpm, spy);
expect(spy).to.have.been.called.with(
'To prevent an accumulation of replicated dependencies when compiling LF programs '
+ 'with the TypeScript target, it is highly recommended to install pnpm globally.'
+ 'with the TypeScript target, it is highly recommended to install pnpm globally.' + " " + checkDependencies.caveat
);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pnpm, spy);
Expand All @@ -158,7 +158,7 @@ suite('test dependency checking', () => {
break;
case DependencyStatus.Missing0:
await expectFailure(Dependency.Rust, spy);
expect(spy).to.have.been.called.with(checkDependencies.rustMessage);
expect(spy).to.have.been.called.with(checkDependencies.rustMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
this.test.skip();
Expand All @@ -180,7 +180,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing1:
await expectFailure(Dependency.Rti, spy);
expect(spy).to.have.been.called.with(checkDependencies.rtiMessage);
expect(spy).to.have.been.called.with(checkDependencies.rtiMessage + " " + checkDependencies.caveat);
break;
default:
throw new Error('unreachable');
Expand Down
2 changes: 1 addition & 1 deletion src/version_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const rtiVersionChecker = async () => {
// TODO: Update when #76 is addressed: https://github.com/lf-lang/reactor-c/issues/76
let exists: boolean;
try {
exists = (await which("RTI")).length > 0;
exists = (await which('RTI')).length > 0;
} catch (e) {
return { version: new Version('0.0.0'), isCorrect: null };
}
Expand Down

0 comments on commit 1f33508

Please sign in to comment.