Skip to content

Commit

Permalink
Merge pull request #36 from viperproject/release-viper-tools
Browse files Browse the repository at this point in the history
Create Viper Tools
  • Loading branch information
aterga authored May 26, 2021
2 parents 9e0f9d6 + ae407ff commit 16cfc08
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 86 deletions.
160 changes: 158 additions & 2 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,94 @@ jobs:
path: viperserver/logs


create-viper-tools:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
needs: test
strategy:
# tests should not be stopped when they fail on one of the OSes:
fail-fast: false
matrix:
name: [latest, release]
include:
- name: latest
win-tools-url: "http://viper.ethz.ch/downloads/ViperToolsNightlyWin.zip"
linux-tools-url: "http://viper.ethz.ch/downloads/ViperToolsNightlyLinux.zip"
mac-tools-url: "http://viper.ethz.ch/downloads/ViperToolsNightlyMac.zip"
- name: release
win-tools-url: "http://viper.ethz.ch/downloads/ViperToolsLastReleaseWin.zip"
linux-tools-url: "http://viper.ethz.ch/downloads/ViperToolsLastReleaseLinux.zip"
mac-tools-url: "http://viper.ethz.ch/downloads/ViperToolsLastReleaseMac.zip"
runs-on: ubuntu-latest
steps:
- name: Install prerequisites
run: sudo apt-get install zip unzip

- name: Download ViperServer fat JAR
uses: actions/download-artifact@v2
with:
name: viperserver-${{ matrix.name }}-fat-jar

- name: Download Viper Tools for Windows
run: curl --fail --silent --show-error ${{ matrix.win-tools-url }} --output ViperToolsWin.zip
- name: Unzip Viper Tools for Windows
run: unzip ViperToolsWin.zip -d OrigViperToolsWin
- name: Download Viper Tools for Linux
run: curl --fail --silent --show-error ${{ matrix.linux-tools-url }} --output ViperToolsLinux.zip
- name: Unzip Viper Tools for Linux
run: unzip ViperToolsLinux.zip -d OrigViperToolsLinux
- name: Download Viper Tools for macOS
run: curl --fail --silent --show-error ${{ matrix.mac-tools-url }} --output ViperToolsMac.zip
- name: Unzip Viper Tools for macOS
run: unzip ViperToolsMac.zip -d OrigViperToolsMac

- name: Create a fresh Viper Tools folder per platform
run: |
mkdir -p ViperToolsWin
mkdir -p ViperToolsLinux
mkdir -p ViperToolsMac
- name: Copy boogie from OrigViperTools to ViperTools
run: |
cp -R OrigViperToolsWin/boogie ViperToolsWin/boogie/
cp -R OrigViperToolsLinux/boogie ViperToolsLinux/boogie/
cp -R OrigViperToolsMac/boogie ViperToolsMac/boogie/
- name: Copy z3 from OrigViperTools to ViperTools
run: |
cp -R OrigViperToolsWin/z3 ViperToolsWin/z3/
cp -R OrigViperToolsLinux/z3 ViperToolsLinux/z3/
cp -R OrigViperToolsMac/z3 ViperToolsMac/z3/
- name: Copy ViperServer fat JAR to ViperTools
run: |
mkdir -p ViperToolsWin/server && cp viperserver.jar ViperToolsWin/server
mkdir -p ViperToolsLinux/server && cp viperserver.jar ViperToolsLinux/server
mkdir -p ViperToolsMac/server && cp viperserver.jar ViperToolsMac/server
- name: Create folder to store all ViperTools platform zip files
run: mkdir deploy
# note that we change into the tool folder to zip it. This avoids including the parent folder in the zip
- name: Zip ViperTools for Windows
run: zip -r ../deploy/ViperToolsWin.zip ./*
working-directory: ViperToolsWin
- name: Zip ViperTools for Linux
run: zip -r ../deploy/ViperToolsLinux.zip ./*
working-directory: ViperToolsLinux
- name: Zip ViperTools for macOS
run: zip -r ../deploy/ViperToolsMac.zip ./*
working-directory: ViperToolsMac

- name: Upload ViperTools zip files
uses: actions/upload-artifact@v2
with:
name: ViperTools-${{ matrix.name }}
path: deploy


create-nightly-release:
# this job creates a new nightly pre-release, set viperserver.jar as artifacts, and deletes old releases
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly') || github.event_name == 'schedule'
needs: test
needs: create-viper-tools
runs-on: ubuntu-latest
env:
# specifies that `latest` artifacts from `build` job should be used for nightly releases:
Expand All @@ -280,6 +364,12 @@ jobs:
name: viperserver-${{ env.NAME }}-fat-jar
path: deploy

- name: Download ViperTools
uses: actions/download-artifact@v2
with:
name: ViperTools-${{ env.NAME }}
path: deploy

- name: Download version file
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -321,11 +411,41 @@ jobs:
asset_name: viperserver.jar
asset_content_type: application/octet-stream

- name: Upload ViperTools for Windows
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsWin.zip
asset_name: ViperToolsWin.zip
asset_content_type: application/zip

- name: Upload ViperTools for Ubuntu
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsLinux.zip
asset_name: ViperToolsLinux.zip
asset_content_type: application/zip

- name: Upload ViperTools for macOS
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsMac.zip
asset_name: ViperToolsMac.zip
asset_content_type: application/zip


create-stable-release:
# this job creates a stable draft-release and set viperserver.jar as artifacts
if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'stable'
needs: test
needs: create-viper-tools
runs-on: ubuntu-latest
env:
# specifies that `release` artifacts from `build` job should be used for stable releases:
Expand All @@ -343,6 +463,12 @@ jobs:
name: viperserver-${{ env.NAME }}-fat-jar
path: deploy

- name: Download ViperTools
uses: actions/download-artifact@v2
with:
name: ViperTools-${{ env.NAME }}
path: deploy

- name: Download version file
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -380,3 +506,33 @@ jobs:
asset_path: deploy/viperserver.jar
asset_name: viperserver.jar
asset_content_type: application/octet-stream

- name: Upload ViperTools for Windows
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsWin.zip
asset_name: ViperToolsWin.zip
asset_content_type: application/zip

- name: Upload ViperTools for Ubuntu
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsLinux.zip
asset_name: ViperToolsLinux.zip
asset_content_type: application/zip

- name: Upload ViperTools for macOS
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/ViperToolsMac.zip
asset_name: ViperToolsMac.zip
asset_content_type: application/zip
50 changes: 0 additions & 50 deletions src/main/scala/viper/server/LanguageServerRunner.scala

This file was deleted.

49 changes: 46 additions & 3 deletions src/main/scala/viper/server/ViperConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ package viper.server

import java.io.File

import org.rogach.scallop.{ScallopConf, ScallopOption, singleArgConverter}
import org.rogach.scallop.{ScallopConf, ScallopOption, numberHandler, singleArgConverter}
import viper.server.core.DefaultVerificationExecutionContext
import viper.server.utility.Helpers.{canonizedFile, validatePath}
import viper.server.utility.ibm

Expand Down Expand Up @@ -52,17 +53,34 @@ class ViperConfig(args: Seq[String]) extends ScallopConf(args) {
hidden = false
)

val SERVER_MODE_LSP = "LSP"
val SERVER_MODE_HTTP = "HTTP"
private val server_modes = Array(SERVER_MODE_LSP, SERVER_MODE_HTTP)

val serverMode: ScallopOption[String] = opt[String]("serverMode",
descr = s"One of the supported protocols: ${server_modes.mkString(",")}.",
default = Some(SERVER_MODE_HTTP),
validate = (ll: String) => server_modes.contains(ll.toUpperCase),
noshort = true,
hidden = false
)(singleArgConverter(level => level.toUpperCase))

val port: ScallopOption[Int] = opt[Int]("port", 'p',
descr = ("Specifies the port on which ViperServer will be started."
+ s"The port must be an integer in range [${ibm.Socket.MIN_PORT_NUMBER}-${ibm.Socket.MAX_PORT_NUMBER}]"
+ "If the option is omitted, an available port will be selected automatically."),
validate = p => try {
ibm.Socket.available(p)
if (p != 0) {
ibm.Socket.available(p)
} else {
true
}
} catch {
case e: Exception =>
println(s"Invalid port $p: $e")
false
},
default = Some(0),
noshort = false,
hidden = false)

Expand All @@ -83,4 +101,29 @@ class ViperConfig(args: Seq[String]) extends ScallopConf(args) {
noshort = false,
hidden = false
)
}

val nThreads: ScallopOption[Int] = opt[Int](
name = "nThreads",
descr = s"Maximal number of threads that should be used (not taking threads used by backend into account)\n" +
s"Values below ${DefaultVerificationExecutionContext.minNumberOfThreads} (the minimum) will be set to the minimum.\n" +
s"The default value is the maximum of ${DefaultVerificationExecutionContext.minNumberOfThreads} and the number of available processors",
default = Some(Math.max(DefaultVerificationExecutionContext.minNumberOfThreads, Runtime.getRuntime.availableProcessors())),
noshort = true
)(singleArgConverter(input => {
// parse option as int and check bounds
val n = input.toInt
n match {
case n if n < DefaultVerificationExecutionContext.minNumberOfThreads => DefaultVerificationExecutionContext.minNumberOfThreads
case n => n
}
}, numberHandler("Int")))

/**
* Exception handling
*/
/**
* Epilogue
*/

verify()
}
Loading

0 comments on commit 16cfc08

Please sign in to comment.