Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: upload client with bundled server as artifact #169

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/unified-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CN LSP CI

on:
push:
branches:
- main
pull_request:
branches:
- main

# Cancel in-progress job when a new push is performed
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
node-version: [21.7.3]
ocaml-version: [5.1.1]
os: [ubuntu-22.04, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Check out repository
uses: actions/checkout@v4

# Build server

- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Install dependencies
run: opam install . --deps-only --locked -y

- name: Build
run: eval $(opam env) && dune build

- name: Run tests
run: eval $(opam env) && dune test

# Build client

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install client dependencies
working-directory: ./cn-client
run: npm install

- name: Build client
working-directory: ./cn-client
run: npm run compile

# Distribute client

- name: Install server
run: eval $(opam env) && dune install

- name: Compile client .vsix
working-directory: ./cn-client
run: |
cp ../_opam/bin/cn-lsp-server cn-lsp-server
cp -r ../_opam/lib/cerberus/runtime cerb-runtime
npm run dist

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: cn-client-${{ matrix.os }}
# This will only match one file
path: cn-client/cn-client-*.vsix
2 changes: 2 additions & 0 deletions cn-client/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
!package-lock.json
!package.json
!README.md
!cn-lsp-server
!cerb-runtime
4 changes: 2 additions & 2 deletions cn-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cn-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/GaloisInc/VERSE-Toolchain",
"type": "git"
},
"version": "0.0.5",
"version": "0.1.0",
"engines": {
"vscode": "^1.75.0"
},
Expand Down
22 changes: 18 additions & 4 deletions cn-client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let client: ct.LanguageClient;
type Maybe<T> = T | undefined;

export async function activate(context: vsc.ExtensionContext): Promise<void> {
let serverContext = getConfiguredServerContext();
let serverContext = getConfiguredServerContext(context);

if (serverContext === undefined) {
serverContext = await newServerContext(context);
Expand Down Expand Up @@ -185,7 +185,7 @@ async function newServerContext(
return undefined;
}

function getConfiguredServerContext(): Maybe<ServerContext> {
function getConfiguredServerContext(context: vsc.ExtensionContext): Maybe<ServerContext> {
let conf = vsc.workspace.getConfiguration("CN");
let serverPath: Maybe<string> = conf.get("serverPath");
let cerbRuntime: Maybe<string> = conf.get("cerbRuntime");
Expand All @@ -198,11 +198,25 @@ function getConfiguredServerContext(): Maybe<ServerContext> {
serverPath !== "" &&
cerbRuntime !== null &&
cerbRuntime !== undefined &&
cerbRuntime !== ""
cerbRuntime !== "" &&
fs.existsSync(serverPath) &&
fs.existsSync(cerbRuntime)
) {
return { serverPath, cerbRuntime };
} else {
return undefined;
const bundledServer = vsc.Uri.joinPath(context.extensionUri, "cn-lsp-server");
const bundledRuntime = vsc.Uri.joinPath(context.extensionUri, "cerb-runtime");
if (
fs.existsSync(bundledServer.path) &&
fs.existsSync(bundledRuntime.path)
) {
return {
serverPath: bundledServer.path,
cerbRuntime: bundledRuntime.path,
};
} else {
return undefined;
}
}
}

Expand Down